Search code examples
assemblyx86protected-mode

Questions about indirect jmp in protected mode


Because the address xxxx:yyyyyyyy is 32 bits in protected mode, I put a 48-bits address in a piece of memory and want to give indirect jmp, here is what I wrote:

mov eax,s1
mov [address],eax
mov ax,SelectorCode32
mov [address+4],ax
jmp  fword [address]

address:dd 0
        dw 0

But the nasm shows that jmp fword [address] is wrong, I've read some suggestions like this, but didn't help either, so what should I do?


Solution

  • The NASM's syntax for near and far calls is different from those of TASM and MASM.

    Here are the two options for indirect jumps:

    jmp [fptr] ; jump to CS:0x12345678
    jmp far [fptr] ; jump to 0xABCD:0x12345678
    
    fptr dd 0x12345678
         dw 0xABCD
    

    You can also always push the far address onto the stack and do retf.