www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - inline assembler - far jump

reply Kevin VR <azra pandora.be> writes:
Hello,

One of the things I find interesting in D is it's capability to support 
both higher level programming stuff (such as GC, OO, etc), and at the 
same time allow low level stuff (such as inline assembler). (and keep it 
elegant :)

Currently I'm experimenting with D's low level capabilities, and I've 
ran into a problem:
How can I do a far jump in D, using the inline assembler?
In NASM I would have something like this (I got this from a tutorial in 
kernel programming at osdever.net):

<code>
jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!
flush2: ret       ; Returns back to the C (D actually :) code!
</code>

I can find some references to far pointers and segmentation in D's 
inline assembler section, but it's unclear to me how to use this, or 
even if this is possible at all?

thanks,
Kevin
May 15 2005
next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
These far jumps are only for real mode.
http://www.answers.com/main/ntquery?method=4&dsid=2222&dekey=X86-jmp&gwp=8&curtab=2222_1

D assumes it is running always in protected / flat mode I guess.

Andrew.


"Kevin VR" <azra pandora.be> wrote in message 
news:d68mje$k40$1 digitaldaemon.com...
 Hello,

 One of the things I find interesting in D is it's capability to support 
 both higher level programming stuff (such as GC, OO, etc), and at the same 
 time allow low level stuff (such as inline assembler). (and keep it 
 elegant :)

 Currently I'm experimenting with D's low level capabilities, and I've ran 
 into a problem:
 How can I do a far jump in D, using the inline assembler?
 In NASM I would have something like this (I got this from a tutorial in 
 kernel programming at osdever.net):

 <code>
 jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!
 flush2: ret       ; Returns back to the C (D actually :) code!
 </code>

 I can find some references to far pointers and segmentation in D's inline 
 assembler section, but it's unclear to me how to use this, or even if this 
 is possible at all?

 thanks,
 Kevin 
May 15 2005
prev sibling parent mclysenk mtu.edu writes:
Well, you could just push the full address on the stack and then do a retf.

:push <segment>
:push <address>
:retf

That would be the same thing as a far jump if I'm not mistaken.

Or you could just assemble it by hand,

:db 0xea
:dd <address>
:dw <segment>

However, it would be nice if you could just do the jump, but I'm not sure if
that's possible in D, since it's built for 32-bit protected mode only.

In article <d68mje$k40$1 digitaldaemon.com>, Kevin VR says...
Hello,

One of the things I find interesting in D is it's capability to support 
both higher level programming stuff (such as GC, OO, etc), and at the 
same time allow low level stuff (such as inline assembler). (and keep it 
elegant :)

Currently I'm experimenting with D's low level capabilities, and I've 
ran into a problem:
How can I do a far jump in D, using the inline assembler?
In NASM I would have something like this (I got this from a tutorial in 
kernel programming at osdever.net):

<code>
jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!
flush2: ret       ; Returns back to the C (D actually :) code!
</code>

I can find some references to far pointers and segmentation in D's 
inline assembler section, but it's unclear to me how to use this, or 
even if this is possible at all?

thanks,
Kevin
May 16 2005