Reputation: 119
I'm working on a numerical base conversion program and I've stumbled upon a problem in one part of the code:
mov ax,36864
mov bx,ax
mov dx,0
sub bx,4096
jns ustawGr
mov al,48
int 29h
jmp konwerter16
It works fine for numbers up to 36863, but for some reason it is not going into ustawGr
and prints 0
for any higher number even though the register should be able to contain it.
Upvotes: 1
Views: 223
Reputation: 58447
36864 - 4096
is 0x9000 - 0x1000 == 0x8000
. In two's complement representation 0x8000
is the greatest negative 16-bit number (-32768
). And since the value is negative, your jns
won't be taken.
Upvotes: 3