aboutsummaryrefslogtreecommitdiff
path: root/indev/psn00bdbg-mk2/monitor/sdkinst.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 /indev/psn00bdbg-mk2/monitor/sdkinst.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 'indev/psn00bdbg-mk2/monitor/sdkinst.S')
-rw-r--r--indev/psn00bdbg-mk2/monitor/sdkinst.S65
1 files changed, 65 insertions, 0 deletions
diff --git a/indev/psn00bdbg-mk2/monitor/sdkinst.S b/indev/psn00bdbg-mk2/monitor/sdkinst.S
new file mode 100644
index 0000000..6d20624
--- /dev/null
+++ b/indev/psn00bdbg-mk2/monitor/sdkinst.S
@@ -0,0 +1,65 @@
+#
+# To use this installer properly, the program text must be compiled to
+# load at a higher address such as 0x80012000.
+#
+# Then call the function early in your program:
+#
+# void install_monitor(void);
+#
+# ...
+#
+# int main(int argc, const char *argv[])
+# {
+# ResetGraph(0);
+#
+# EnterCriticalSection();
+# install_monitor();
+# ExitCriticalSection();
+# ...
+#
+.set noreorder
+
+.section .text
+
+.global _install_monitor
+.type _install_monitor, @function
+_install_monitor: # = Patch installer routine
+
+ addiu $sp, -4
+ sw $ra, 0($sp)
+
+ la $a0, debug_payload
+ la $a1, debug_payload_end
+ la $a2, debug_payload
+ subu $a1, $a2
+ jal .Lcopymem
+ lui $a2, 0xA001
+
+ lui $a0, 0x8001
+ jalr $a0
+ nop
+
+ lw $ra, 0($sp)
+ addiu $sp, 4
+ jr $ra
+ nop
+
+ .Lcopymem: # installer's copy routine
+
+ addiu $a1, -4
+ lw $v0, 0($a0)
+ addiu $a0, 4
+ sw $v0, 0($a2)
+ bgtz $a1, .Lcopymem
+ addiu $a2, 4
+ jr $ra
+ nop
+
+
+.section .data
+
+debug_payload:
+
+ .incbin "patch.bin"
+
+debug_payload_end: