Files
pokemon-gba/source/start.s
T

46 lines
949 B
ArmAsm

.syntax unified
.cpu arm7tdmi
.arm
@ A GBA cartridge starts with a branch and a 192-byte hardware header.
@ tools/rom_header.py fills in the required boot logo and checksum.
.section .gba_header, "ax", %progbits
.global _start
_start:
b reset
.space 188, 0
.section .text.start, "ax", %progbits
reset:
@ Give IRQ and system mode separate stacks in internal RAM.
mov r0, #0xd2
msr cpsr_c, r0
ldr sp, =0x03007fa0
mov r0, #0xdf
msr cpsr_c, r0
ldr sp, =0x03007f00
@ Copy initialized variables from the cartridge into working RAM.
ldr r0, =__data_load
ldr r1, =__data_start
ldr r2, =__data_end
1:
cmp r1, r2
ldrlo r3, [r0], #4
strlo r3, [r1], #4
blo 1b
@ Clear uninitialized variables, as C expects.
ldr r1, =__bss_start
ldr r2, =__bss_end
mov r3, #0
2:
cmp r1, r2
strlo r3, [r1], #4
blo 2b
bl main
3:
b 3b
.section .note.GNU-stack,"",%progbits