
October 16th, 2009, 04:04 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 3
Time spent in forums: 20 m 55 sec
Reputation Power: 0
|
|
|
[Assembly] signed math
Hi,
I'm taking my first steps in assembly and I'm a bit confused over signed versus unsigned math. I'm debugging a simple executable which at one point does a subtraction.
Before the operation, this is what AX and BX look like:
AX CF8F
BX 2300
After "sub ax, bx" the sign flag is set and AX becomes
AX AC8F
When thinking in unsigned numbers I understand what is happening.
53135 - 8960 = 44175
However, when I'm trying to understand what happens in terms of signed numbers, I'm a bit confused.
AX CF8F = 1100 1111 1000 1111 = -100 1111 1000 1111 = -20367
BX 2300 = 0010 0011 0000 0000 = +010 0011 0000 0000 = 8960
-20367 - 8960 = -29327 = -111 0010 1000 1111 = 1111 0010 1000 1111 = F28F
So obviously there is something wrong with my reasoning. Who can help me out?
Thanks
|