-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvectors.s
77 lines (58 loc) · 1.15 KB
/
vectors.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@ I believe Sven wrote these? Thanks sven :)
.ARM
.text
swi_vector:
stmfa sp!, {r0-r4, lr}
@ check SWI number
@ should work for ARM and THUMB (yay bigendian):
@
@ ARM:
@ OOnnnnNN BBBBBBBB
@ |--| ^--LR
@ ^--halfword retreived, mask last 8 bits to get number
@ THUMB:
@ xxxx OONN BBBB CCCC
@ |--| ^--LR
@ ^--halfword retreived, mask last 8 bits to get number
ldrh r3, [lr, #-2]
and r3, r3, #0xFF
cmp r3, #0xAB
bne return
@ check operation number (4=debug print)
cmp r0, #4
bne return
@ gpio port
ldr r3, =0x0d806814
loop:
ldrb r2, [r1]
bl send
add r1, #1
cmp r2, #0x00
bne loop
@ optional code to insert linefeed at the end of each print, some IOS modules seem to need this
@ to get sane output
@ mov r2, #0xa
@ bl send
return:
ldmfa sp!, {r0-r4, lr}
movs pc, lr
@ send a string over USBGecko
send:
mov r0, #0xd0
str r0, [r3, #0x00]
mov r0, #0xB0000000
orr r0, r0, r2, LSL #20
str r0, [r3, #0x10]
mov r0, #0x19
str r0, [r3, #0x0c]
sendloop:
ldr r0, [r3, #0x0c]
tst r0, #1
bne sendloop
ldr r0, [r3, #0x10]
tst r0, #0x04000000
mov r0, #0
str r0, [r3, #0x00]
beq send
mov pc, lr
.POOL