For example:
jmp LABEL
... # loads of instructions
jmp LABEL
.... # loads of instructions
LABEL:
.....
Without the size of jmp LABEL
instruction, the address of LABEL can't be determine because the two forms of jmp instruction (short (2 Bytes), near (3 or 5 Bytes)) have different size. Whereas, without knowing about LABEL's address, you cannot determine which form to use.
How does assembler solve it?
It depends on the kind of assembler you use. A simple 2-pass assembler (like MASM) makes it your problem. They'll pick a long jump and you have to write JMP SHORT LABEL
explicitly to get the short one. And bitch at you when you guessed wrong.
An optimizing n-pass assembler (like TASM) sorts it out by itself. It assumes the short jump and if it discovers that it can't reach then it restarts the assembly, now with a long jump.
You can easily tell what kind of flavor you have. Just look at the code listing it generates, if you get the 5 byte long jump then you have the 2-pass kind.
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