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, #0xFFFFFFFF
51strh r0, [r2, #2]
52mov r0, #0x1F
53msr cpsr, r0
54swi #0x020000
55mov r0, #0xD3
56msr cpsr, r0
57mov r0, #0x04000000
58ldrh r2, [r0, #-8]
59ldrh r1, [sp, #0]
60ands r1, r2
61eorne r1, r2
62strneh r1, [r0, #-8]
63ldrh r0, [sp, #2]
64mov r1, #0x04000000
65add r1, #0x200
66strh r0, [r1, #0]
67beq IntrWaitLoop
68add sp, #4
69ldmfd sp!, {r2,pc}