aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/start.s
blob: c9b529bd961a8897603a91770f4b7050c241c80c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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