Far jump to code segment with D inline assembler

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Mar 13 03:49:22 PDT 2007


Alexander Panek wrote:
> I am just doing some R&D regarding low level development with D. Due to the
> multiboot standard, and the weird things you have to do at bootup on the x86
> architecture, one has to perform a far jump to a specific code segment given
> as an offset to the prior registered GDT.

This doesn't have much to do with the multiboot standard, just the x86 
architecture. Multiboot just doesn't allow you to assume the GDT is 
already correctly loaded (though the segment registers will be).

 > Now, with nasm/Intel syntax, you
> can just do:
> 
> /+ ... +/
> jmp 0x08:flush
> 
> flush:
> /+ ... +/
> 
> .. in D, my brain tells me, the syntax would theoretically look like this:
> 
> void flush ( )
> 
>     asm {
>         naked;
> 
>         /+ ... +/
>         jmp int far ptr 0x08:flush;
> 
>         flush:
>             /+ ... +/
> 
>         ret;
>     }
> }
> 
> Yet, the compiler (1.009) yells at me, that either the operand size for
> `jmp` is wrong, or it would have expected nops instead of the jump
> statement.
> 
> Any advice one could give?

Sorry, I have no idea how to do this in the D inline assembler. I just 
have an external .asm file that sets up the GDT (and rudimentary paging) 
before calling the D code. I prefer the NASM variation of asm syntax anyway.


More information about the Digitalmars-d-learn mailing list