Search code examples
assemblyoperating-systemx86bootloaderatt

How to far jump to $0x9000:%ax using AT&T syntax?


I'm writing a toy os to learn the workings of it, here I came into a little problem. I want to do a long jump, just as follows:

ljmp $0x9000, *(%ax)

The section address is 0x9000, the offset address is stored in the register ax (currently I'm still under real mode), I've tried the following, none of them worked.

ljmp $0x9000, ax
ljmp $0x9000, %ax
ljmp $0x9000, (%ax)
ljmp $0x9000, *(%ax)

So how to do the trick? I'm using GNU AS (i686-elf-as).


Solution

  • As an alternative to "nrz"'s method you may also push 0x9000 and AX and perform a RETF:

    pushw $0x9000
    push %ax
    retf
    

    Note: On original 8086s and 8088s even the "pushw $xxxx" instruction does not exist...