diff options
author | midipix <writeonce@midipix.org> | 2016-09-22 00:19:02 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-09-22 00:19:02 -0400 |
commit | e3a9601cdc0ea5cb5d2a43ea7e8f0f4bf8afdbbf (patch) | |
tree | a12a3c663b7eca7193ce370a112b4e2b9a0cf326 /src/setjmp | |
parent | 1cf6f622d8362989eaf11cc8a3e7ad51e68bcbad (diff) | |
download | mmglue-e3a9601cdc0ea5cb5d2a43ea7e8f0f4bf8afdbbf.tar.bz2 mmglue-e3a9601cdc0ea5cb5d2a43ea7e8f0f4bf8afdbbf.tar.xz |
nt32: implemented setjmp(), longjmp().
Diffstat (limited to 'src/setjmp')
-rw-r--r-- | src/setjmp/nt32/longjmp.s | 18 | ||||
-rw-r--r-- | src/setjmp/nt32/setjmp.s | 14 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/setjmp/nt32/longjmp.s b/src/setjmp/nt32/longjmp.s index 73b2e61..045b93d 100644 --- a/src/setjmp/nt32/longjmp.s +++ b/src/setjmp/nt32/longjmp.s @@ -10,7 +10,23 @@ ___longjmp: __longjmp: _longjmp: - test %edx, %edx # is val zero? + movl 4(%esp), %ecx # jump buffer + movl 8(%esp), %eax # val + + test %eax, %eax # is val zero? + jne 1f # no: return val + xor $1, %eax # yes: return one + +1: + movl 20(%ecx), %esi # restore regs + movl 16(%ecx), %edi + movl 12(%ecx), %ebp + movl 8(%ecx), %ebx + + movl 4(%ecx), %esp # original stack pointer + + movl (%ecx), %edx # original return address + jmp *%edx .section .got$longjmp .global __imp__longjmp diff --git a/src/setjmp/nt32/setjmp.s b/src/setjmp/nt32/setjmp.s index 7ef6485..d00fba0 100644 --- a/src/setjmp/nt32/setjmp.s +++ b/src/setjmp/nt32/setjmp.s @@ -10,6 +10,20 @@ ___setjmp: __setjmp: _setjmp: + movl 4(%esp), %edx # jump buffer + + movl (%esp), %eax # return address + movl %eax, (%edx) + + leal 4(%esp), %ecx # caller's stack pointer + movl %ecx, 4(%edx) + + movl %ebx, 8(%edx) + movl %ebp, 12(%edx) + movl %edi, 16(%edx) + movl %esi, 20(%edx) + + xor %eax,%eax ret .section .got$setjmp,"r" |