Annotation of coherent/b/lib/libc/gen/i386/setjmp.s, revision 1.1.1.1

1.1       root        1: //////////
                      2: / libc/gen/i386/setjmp.s
                      3: / i386 C library.
                      4: / ANSI 4.6.1.1, 4.6.2.1.
                      5: //////////
                      6: 
                      7: //////////
                      8: / #include <setjmp.h>
                      9: /
                     10: / int
                     11: / setjmp(env) jmp_buf env;
                     12: / Store the current register "environment"
                     13: / (frame pointer, stack pointer, return address, register variables)
                     14: / into "env" and return 0.
                     15: /
                     16: / void
                     17: / longjmp(env, value) jmp_buf env; int value;
                     18: / Restore the registers from "env", causing the setjmp() call to
                     19: / return again, this time returning the given "value".
                     20: /
                     21: / For i386, the "jmp_buf" structure is an array of six dwords.
                     22: //////////
                     23: 
                     24: SAVEEBP        .equ    0
                     25: SAVEESP        .equ    SAVEEBP+4
                     26: SAVERA .equ    SAVEESP+4
                     27: SAVEESI        .equ    SAVERA+4
                     28: SAVEEDI        .equ    SAVEESI+4
                     29: SAVEEBX        .equ    SAVEEDI+4
                     30: 
                     31:        .globl  setjmp
                     32:        .globl  longjmp
                     33: 
                     34: setjmp:
                     35:        pop     %ecx                    / return address to ECX
                     36:        movl    %edx, (%esp)            / env to EDX
                     37:        movl    SAVEEBP(%edx), %ebp     / save EBP
                     38:        movl    SAVEESP(%edx), %esp     / save ESP (after return address popped)
                     39:        movl    SAVERA(%edx), %ecx      / save return address
                     40:        movl    SAVEESI(%edx), %esi     / save ESI
                     41:        movl    SAVEEDI(%edx), %edi     / save EDI
                     42:        movl    SAVEEBX(%edx), %ebx     / save EBX
                     43:        subl    %eax, %eax              / return value 0 to EAX
                     44:        ijmp    %ecx                    / and return
                     45: 
                     46: longjmp:
                     47:        pop     %edx                    / longjmp return address to bit bucket
                     48:        pop     %edx                    / env to EDX
                     49:        pop     %eax                    / return value to EAX
                     50:        orl     %eax, %eax              / check if return value 0
                     51:        jnz     ?0                      / nope, ok
                     52:        incl    %eax                    / ANSI 4.6.2.1: return 1 if arg is 0
                     53: 
                     54: ?0:
                     55:        mov     %ebp, SAVEEBP(%edx)     / restore EBP
                     56:        mov     %esp, SAVEESP(%edx)     / restore ESP
                     57:        mov     %esi, SAVEESI(%edx)     / restore ESI
                     58:        mov     %edi, SAVEEDI(%edx)     / restore EDI
                     59:        mov     %ebx, SAVEEBX(%edx)     / restore EBX
                     60:        ijmp    SAVERA(%edx)            / return through saved return address
                     61: 
                     62: / end of libc/gen/i386/setjmp.s

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.