summaryrefslogtreecommitdiffhomepage
path: root/src/setjmp
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
committermidipix <writeonce@midipix.org>2015-03-08 13:23:20 -0400
commit86062740f1e8eeb4c554055cf304dc1e0e87ea43 (patch)
tree35d8309221f4fd2050fefbc1b3b3957a1099ce8a /src/setjmp
parent41058bd82ed2ae880c463d61e5702aef07681bf0 (diff)
downloadmmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.bz2
mmglue-86062740f1e8eeb4c554055cf304dc1e0e87ea43.tar.xz
initial commit of core port files.
signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'src/setjmp')
-rw-r--r--src/setjmp/nt64/longjmp.s28
-rw-r--r--src/setjmp/nt64/setjmp.s23
2 files changed, 51 insertions, 0 deletions
diff --git a/src/setjmp/nt64/longjmp.s b/src/setjmp/nt64/longjmp.s
new file mode 100644
index 0000000..0fcf52e
--- /dev/null
+++ b/src/setjmp/nt64/longjmp.s
@@ -0,0 +1,28 @@
+.text
+.globl __longjmp
+.globl _longjmp
+.globl longjmp
+
+__longjmp:
+_longjmp:
+longjmp:
+ test %edx, %edx # is val zero?
+ jne 1f # no: return val
+ xor $1, %edx # yes: return one
+
+1:
+ mov %edx, %eax # return value
+
+2:
+ mov 0x10(%rcx), %rbx # restore regs
+ mov 0x18(%rcx), %rbp
+ mov 0x20(%rcx), %rdi
+ mov 0x28(%rcx), %rsi
+ mov 0x30(%rcx), %r12
+ mov 0x38(%rcx), %r13
+ mov 0x40(%rcx), %r14
+ mov 0x48(%rcx), %r15
+
+ mov 0x08(%rcx), %rsp # saved stack pointer
+ mov (%rcx), %rdx # return address
+ jmp *%rdx # return
diff --git a/src/setjmp/nt64/setjmp.s b/src/setjmp/nt64/setjmp.s
new file mode 100644
index 0000000..3e8a1ea
--- /dev/null
+++ b/src/setjmp/nt64/setjmp.s
@@ -0,0 +1,23 @@
+.text
+.globl __setjmp
+.globl _setjmp
+.globl setjmp
+
+__setjmp:
+_setjmp:
+setjmp:
+ pop (%rcx) # return address
+ mov %rsp, 0x08(%rcx) # caller's stack pointer
+ push (%rcx) # restore own stack pointer
+
+ mov %rbx, 0x10(%rcx)
+ mov %rbp, 0x18(%rcx)
+ mov %rdi, 0x20(%rcx)
+ mov %rsi, 0x28(%rcx)
+ mov %r12, 0x30(%rcx)
+ mov %r13, 0x38(%rcx)
+ mov %r14, 0x40(%rcx)
+ mov %r15, 0x48(%rcx)
+
+ xor %eax, %eax
+ ret