forked from below/HelloSilicon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.s
35 lines (31 loc) · 781 Bytes
/
debug.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
@ Various macros to help with debugging
@ These macros preseve all registers.
@ Beware they will change cpsr.
.macro printReg reg
push {r0-r4, lr} @ save regs
mov r2, R\reg @ for the %d
mov r3, R\reg @ for the %x
mov r1, #\reg
add r1, #'0' @ for %c
ldr r0, =ptfStr @ printf format str
str r1, [sp, #-32]
str r2, [sp, #8]
str r3, [sp, #16]
bl _printf @ call printf
add sp, sp, #32
pop {r0-r4, lr} @ restore regs
.endm
.macro printStr str
push {r0-r4, lr} @ save regs
ldr r0, =1f @ load print str
bl _printf @ call printf
pop {r0-r4, lr} @ restore regs
b 2f @ branch around str
1: .asciz "\str\n"
.align 4
2:
.endm
.data
ptfStr: .asciz "R%c = %16d, 0x%08x\n"
.align 4
.text