Data segments

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Curufir

Re:Data segments

Post 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.
bkilgore

Re:Data segments

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Data segments

Post 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.
bkilgore

Re:Data segments

Post 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
Post Reply