bit shift was left, of course, write in comment what code really does!
[AROS.git] / arch / i386-pc / exec / userstate.s
blob414e410c455bef1f187a655d782ee750f4787324
1 #include <aros/i386/asm.h>
3 .text
4 .align 16
6 .globl cpu_SuperState
7 .type cpu_SuperState, @function
9 // This is a SuperState() helper. It's called via Supervisor().
10 // Its job is to restore a stack pointer and return to user's code.
11 cpu_SuperState:
12 movl %esp, %eax // return int handler stack
13 movl 12(%eax),%esp // use user stack
14 pushl (%eax) // push return address
15 ret // return from SuperState() call
17 .size cpu_SuperState, .-cpu_SuperState
19 .globl AROS_SLIB_ENTRY(UserState, Exec, 26)
20 .type AROS_SLIB_ENTRY(UserState, Exec, 26), @function
22 AROS_SLIB_ENTRY(UserState, Exec, 26):
23 popl %ecx // Get return address
24 movl (%esp), %eax // Get supervisor return stack
25 movl %ecx, (%eax) // Set return address
26 movl %esp, 12(%eax) // Set USP in exception stack frame
27 movl %eax, %esp // SSP = SP
28 iret // Exit from interrupt
30 .size AROS_SLIB_ENTRY(UserState, Exec, 26), .-AROS_SLIB_ENTRY(UserState, Exec, 26)