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.
24 .extern __sbss_start, __bss_end, __CheckARGV
25 .globl _start, __main, __system_argv
31 .long 0 # command line
32 .long 0 # command line length
35 .long 0 # end address of argv
38 bl InitBATS # Initialize BATs to a clear and known state
39 bl InitGPRS # Initialize the General Purpose Registers
40 bl FPRInit # Initialize the FPR's
41 bl __PSInit # Initialize Paired Singles
42 bl __CacheInit # Initialize the system caches
43 bl __SystemInit # Initialize more cache aspects, clear a few SPR's, and disable interrupts.
45 bl __CheckARGV # check for argv & initialise struct
52 # Clear the BSS section!
54 ori r3,r3,__sbss_start@l
62 b SYS_Init # Branch to the user code!
65 # Clear all of the GPR's to 0
96 lis sp,__crt0stack@h # we take 0x8173FFF0 as the topmost starting point for our stack,this gives us ~128Kb Stack
97 ori sp,sp,__crt0stack@l
103 ori r2,r2,_SDA2_BASE_@l # Set the Small Data 2 (Read Only) base register.
105 ori r13,r13,_SDA_BASE_@l # Set the Small Data (Read\Write) base register.
109 # Enable the Floating Point Registers
114 # Clear all of the FPR's to 0
153 //r3 = ptr, r4 = fill, r5 = size
190 .section .sdata,"aw",@progbits
192 .type __system_argv, @object
193 .size __system_argv, 4