diff options
Diffstat (limited to 'libpsn00b/libc/setjmp.S')
| -rw-r--r-- | libpsn00b/libc/setjmp.S | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libpsn00b/libc/setjmp.S b/libpsn00b/libc/setjmp.S new file mode 100644 index 0000000..fb0dc6b --- /dev/null +++ b/libpsn00b/libc/setjmp.S @@ -0,0 +1,50 @@ +# PSn00bSDK setjmp/longjmp +# (C) 2023 spicyjpeg - MPL licensed +# +# This is not a "proper" implementation of setjmp/longjmp as it does not save +# COP0 and GTE registers, but it is fully compatible with the version found in +# the BIOS. + +.set noreorder + +.section .text.setjmp, "ax", @progbits +.global setjmp +.type setjmp, @function + +setjmp: + sw $ra, 0x00($a0) + sw $sp, 0x04($a0) + sw $fp, 0x08($a0) + sw $s0, 0x0c($a0) + sw $s1, 0x10($a0) + sw $s2, 0x14($a0) + sw $s3, 0x18($a0) + sw $s4, 0x1c($a0) + sw $s5, 0x20($a0) + sw $s6, 0x24($a0) + sw $s7, 0x28($a0) + sw $gp, 0x2c($a0) + + jr $ra + li $v0, 0 + +.section .text.longjmp, "ax", @progbits +.global longjmp +.type longjmp, @function + +longjmp: + lw $ra, 0x00($a0) + lw $sp, 0x04($a0) + lw $fp, 0x08($a0) + lw $s0, 0x0c($a0) + lw $s1, 0x10($a0) + lw $s2, 0x14($a0) + lw $s3, 0x18($a0) + lw $s4, 0x1c($a0) + lw $s5, 0x20($a0) + lw $s6, 0x24($a0) + lw $s7, 0x28($a0) + lw $gp, 0x2c($a0) + + jr $ra + move $v0, $a1 |
