Page 1 of 1
The sequence of CPU's pushing register when interrupt occur?
Posted: Thu Apr 03, 2008 1:07 am
by oohayulin
When a interrupt occurs, in what sequence CPU push the registers???
In the bochs I traced the stacks: before "int 3" excution and before "cli" in a isr stub function. I found it just pushed eflags(first), cs(second), eip(third) registers into the stack.
Is it right?
Maybe you can tell me in what sequence "pushad" push the general registers by the way.
Posted: Thu Apr 03, 2008 1:26 am
by JamesM
That's right. When it does a ring change it also pushes SS (first) and ESP (second), followed by the rest as normal.
Pusha pushes eax, ecx, edx, ebx, esp, ebp, esi, edi in that order.
More info available
here.
Cheers,
James
Posted: Thu Apr 03, 2008 1:37 am
by oohayulin
OK. 3Q.
JamesM, I am reading your tutorial and got the problem.
maybe you can add some information about the "struct resgisters" because I found the member sequence in this struct is according to the sequence of "ring change pushing" , "pushing int_no and errcode" and "pushad".
It was my confused problem yesterday. I drawed a long stack diagram to understand it.
Posted: Thu Apr 03, 2008 7:57 am
by Krox
http://www.sandpile.org/
Really nice reference for all stackframes, other "CPU-structs" and some more stuff...
Posted: Thu Apr 03, 2008 8:24 am
by JamesM
oohayulin wrote:OK. 3Q.
JamesM, I am reading your tutorial and got the problem.
maybe you can add some information about the "struct resgisters" because I found the member sequence in this struct is according to the sequence of "ring change pushing" , "pushing int_no and errcode" and "pushad".
It was my confused problem yesterday. I drawed a long stack diagram to understand it.
Hi,
You're right, the registers structure is tailored to the stack frame created in my tutorials. It works for inter ring changes and non ring changes, because in the second case the last two members actually just point to junk, but the rest are good. Draw a diagram and work out why
Posted: Thu Apr 03, 2008 9:18 am
by oohayulin
JamesM wrote:Draw a diagram and work out why
Yeah. Drawing a diagram is great and helpful to understand. Now I have known much from drawing it.
Maybe others can try drawing too!