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:
sub eax,1 adc eax,0
sub eax,n jc .over mov eax,0 .over: