Page 1 of 1

The "iret" Instruction

Posted: Sun Feb 02, 2003 12:28 am
by Perica
..

Re:The "iret" Instruction!!

Posted: Sun Feb 02, 2003 5:05 am
by drizzt
...
0x12345678 <---------- stack pointer before int

An interrupt occurs!

...
0x12345678
(dword) EFLAGS
(dword) CS
(dword) EIP <-----------stack pointer after int

Re:The "iret" Instruction!!

Posted: Sun Feb 02, 2003 11:12 am
by Slasher
As Drizzt said, the interrupt causes the CPU to Push the
EFLAGS,CP and EIP in that order onto the stack. The iret instruction is an Interrupt Return instruction that causes the CPU to restore the EFLAGS,CP and EIP values to the ones previously stored on the stack(it pops them off the stack in reverse order EIP,CP then EFLAGS). This effectively returns the CPU to the program at the point in its code when the interrupt occurred. Hope this helps.