Bit Test Complement
Home Language Journey Art Blog
09/03/2022

Saturated subtract on x64

Decrement can be optimized into:

 sub eax,1
 adc eax,0


Subtracting arbitrary values with min=0 work without the additional compare

 sub eax,n
 jc .over
 mov eax,0
.over: