if (b < a) a = b;The approach used here does not use any branches which may mess up your BTB (Branch Target Buffer)
; ; Find minimum of two unsigned values ; ; input: ; eax = value a ; ebx = value b ; ; output: ; eax = smallest value ; ; destroys: ; ebx, ecx ; flags ; sub ebx,eax sbb ecx,ecx and ecx,ebx add eax,ecxYou can use this gem on 16 bit machines too, just use 16 bit registers. This gem comes from Agner Fog's Pentium optimization manual. Be sure to get this manual.