1 # setjmp/longjmp for Renesas RX.
3 # The jmpbuf looks like this:
5 # Register jmpbuf offset
24 # R1 contains the pointer to jmpbuf:
26 # int R1 = setjmp (jmp_buf R1)
27 # void longjmp (jmp_buf R1, int R2)
29 # The ABI allows for R1-R5 to be clobbered by functions. We must be
30 # careful to always leave the stack in a usable state in case an
35 .type _setjmp, @function
37 mov.l r0, [r1] ; save all the general registers
38 mov.l r1, 0x4[r1] ; longjmp won't use this, but someone else might.
53 mov.l [r0], r2 ; get return address off the stack
54 mov.l r2, 0x40[r1] ; PC
55 mov #0, r1 ; Return 0.
58 .size _setjmp, .Lend1 - _setjmp
62 .type _longjmp, @function
64 tst r2, r2 ; Set the Z flag if r2 is 0.
65 stz #1, r2 ; If the Z flag was set put 1 into the return register.
66 mov r2, 4[r1] ; Put r2 (our return value) into the setjmp buffer as r1.
68 mov.l [r1], r0 ; Restore the stack - there's a slot for PC
69 mov.l 0x40[r1], r2 ; Get the saved PC
70 mov.l r2, [r0] ; Overwrite the old return address
86 mov.l 0x4[r1], r1 ; This sets up the new return value
89 .size _longjmp, .Lend2 - _longjmp