How do you use the jump family of instructions?
This is what they've got:
JL label
"It" jumps if it is less than or if it is not larger than or equal to.
My question is what is it in this sentence? Say I have a variable in ebx
and I want to jump to label there:
if ebx
is <= 10
.
Specifically I'm interested in using the x86 jump family of instructions
JLE
instruction actually tests two flags at once:ZF
)CF
)If Carry and Zero flags are 1 then the short relative jump will be executed.
Maybe just a word how
CMP
instruction works.CMP
instruction is likeSUB
(subtract), but the destination register will not be updated after exsecution. So the following code will perform the same result like CMP ebx, 10. CMP and SUB instruction affect to flags: Carry, Parity, Auxiliary, Zero, Sign and Overflow flags.The jump itself checks the flags in the EFL register. These are usually set with TEST or CMP(or as a side effect of many other instructions).
See also: The art of assembly language on CMP
As a sidenote: You should get the Intel reference manuals. In particular the two part "Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 2: Instruction Set Reference" which describes all x86 instructions.
The x86 assembly uses a system of bit-flags that represent the result of comparisons. The conditional jump instructions use these flags when deciding whether to perform the jump or not.
In your case you'd use the following two instructions:
JB - work with unsigned numbers (Jump Below) <
JL - work with signed numbers