Getting sign of an integer in Assembly

Posted by Sagekilla on Stack Overflow See other posts from Stack Overflow or by Sagekilla
Published on 2010-05-13T00:47:19Z Indexed on 2010/05/13 0:54 UTC
Read the original article Hit count: 280

Filed under:
|
|
|

Hi all, I'm writing some assembly for a project using MASM (32-bit), and I was wondering what would be the easiest way to do this:

int delta = A - B;
int value = floor((delta + sign(delta)) / 2);

Which is basically the following mapping:

For 1 < A < 9, and B = 5:
A = [1, 2] -> -2
A = [3, 4] -> -1
A = [5] -> 0
A = [6, 7] -> +1
A = [8, 9] -> +1

Any help is much appreciated!

© Stack Overflow or respective owner

Related posts about rounding

Related posts about assembly