moved crt0 into src, adjusted symbol_addrs, fixed xbeginning beginning (#63)

This commit is contained in:
Noah McQueen 2024-10-28 00:28:28 -06:00 committed by GitHub
parent 7f3ec41867
commit 5112c74546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 97 additions and 9 deletions

View File

@ -4,6 +4,13 @@
// .text section //
///////////////////////////////////////////////////////////
//=========================================================
// crt0.s
//=========================================================
_start = 0x00100000; // type:func
_exit = 0x001000B8; // type:func
_root = 0x001000C0; // type:func
//=========================================================
// libc.a
//=========================================================

View File

@ -9,11 +9,6 @@
// _heap_size = 0x0000a000; // type:label
// crt0
// ENTRYPOINT = 0x00100008; // type:func
_start = 0x00100008; // type:func
_exit = 0x001000b8; // type:func
// game
main = 0x00100438; // type:func

View File

@ -21,6 +21,7 @@ options:
subalign: 8
disasm_unknown: True
named_regs_for_c_funcs: False
hasm_in_src_path: True
segments:
- [0, databin, elf_header]
- name: main
@ -29,8 +30,8 @@ segments:
vram: 0x100000
bss_size: 0x1E1500
subsegments:
- [0x80, asm, crt0]
- [0x168, c, xbeginning]
- [0x80, hasm, lib/crt0]
- [0x148, c, xbeginning]
- [0x1260, c, xporcupine]
- [0x18F0, asm]
- [0x6258, c, xpancake]

78
src/lib/crt0.s Normal file
View File

@ -0,0 +1,78 @@
.include "macro.inc"
.set noat
.set noreorder
.align 3
glabel _start
nop
nop
/* Clear .bss segment */
lui $v0, %hi(D_0048DB00)
lui $v1, %hi(D_66F018)
addiu $v0, $v0, %lo(D_0048DB00)
addiu $v1, $v1, %lo(D_66F018)
bssloop:
sq $zero, 0x0($v0)
nop
sltu $at, $v0, $v1
nop
nop
bnez $at, bssloop
addiu $v0, $v0, 0x10
/* Initialize main thread */
lui $a0, %hi(D_0048DB00)
lui $a1, %hi(D_1FE0000)
lui $a2, %hi(D_20000)
lui $a3, %hi(D_0048DB00)
lui $t0, %hi(_root)
addiu $a0, $a0, %lo(D_0048DB00)
addiu $a1, $a1, %lo(D_1FE0000)
addiu $a2, $a2, %lo(D_20000)
addiu $a3, $a3, %lo(D_0048DB00)
addiu $t0, $t0, %lo(_root)
daddu $gp, $a0, $zero
addiu $v1, $zero, 60
syscall
daddu $sp, $v0, $zero
/* Initialize heap region */
lui $a0, %hi(D_66F018)
lui $a1, %hi(D_A000)
addiu $a0, $a0, %lo(D_66F018)
addiu $a1, $a1, %lo(D_A000)
addiu $v1, $zero, 61
syscall
/* Initialize system */
jal _InitSys
nop
/* Flush data cache */
jal FlushCache
daddu $a0, $zero, $zero
/* Call main program */
ei
lui $v0, %hi(D_0048DB00)
addiu $v0, $v0, %lo(D_0048DB00)
lw $a0, 0x0($v0)
jal main
addiu $a1, $v0, 0x4
j Exit
daddu $a0, $v0, $zero
nop
.size _start, . - _start
glabel _exit
j Exit
daddu $a0, $zero, $zero
.size _exit, . - _exit
glabel _root
addiu $v1, $zero, 35
syscall # ExitThread()
.size _root, . - _root

View File

@ -95,14 +95,21 @@ void func_00177748(void);
void func_00177768(void);
void func_001777A8(void);
s32 func_001000C8(void) {
func_00106A40();
return 0;
}
s32 func_001000E8(void) {
sceGsSyncPath(0, 0);
func_00106AA8();
return 0;
}
INCLUDE_ASM("asm/nonmatchings/xbeginning", func_00100118);
void func_00100118(void);
void func_00100118(void) {
*(u16*)(func_0011ED30(159998, func_001000C8) + 2) = -1;
*(u16*)(func_0011ED30(184990, func_001000E8) + 2) = -1;
}
void func_00100168(void) {
s32 new_var;