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
The jle instruction is a conditional jump that follows a test. It performs a signed comparison jump after a cmp if the destination operand is less than or equal to the source operand.
In the x86 assembly language, the JMP instruction performs an unconditional jump. Such an instruction transfers the flow of execution by changing the program counter.
A jump instruction, like "jmp", just switches the CPU to executing a different piece of code. It's the assembly equivalent of "goto", but unlike goto, jumps are notconsidered shameful in assembly.
je" (jump if equal) and "jne" (jump if not equal) are just aliases of jz & jnz, because if the difference is zero, then the two values are equal.
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).
CMP ebx,10
JLE there
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.
JLE
instruction conducts two tests:
SF
) != Overflow Flag (OF
)ZF
) == 1If Zero flags is 1 and Signed Flag and Overflow Flag are not equal, then the short relative jump will be executed.
Maybe just a word how CMP
instruction works. CMP
instruction is like SUB
(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.
push ebx //store ebx value to stack
sub ebx, 10
pop ebx //restore ebx value from stack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With