This blog was last modified 428 days before.
Jump Instruction Type
In ASM, we have both Conditional Jump and Unconditional Jump. As their name implies, first one only perform the jump if certain condition satified, and the second one always perform jump operation.
For unconditional jump, we use JMP
instruction.
For conditional jump, check the Github ASM Learning Book - Conditional Jump. (Estimated Read Time: 10-15min)
Remember These Conditional Jump Instruction
Actually we just need to remember their are two types of conditional jump: Flag-based Jump and Cmp-based Jump.
Flag-based Jump
Just remember it's J
+ [FlagName]
. For example, jump if zero flag triggered is JZ
. It's opposite would be JNZ
.
Here we suggest take some time remember the name and its meaning of the commonly-used flags, it would quite helps.
Cmp-based Jump
For unsigned number, we use words above/below. For example, jump if above would be JB
.
For signed number, we use the more common words greater/less. For example just if greater is JG
.
- If you want to also include the equal situation, just add an
E
. For above example isJBE
andJGE
. - If you want to use the opposite, add
N
. For above example isJNBE
andKNGE
.
Range of Jmp Description
Why jump instruction has range?
Think about how jump work. We already says several times that the only thing that CPU recognize is number (address). So not surprisingly, the implement of jump instruction in ASM is also based on memory address.
Then what's the range of the address?
One thing we need to acknowledge first is that 8086 x16 ASM is using relative jump.
For Conditional Jump, it's generally believed that the relative jump range is [-128, 127]
. The jump instruction use one byte, and the addr use another one byte. And the signed number range represented by one byte is from -128 to 127.
For Unconditional Jump, the ASM Learning Book on Github (I've given the link above) said the range is [-8000h, 7fffh]
(which is the signed number range represented by 16-bit). But based on my experiment on emu8086
, seems that the Unconditional Jump also only use one single byte to store the realtive address info.
No comment