src/gba/hle-bios.s (view raw)
1#define nop andeq r0, r0
2
3.text
4
5b resetBase
6b undefBase
7b swiBase
8b pabtBase
9b dabtBase
10nop
11b irqBase
12b fiqBase
13
14resetBase:
15mov pc, #0x8000000
16
17swiBase:
18cmp sp, #0
19moveq sp, #0x04000000
20subeq sp, #0x20
21stmfd sp!, {lr}
22ldrb r0, [lr, #-2]
23cmp r0, #4
24bleq IntrWait
25cmp r0, #5
26bleq IntrWait
27ldmfd sp!, {lr}
28movs pc, lr
29
30irqBase:
31stmfd sp!, {r0-r3, r12, lr}
32mov r0, #0x04000000
33add lr, pc, #0
34ldr pc, [r0, #-4]
35ldmfd sp!, {r0-r3, r12, lr}
36subs pc, lr, #4
37
38IntrWait:
39stmfd sp!, {r2,lr}
40add sp, #-4
41strh r1, [sp, #0]
42IntrWaitLoop:
43mov r2, #0x04000000
44add r2, #0x200
45ldrh r0, [r2, #0]
46strh r0, [sp, #2]
47ldrh r1, [sp, #0]
48orr r1, r0, r1
49strh r1, [r2, #0]
50mov r0, #0x1F
51msr cpsr, r0
52swi #0x020000
53mov r0, #0xD3
54msr cpsr, r0
55mov r0, #0x04000000
56ldrh r2, [r0, #-8]
57ldrh r1, [sp, #0]
58ands r1, r2
59eorne r1, r2
60strneh r1, [r0, #-8]
61ldrh r0, [sp, #2]
62mov r1, #0x04000000
63add r1, #0x200
64strh r0, [r1, #0]
65beq IntrWaitLoop
66add sp, #4
67ldmfd sp!, {r2,pc}