summaryrefslogtreecommitdiff
path: root/newlib/libc/machine/m32r/setjmp.S
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-12-15 09:38:53 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2017-12-15 09:39:34 -0500
commitf95a4a932476be2ba99e2fd081e8d2bc6ea12813 (patch)
tree75f67192cb2d7b7b575c94edda318e475239b63c /newlib/libc/machine/m32r/setjmp.S
parentf60aca96985e68c7d8a52eb7bc955fb80e132f73 (diff)
Import newlib and create makefile
Diffstat (limited to 'newlib/libc/machine/m32r/setjmp.S')
-rw-r--r--newlib/libc/machine/m32r/setjmp.S52
1 files changed, 52 insertions, 0 deletions
diff --git a/newlib/libc/machine/m32r/setjmp.S b/newlib/libc/machine/m32r/setjmp.S
new file mode 100644
index 0000000..e6938ef
--- /dev/null
+++ b/newlib/libc/machine/m32r/setjmp.S
@@ -0,0 +1,52 @@
+# setjmp/longjmp for m32r. The jmpbuf looks like this:
+#
+# Register jmpbuf offset
+# reserved 0x00
+# R8 0x04
+# R9 0x08
+# R10 0x0c
+# R11 0x10
+# R12 0x14
+# R13 (FP) 0x18
+# R14 (LR) 0x1c
+# R15 (SP) 0x20
+# reserved 0x24
+
+ .text
+ .global setjmp
+setjmp:
+ ;addi r0, #-4 ; commented out as first word is reserved
+ ;st r1, @+r0
+ st r8, @+r0
+ st r9, @+r0
+ st r10, @+r0
+ st r11, @+r0
+ st r12, @+r0
+ st r13, @+r0
+ st r14, @+r0
+ st r15, @+r0
+
+# Return 0 to caller.
+ ldi r0, #0
+ jmp lr
+
+ .global longjmp
+longjmp:
+ addi r0, #4 ; first word is reserved
+ ;ld r1, @r0+
+ ld r8, @r0+
+ ld r9, @r0+
+ ld r10, @r0+
+ ld r11, @r0+
+ ld r12, @r0+
+ ld r13, @r0+
+ ld r2, @r0+ ; return address
+ ld r15, @r0+
+
+# If caller attempted to return 0, return 1 instead.
+
+ mv r0, r1
+ bnez r0, .Lnonzero
+ ldi r0, #1
+.Lnonzero:
+ jmp r2