Assembly cmp fails for correct values when comparing (ax register)/(value)
and variable
When I compare two values like
cmp numSmallerEqual, 57
JLE nextStep1
or
move ax, 57
cmp numSmallerEqual, ax
JLE nextStep1
it fails to jump even if num1 is smaller than 57. However when I do it
like this it works
mov ax,9
add ax, 48
mov dx,ax
mov ah,02
cmp numSmallerEqual, ax
JLE nextStep1
It miraculously works. The strangest thing is if I remove even one line ex
instead of:
mov ax,9
add ax, 48
I only add:
mov ax, 57
It fails.
numSmallerEqual is declared and assigned a character value that was read
from the keyboard as follows:
numSmallerEqual dw 0
mov ah,01
int 21h
mov numSmallerEqual, ax
First I don't understand why the fist compare fails, and second I can't
figure out why the second compare works (other than assuming it flushes
memory that I am not aware of). What is the reason for this behaviour?
No comments:
Post a Comment