summaryrefslogtreecommitdiff
path: root/src/setjmp
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-11 20:54:30 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-11 20:54:30 -0400
commit4f50d3e580761fd3c44fe8ed0db57858c5295f25 (patch)
treeef8934a96d428ccd899de156108adc6c56d3d6c9 /src/setjmp
parentffe55c6c457e3ea5f0559c3a92cedecc2c44a776 (diff)
split __setjmp and __longjmp into separate assembly files under src/setjmp
Diffstat (limited to 'src/setjmp')
-rw-r--r--src/setjmp/__longjmp.x86-64.s26
-rw-r--r--src/setjmp/__setjmp.x86-64.s26
2 files changed, 52 insertions, 0 deletions
diff --git a/src/setjmp/__longjmp.x86-64.s b/src/setjmp/__longjmp.x86-64.s
new file mode 100644
index 00000000..de666dce
--- /dev/null
+++ b/src/setjmp/__longjmp.x86-64.s
@@ -0,0 +1,26 @@
+.global __longjmp
+__longjmp:
+ mov %rdi, %rax
+ mov 0x08(%rax), %rbx
+ mov 0x18(%rax), %rdx
+ mov 0x20(%rax), %rsp
+ mov 0x28(%rax), %rbp
+ mov 0x30(%rax), %rsi
+ mov 0x38(%rax), %rdi
+ mov 0x40(%rax), %r8
+ mov 0x48(%rax), %r9
+ mov 0x50(%rax), %r10
+ mov 0x58(%rax), %r11
+ mov 0x60(%rax), %r12
+ mov 0x68(%rax), %r13
+ mov 0x70(%rax), %r14
+ mov 0x78(%rax), %r15
+ mov 0x80(%rax), %rcx
+ mov %rcx, 0x00(%rbp)
+ mov 0x88(%rax), %rcx
+ mov %rcx, 0x08(%rbp)
+ mov 0x90(%rax), %rcx
+ mov %rcx, 0x00(%rsp)
+ mov 0x10(%rax), %rcx
+ mov 0x00(%rax), %rax
+ ret
diff --git a/src/setjmp/__setjmp.x86-64.s b/src/setjmp/__setjmp.x86-64.s
new file mode 100644
index 00000000..d5b095e1
--- /dev/null
+++ b/src/setjmp/__setjmp.x86-64.s
@@ -0,0 +1,26 @@
+.global __setjmp
+__setjmp:
+ /* setjmp() in C sets env[0] to 0 */
+ mov %rbx, 0x08(%rdi)
+ mov %rcx, 0x10(%rdi)
+ mov %rdx, 0x18(%rdi)
+ mov %rsp, 0x20(%rdi)
+ mov %rbp, 0x28(%rdi)
+ mov %rsi, 0x30(%rdi)
+ mov %rdi, 0x38(%rdi)
+ mov %r8, 0x40(%rdi)
+ mov %r9, 0x48(%rdi)
+ mov %r10, 0x50(%rdi)
+ mov %r11, 0x58(%rdi)
+ mov %r12, 0x60(%rdi)
+ mov %r13, 0x68(%rdi)
+ mov %r14, 0x70(%rdi)
+ mov %r15, 0x78(%rdi)
+ mov 0x00(%rbp), %rax
+ mov %rax, 0x80(%rdi)
+ mov 0x08(%rbp), %rax
+ mov %rax, 0x88(%rdi)
+ mov 0x00(%rsp), %rax
+ mov %rax, 0x90(%rdi)
+ xor %rax, %rax
+ ret