6 # crt0.s file for the GameCube V1.1 by Costis (costis@gbaemu.com)!
8 # Updates: Added support for clearing the BSS section so that global
9 # variables are cleared to 0 upon start-up.
11 # This is start-up code for initializing the GameCube system and hardware
12 # before executing the actual user program code. It clears the GPR's,
13 # initializes the FPR's, initializes the Data, Code, and L2 caches, clears
14 # and initializes SPR's, and disables exceptions (interrupts).
16 # Have fun!!! Please e-mail any suggestions or bugs to costis@gbaemu.com.
25 .extern __sbss_start, __bss_end, __CheckARGV
26 .globl _start, __main, __system_argv
32 .long 0 # command line
33 .long 0 # command line length
36 .long 0 # end address of argv
39 bl __InitBATS # Initialize BATs to a clear and known state
40 bl __InitGPRS # Initialize the General Purpose Registers
41 bl __InitHardware # Initialize some aspects of the Hardware
42 bl __InitSystem # Initialize more cache aspects, clear a few SPR's, and disable interrupts.
44 bl __CheckARGV # check for argv & initialise struct
51 # Clear the SBSS section!
53 ori r3,r3,__sbss_start@l
56 ori r5,r5,__sbss_end@l
60 # Clear the BSS section!
62 ori r3,r3,__bss_start@l
70 b SYS_Init # Branch to the user code!
73 # Clear all of the GPR's to 0
104 lis sp,__crt0stack@h # we take 0x8173FFF0 as the topmost starting point for our stack,this gives us ~128Kb Stack
105 ori sp,sp,__crt0stack@l
111 ori r2,r2,_SDA2_BASE_@l # Set the Small Data 2 (Read Only) base register.
113 ori r13,r13,_SDA_BASE_@l # Set the Small Data (Read\Write) base register.
117 # Enable the Floating Point Registers
123 bl __InitPS # Initialize Paired Singles
124 bl __InitFPRS # Initialize the FPR's
125 bl __InitCache # Initialize the system caches
129 //r3 = ptr, r4 = fill, r5 = size
152 .section .sdata,"aw",@progbits
154 .type __system_argv, @object
155 .size __system_argv, 4