* same with xv6
[mascara-docs.git] / i386 / MIT / course / src / git.lab / net / lwip / jos / arch / longjmp.S
blob5fa39425d840506dcbfee485e8cf025eb789340f
1 #ifndef _ALIGN_TEXT
2 #define _ALIGN_TEXT .align 16, 0x90
3 #endif
5 #define ENTRY(x) \
6         .text; _ALIGN_TEXT; .globl x; .type x,@function; x:
9 ENTRY(jos_setjmp)
10         movl    4(%esp), %ecx   // jos_jmp_buf
12         movl    0(%esp), %edx   // %eip as pushed by call
13         movl    %edx,  0(%ecx)
15         leal    4(%esp), %edx   // where %esp will point when we return
16         movl    %edx,  4(%ecx)
18         movl    %ebp,  8(%ecx)
19         movl    %ebx, 12(%ecx)
20         movl    %esi, 16(%ecx)
21         movl    %edi, 20(%ecx)
23         movl    $0, %eax
24         ret
26 ENTRY(jos_longjmp)
27         // %eax is the jos_jmp_buf*
28         // %edx is the return value
30         movl     0(%eax), %ecx  // %eip
31         movl     4(%eax), %esp
32         movl     8(%eax), %ebp
33         movl    12(%eax), %ebx
34         movl    16(%eax), %esi
35         movl    20(%eax), %edi
37         movl    %edx, %eax
38         jmp     *%ecx