aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/start.s
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-04-06 10:11:07 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-04-06 10:11:07 +0800
commitf3e040230772f978540a71aea43dfde200992922 (patch)
treebd8ca31b72dd01e24980b073854e263589530f56 /libpsn00b/libc/start.s
downloadpsn00bsdk-f3e040230772f978540a71aea43dfde200992922.tar.gz
First commit
Diffstat (limited to 'libpsn00b/libc/start.s')
-rw-r--r--libpsn00b/libc/start.s39
1 files changed, 39 insertions, 0 deletions
diff --git a/libpsn00b/libc/start.s b/libpsn00b/libc/start.s
new file mode 100644
index 0000000..c9b529b
--- /dev/null
+++ b/libpsn00b/libc/start.s
@@ -0,0 +1,39 @@
+# Start function!
+# This is essentially the entrypoint of the PS-EXE
+
+.set noreorder
+
+.section .text
+
+.global _start
+.type _start, @function
+_start:
+
+ addiu $sp, -32
+ sw $ra, 28($sp)
+
+ la $gp, _gp # Very important to set!
+
+ la $a0, .bss # What are the CORRECT symbols for BSS start and end?
+ la $a1, _end
+.clear_bss:
+ sb $0 , 0($a0)
+ blt $a0, $a1, .clear_bss
+ addiu $a0, 1
+
+ la $a0, _end+4 # Initialize heap for malloc (does not use BIOS maalloc)
+ li $a1, 1572864
+ jal InitHeap
+ nop
+
+ move $a0, $0 # No support for arguments for now
+ move $a1, $0
+
+ jal main
+ nop
+
+ lw $ra, 28($sp)
+ addiu $sp, 32
+ jr $ra
+ nop
+ \ No newline at end of file