Question

The 16-bit DOS unconditional jmp assembly instruction to machine code:

jmp FF   translated to EBFD
jmp 100  translated to EBFE
jmp 2    translated to E9FFFE
jmp eax  translated to 66FFE0
jmp 80   translated to E97DFF

I understand that EB, E9 and 66 indicate different jmps (short, near or register) but how about the value comes after it? for example, how exactly FF maps to FD and 100 maps to FE?

Était-ce utile?

La solution

The command encoding for a relative jump contains an offset that's relative to the command that's following the JMP. This is because when the JMP is being executed, the IP register is already pointing at the next command; the IP is incremented at the command fetch stage.

This encoding requires that the assembler knows the IP value at the JMP command. For that, in MS_DOS's 16-bit segmented mode they typically place an ORG directive somewhere early on in the file. Some assemblers might have a default for that. If the JMP destination is a label (as opposed to an absolute address), this is not necessary.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top