Hi everybody!
I just program a small code to find min and max of 3 integers. This is my min proc:
========================================
Min proc y1:DWORD, y2:DWORD, y3:DWORD
mov eax, y1
.if eax > y2
mov eax,y2
.endif
.if eax > y3
mov eax,y3
.endif
Ret
Min EndP
=========================================
It is true when compare between unsign ex: 3,4,5 ->3 or sign:-3,-4,-5 -> -5 but when I compare mix of them, it goes wrong: -3,4,5 -> 4.
I think that it just compare binary value. So do I have to seperate the case of sign with unsign.
Please show me the good way to solve it.
Thank you very much!
Posted on 2004-08-08 21:31:12 by zjhlogo
Try changing the :DWORD parameters to :SDWORD, this should fix things. Also, if you need the ".if" stuff with registers that need to be treated as signed, "sdword ptr eax" should do.

There's probably also a more efficient way to implement this function, but first things first :)
Posted on 2004-08-09 02:23:02 by f0dder

goes wrong: -3,4,5 -> 4.

-3 = FFFFFFFDh
4 = 4h
5 = 5h

check with windows calculator.
signed states are taken from 0-(left most bit on) as positive, and well (left most bit on +1) means negative but works as in:
(assuming 4 max)
-1
-2
-3
-4
0
1
2
3
4
Posted on 2004-08-09 12:57:29 by Black iCE
Thank you very much for your answers!:alright:
Posted on 2004-08-10 03:09:16 by zjhlogo