67 lines
1.2 KiB
ArmAsm
67 lines
1.2 KiB
ArmAsm
.data
|
|
godot_msg:
|
|
.string "Waiting for Godot"
|
|
|
|
.text
|
|
|
|
.balign 4
|
|
.global _start
|
|
_start:
|
|
/* Disable IRQ and FIQ */
|
|
cpsid if
|
|
|
|
/* Initialize stack pointers */
|
|
cps #0x13
|
|
ldr sp, =stack_svc
|
|
cps #0x1b
|
|
ldr sp, =stack_und
|
|
cps #0x17
|
|
ldr sp, =stack_abt
|
|
cps #0x12
|
|
ldr sp, =stack_irq
|
|
cps #0x11
|
|
ldr sp, =stack_fiq
|
|
cps #0x1f
|
|
ldr sp, =stack_sys
|
|
|
|
/* Enter SuperVisor Mode */
|
|
cps #0x13
|
|
|
|
/* Call constructors */
|
|
ldr r10, =_init_array_start
|
|
ldr r11, =_init_array_end
|
|
1:
|
|
cmp r10, r11 // if every constructor has been called
|
|
beq 3f
|
|
|
|
// "resta di stucco è un barbatrucco"
|
|
ldr r0, [r10] // load constructor address in r0
|
|
ldr lr, =2f // store return address in lr
|
|
mov pc, r0 // jump to address in r0
|
|
2:
|
|
add r10, #4 // next constructor
|
|
b 1b
|
|
3:
|
|
|
|
/* Enable Vector Table BAR remapping (clears bit 13 of SCTLR) */
|
|
mrc p15, 0, r0, c1, c0, 0
|
|
and r0, #0xffffdfff
|
|
mcr p15, 0, r0, c1, c0, 0
|
|
|
|
/* Sets VBAR with custom vector table's address */
|
|
ldr r0, =vectab
|
|
mcr p15, 0, r0, c12, c0, 0
|
|
|
|
/* Enable IRQ and FIQ */
|
|
cpsie if
|
|
|
|
/* C-Main */
|
|
bl main
|
|
|
|
ldr r0, =godot_msg
|
|
bl printkl
|
|
|
|
/* Endless busy loop */
|
|
b .
|
|
|