Page 1 of 1

Stack pb when CPL switching

Posted: Fri Nov 07, 2003 5:56 pm
by pini
I'm switching from CPL3 to CPL0 when I receive an IRQ0. Here's my IRQ0 handler :

Code: Select all

int_irq0:
   cli
   push   eax
   call   task_tick
   test   eax,eax
   jnz   .nosw
   mov   eax,[tss.esp0] ; (*)
   cli
   hlt
well, task_tick is a simple C function that returns 0 if the current process has running its time out and .nosw is a label defined somewhere below.

the line (*) give 0x10C1BC to EAX, which is correct according to what the TSS.ESP0 field should contain, but ESP is 0x10C1A4 (0x10C1A8 without the push eax).

Shouldn't ESP be 0x10C1B8 = 0x10C1BC - 4 (push eax) ?
Where am I wrong ?

Re:Stack pb when CPL switching

Posted: Fri Nov 07, 2003 6:07 pm
by pini
I got the answer : ESP is loaded with TSS.ESP0 before pushing SS, ESP, EFLAGS, CS and EIP onto the stack