Page 2 of 2

Re:Data segments

Posted: Mon Aug 09, 2004 1:03 pm
by Curufir
This is already taken care of for you.

When an IRQ fires an interrupt is called.

Any time an interrupt is called the current value of eflags, cs and eip are pushed onto the stack. When you're finished with whatever the interrupt does you perform an iret which pops values for those registers back off the stack.

This is bog-standard x86 architecture stuff. If you aren't familiar with it then I suggest re-reading the Intel manuals before continuing much farther.

Re:Data segments

Posted: Thu Aug 19, 2004 9:31 am
by bkilgore
Pype.Clicker wrote:you can use "call eax", but afaik "call ebx:eax" does not exist. You can however use "call <address of a far_pointer>" and store the "segment:offset" you'd like to jump to at that address ...

You can also do a "dynamic" far call by using a far ret instead

Code: Select all

pushl $<segment selector>
pushl $<offset>
lret

Re:Data segments

Posted: Fri Aug 20, 2004 1:48 am
by Pype.Clicker
@bkilgore: no, that won't work. it can be used for a 'dynamic far jump", but you'll miss the current EIP and current CS that are pushed by the CPU when issueing CALL xxx instruction.

Re:Data segments

Posted: Fri Aug 20, 2004 9:33 am
by bkilgore
Pype: that's what i meant, dynamic far jump. Sorry bout that. For a dynamic far call though, why not just change that to:

Code: Select all

pushl %cs
pushl $retaddr
pushl $<segment selector>
pushl $<offset>
lret

retaddr:
Then the called code can issue an lret like normal and in this case it actually will be a far return to retaddr