How can I write a far absolute JMP or CALL instruction using MASM? Specifically how do I get it to emit these instruction using the EA and CA opcodes, without manually emitting them using DB or other data directives?
For example consider the case of jumping to the BIOS reset entry point at FFFF:0000 in a boot sector. If I were using NASM I could code this in one instruction in the obvious way:
jmp 0xffff:0
With the GNU assembler the syntax is less obvious, but the following will do the job:
jmp 0xffff, 0
However when I try the obvious solution with MASM:
jmp 0ffffh:0
I get the following error:
t206b.asm(3) : error A2096:segment, group, or segment register expected
Workarounds I'm trying to avoid
There are a number of possible workarounds I could use in MASM, like any of the following:
Hand assemble the instruction, emitting the machine code manually:
DB 0EAh, 0, 0, 0FFh, 0FFh
Use a far indirect jump:
bios_reset DD 0ffff0000h
...
jmp bios_reset ; FF 2E opcode: indirect far jump
Or push the address on the stack and use a far RET instruction to "return" to it:
push 0ffffh
push 0
retf
But is there anyway I can use an actual JMP instruction and have MASM generate the right opcode (EA)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…