You can't NEG
both parts of the number and expect a correct result. Example: -1
=0xFFFFFFFF 0xFFFFFFFF
If you apply NEG
to both halves you get 0x00000001 0x00000001
which is clearly wrong. You need to apply the general rule of flipping all the bits and adding one, for example:
not ecx
not edx
add ecx, 1
adc edx, 0
Furthermore, I assume the assignment just wants you to use add
and adc
, you don't have to handle carry yourself.