-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.asm
174 lines (132 loc) · 2.51 KB
/
debug.asm
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
; file: debug.asm target ATmega128L-4MHz-STK300
; Debugging library using the UART interface
; Copyright 2023: Daniel Panero (342800), Yasmina Jemili (310507)
.define DEBUG 1
.if DEBUG == 1
; Write a message into the console
; - @0 message
.macro DBMSG
in _sreg, SREG
push _sreg
PRINTF UART0_putc
.db CR, @0, 0
pop _sreg
out SREG, _sreg
.endmacro
; Write a message and SREG into the console
; - @0 message
.macro DBSREG
push a1
push a0
in a0, SREG
clr a1
PRINTF UART0_putc
.db CR, @0, FBIN, a, 0
out SREG, a0
pop a0
pop a1
.endmacro
; Write a message and the register values into the console
; - @0 message
; - @1 register (the binary value will be output)
.macro DBREG
push a1
push a0
in _sreg, SREG
push _sreg
mov a0, @1
clr a1
PRINTF UART0_putc
.db CR, @0, FBIN, a, 0
pop _sreg
out SREG, _sreg
pop a0
pop a1
.endmacro
; Write a message and the register values into the console with formatting
; - @0 message
; - @1 format (FBIN, FHEX, FDEC, FCHAR, FSTR)
.macro DBREGF
push a1
push a0
in _sreg, SREG
push _sreg
mov a0, @2
clr a1
PRINTF UART0_putc
.db CR, @0, @1, a, 0
pop _sreg
out SREG, _sreg
pop a0
pop a1
.endmacro
; Write a message and the registers values into the console
; - @0 message
; - @1 register high
; - @2 register low
.macro DBREGS
push a1
push a0
in _sreg, SREG
push _sreg
mov a1, @1
mov a0, @2
PRINTF UART0_putc
.db CR, @0, FBIN, a, 0
pop _sreg
out SREG, _sreg
pop a0
pop a1
.endmacro
; Write a message and the registers values into the console with formatting
; - @0 message
; - @1 format (FBIN, FHEX, FDEC, FCHAR, FSTR)
; - @2 register high
; - @3 register low
.macro DBREGSF
push a1
push a0
in _sreg, SREG
push _sreg
mov a1, @2
mov a0, @3
PRINTF UART0_putc
.db CR, @0, @1, a, 0
pop _sreg
out SREG, _sreg
pop a0
pop a1
.endmacro
; Write a message and the register IO values into the console
; - @0 message
; - @1 IO register (the binary value will be output)
.macro DBIO
push a1
push a0
in _sreg, SREG
push _sreg
in a0, @1
clr a1
PRINTF UART0_putc
.db CR, @0, FBIN, a, 0
pop _sreg
out SREG, _sreg
pop a0
pop a1
.endmacro
.else
.macro DBMSG
.endmacro
.macro DBSREG
.endmacro
.macro DBREG
.endmacro
.macro DBREGF
.endmacro
.macro DBREGS
.endmacro
.macro DBREGSF
.endmacro
.macro DBIO
.endmacro
.endif