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!, {r2, lr}
22ldrb r2, [lr, #-2]
23cmp r2, #4
24bleq IntrWait
25cmp r2, #5
26moveq r0, #1
27moveq r1, #1
28bleq IntrWait
29ldmfd sp!, {r2, lr}
30movs pc, lr
31
32irqBase:
33stmfd sp!, {r0-r3, r12, lr}
34mov r0, #0x04000000
35add lr, pc, #0
36ldr pc, [r0, #-4]
37ldmfd sp!, {r0-r3, r12, lr}
38subs pc, lr, #4
39
40IntrWait:
41stmfd sp!, {r4, lr}
42# Save inputs
43mrs r3, cpsr
44bic r3, #0x80
45msr cpsr, r3
46# Pull current interrupts enabled and add the ones we need
47mov r4, #0x04000000
48# See if we want to return immediately
49cmp r0, #0
50mov r0, #0
51mov r2, #1
52beq .L1
53# Halt
54.L0:
55strb r0, [r4, #0x301]
56.L1:
57# Check which interrupts were acknowledged
58strb r2, [r4, #0x204]
59ldrh r3, [r4, #-8]
60ands r3, r1
61eorne r3, r1
62strneh r3, [r4, #-8]
63strb r0, [r4, #0x204]
64beq .L0
65#Restore state
66mrs r0, cpsr
67orr r0, #0x80
68msr cpsr, r0
69ldmfd sp!, {r4, pc}