I see lots of questions about doing an if-else statement, but I haven't come across any that are about doing an if-elseif statement.
Here is a simplified version of my code, checking if 2 is less than, equal to, or greater than an input value:
mov eax, [input]
cmp eax, 2
jb less_than
cmp eax, 2
je equal_to
cmp eax, 2
ja greater_than
Where input is a number stored in the .data section, and less_than, equal_to, and greater_than are labels that each execute a separate procedure. The problem is that this statement will always execute the greater_than label, no matter the input.
My understanding of conditional jumps and labels is that if a condition is not met, the jump will not occur, and that labels will be skipped unless they are accessed by a jump statement. Is this understanding incorrect?
System Information:
I am using NASM on an x86 Debian machine.
Aucun commentaire:
Enregistrer un commentaire