Hi all,

Does anyone know how to implement the expression below in very little instructions:

if(y < 0 || (y == 0 && x >= 0)) a++;

The >= operator on the right can also be > (x cannot be zero). Obviously I want to avoid using conditional jumps. What I've come up with so far is:

mov eax, y
shr eax, 31
add a, eax
mov eax, x
neg eax
mov ecx, y
shr eax, cl
shr eax, 31
add a, eax

But I'm sure you gurus know much faster/shorter ways to do this. 8)
Posted on 2004-10-24 11:54:59 by C0D1F1ED
Here is one that uses 6 instructions.
mov eax,x

mov ecx,y
add eax,eax
adc ecx,-1
add ecx,ecx
adc a,0
Posted on 2004-10-24 12:18:57 by Sephiroth3
That's truely incredible. :shock: Thank you very much Sephiroth3!
Posted on 2004-10-24 17:23:13 by C0D1F1ED