From e3a9601cdc0ea5cb5d2a43ea7e8f0f4bf8afdbbf Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 22 Sep 2016 00:19:02 -0400 Subject: nt32: implemented setjmp(), longjmp(). --- src/setjmp/nt32/longjmp.s | 18 +++++++++++++++++- src/setjmp/nt32/setjmp.s | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') 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" -- cgit v1.2.3