mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
Reduce duplication in crt0.s
Couldn't move the interrupt setup though :/. Not sure why
This commit is contained in:
parent
ccb0e69ff3
commit
7e3b983e80
57
agb/crt0.s
57
agb/crt0.s
|
@ -22,31 +22,7 @@ b .Initialise_mb
|
||||||
ldr r1, =0x03007FFC
|
ldr r1, =0x03007FFC
|
||||||
str r0, [r1]
|
str r0, [r1]
|
||||||
|
|
||||||
@ copies iwram section in ewram to iwram
|
b .CommonInit
|
||||||
ldr r0, =__iwram_rom_start @ load memory address storing start of data for iwram in rom
|
|
||||||
ldr r1, =__iwram_data_start @ load memory address storing location of iwram in ram
|
|
||||||
ldr r2, =__iwram_rom_length_halfwords @ load number of 16 bit values to copy
|
|
||||||
swi 0x000B0000 @ call interrupt CpuSet.
|
|
||||||
@ r0: source
|
|
||||||
@ r1: destination
|
|
||||||
@ r2: length + size information
|
|
||||||
@
|
|
||||||
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
|
|
||||||
|
|
||||||
@ everything is in ewram so it is already there, no need to copy that bit
|
|
||||||
|
|
||||||
@ put zero in both r0 and r1
|
|
||||||
@ This corresponds to zero for argc and argv (which would technically be required for a c runtime)
|
|
||||||
ldr r0, =0
|
|
||||||
mov r1, r0
|
|
||||||
|
|
||||||
@ load main and branch
|
|
||||||
ldr r2, =main
|
|
||||||
bx r2
|
|
||||||
|
|
||||||
@ loop if we end up here
|
|
||||||
1:
|
|
||||||
b 1b
|
|
||||||
|
|
||||||
.Initialise:
|
.Initialise:
|
||||||
@ Set interrupt handler
|
@ Set interrupt handler
|
||||||
|
@ -54,24 +30,23 @@ b .Initialise_mb
|
||||||
ldr r1, =0x03007FFC
|
ldr r1, =0x03007FFC
|
||||||
str r0, [r1]
|
str r0, [r1]
|
||||||
|
|
||||||
|
|
||||||
@ copies iwram section in rom to iwram in ram
|
|
||||||
ldr r0, =__iwram_rom_start @ load memory address storing start of data for iwram in rom
|
|
||||||
ldr r1, =__iwram_data_start @ load memory address storing location of iwram in ram
|
|
||||||
ldr r2, =__iwram_rom_length_halfwords @ load number of 16 bit values to copy
|
|
||||||
swi 0x000B0000 @ call interrupt CpuSet.
|
|
||||||
@ r0: source
|
|
||||||
@ r1: destination
|
|
||||||
@ r2: length + size information
|
|
||||||
@
|
|
||||||
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
|
|
||||||
|
|
||||||
@ copies ewram section in rom to ewram in ram
|
@ copies ewram section in rom to ewram in ram
|
||||||
ldr r0, =__ewram_rom_start
|
ldr r0, =__ewram_rom_start @ load memory address storing start of data for ewram in rom
|
||||||
ldr r1, =__ewram_data_start
|
ldr r1, =__ewram_data_start @ load memory address storing location of ewram in ram
|
||||||
ldr r2, =__ewram_rom_length_halfwords
|
ldr r2, =__ewram_rom_length_halfwords @ load number of 16 bit values to copy
|
||||||
swi 0x000B0000
|
swi 0x000B0000 @ call interrupt CpuSet.
|
||||||
|
@ r0: source
|
||||||
|
@ r1: destination
|
||||||
|
@ r2: length + size information
|
||||||
|
@
|
||||||
|
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
|
||||||
|
|
||||||
|
.CommonInit:
|
||||||
|
@ copies iwram section in rom to iwram in ram
|
||||||
|
ldr r0, =__iwram_rom_start
|
||||||
|
ldr r1, =__iwram_data_start
|
||||||
|
ldr r2, =__iwram_rom_length_halfwords
|
||||||
|
swi 0x000B0000
|
||||||
|
|
||||||
@ put zero in both r0 and r1
|
@ put zero in both r0 and r1
|
||||||
@ This corresponds to zero for argc and argv (which would technically be required for a c runtime)
|
@ This corresponds to zero for argc and argv (which would technically be required for a c runtime)
|
||||||
|
|
Loading…
Reference in a new issue