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!, {r4, lr}
40add sp, #-4
41strh r1, [sp, #0]
42mov r4, #0x04000000
43add r4, #0x200
44ldrh r0, [r4, #0]
45strh r0, [sp, #2]
46ldrh r1, [sp, #0]
47orr r0, r1
48strh r0, [r4, #0x0]
49mov r4, #0x04000000
50IntrWaitLoop:
51mov r0, #0x1F
52msr cpsr, r0
53mov r0, #0
54strb r0, [r4, #0x301]
55mov r0, #0xD3
56msr cpsr, r0
57ldrh r0, [r4, #-8]
58ldrh r1, [sp, #0]
59ands r1, r0
60eorne r1, r0
61strneh r1, [r4, #-8]
62beq IntrWaitLoop
63mov r4, #0x04000000
64add r4, #0x200
65ldrh r0, [sp, #2]
66strh r0, [r4, #0]
67add sp, #4
68ldmfd sp!, {r4, pc}