aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/setjmp.S
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-07-05 02:34:11 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-07-05 02:34:11 +0200
commitbeb76e4dd362374b8f42cd971d394bba1074cd8d (patch)
tree3ea4cc342737afb9225c01160c92647ba66c78bd /libpsn00b/libc/setjmp.S
parent5d9aa2d3dfc7d6e51c2eb942ab4cdbae5571a40a (diff)
downloadpsn00bsdk-fix-include.tar.gz
Replace .include with #includefix-include
For some reason, both mipsel-unknown-elf-gcc 8.2.0 and mipsel-non-elf 15.1.0 were unable to resolve .include assembler directives. As a workaround, it is still possible to use the preprocessor, and therefore the usual #include preprocessor directive. However, this requires the assembly files to use the uppercase .S file extension.
Diffstat (limited to 'libpsn00b/libc/setjmp.S')
-rw-r--r--libpsn00b/libc/setjmp.S50
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