Initial revision
[ssr] / StraySrc / Libraries / Core / stream
1 ;
2 ; stream
3 ;
4 ; Debugging with VDUStream
5 ; VDUStream is copyright Computer Concepts. Distribution terms appear to
6 ; be ambiguous.
7 ;
8 ; © 1994-1998 Straylight
9 ;
10
11 ;----- Licensing note -------------------------------------------------------
12 ;
13 ; This file is part of Straylight's core library (corelib).
14 ;
15 ; Corelib is free software; you can redistribute it and/or modify
16 ; it under the terms of the GNU General Public License as published by
17 ; the Free Software Foundation; either version 2, or (at your option)
18 ; any later version.
19 ;
20 ; Corelib is distributed in the hope that it will be useful,
21 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ; GNU General Public License for more details.
24 ;
25 ; You should have received a copy of the GNU General Public License
26 ; along with Corelib. If not, write to the Free Software Foundation,
27 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
29 ;----- Overview -------------------------------------------------------------
30 ;
31 ; Macros provided:
32 ;
33 ; SAVE
34 ; LOAD
35 ; BPT
36 ; S
37 ; REGH
38 ; REGD
39 ; REGS
40 ; REGC
41 ; RDUMP
42
43 ; --- Macro: SAVE ---
44 ;
45 ; Arguments: --
46 ;
47 ; Use: Saves R0, R14 and the current flags so that they can be
48 ; restored by a subsequent LOAD.
49
50 MACRO
51 $label SAVE
52 $label STMFD R13!,{R0,R14}
53 STMFD R13!,{PC}
54 MEND
55
56 ; --- Macro: LOAD ---
57 ;
58 ; Arguments: --
59 ;
60 ; Use: Restores R0, R14 and the flags after a SAVE.
61
62 MACRO
63 $label LOAD
64 $label LDMFD R13!,{R14}
65 TEQP R14,#0
66 LDMFD R13!,{R0,R14}
67 MEND
68
69 ; --- Macro: BPT ---
70 ;
71 ; Arguments: msg == message to print
72 ; cc == condition
73 ;
74 ; Use: Inserts a Sledgehammer breakpoint in the code.
75
76 MACRO
77 $label BPT $msg,$cc
78 $label
79 [ "$cc"<>""
80 ADD$cc PC,PC,#0
81 ADD PC,PC,#(36+:LEN:"$msg"+4) :AND: -4
82 ]
83 SAVE
84 SWI XOS_WriteI+26
85 SWI XOS_WriteI+4
86 SWI XOS_WriteI+12
87 SWI XOS_WriteS
88 DCB "$msg",0
89 SWI XOS_NewLine
90 SWI Sledgehammer_BreakPoint
91 LOAD
92 MEND
93
94 ; --- Macro: S ---
95 ;
96 ; Arguments: str == a string to display
97 ;
98 ; Use: Writes a given string to VDUStream.
99
100 MACRO
101 $label S $str
102 $label SAVE
103 SWI Stream_WriteS
104 DCB "$str",13,10,0
105 LOAD
106 MEND
107
108 ; --- Macro: REGH ---
109 ;
110 ; Arguments: r == the register symbol to display
111 ; str == an optional name for the value
112 ;
113 ; Use: Writes to VDUStream the value of the given register as
114 ; a hex value.
115
116 MACRO
117 $label REGH $r,$str
118 $label SAVE
119 MOV R0,$r
120 SWI Stream_WriteS
121 [ "$str" <> ""
122 DCB "$str == &",0
123 |
124 DCB "$r == &",0
125 ]
126 SWI Stream_WriteH32
127 SWI Stream_NewLine
128 LOAD
129 MEND
130
131 ; --- Macro: REGC ---
132 ;
133 ; Arguments: r == the register symbol to display
134 ; str == an optional name for the value
135 ;
136 ; Use: Writes to VDUStream the value of the given register as
137 ; a character.
138
139 MACRO
140 $label REGC $r,$str
141 $label SAVE
142 MOV R0,$r
143 SWI Stream_WriteS
144 [ "$str" <> ""
145 DCB "$str == `",0
146 |
147 DCB "$r == `",0
148 ]
149 SWI Stream_WriteT8
150 MOV R0,#'''
151 SWI Stream_WriteT8
152 SWI Stream_NewLine
153 LOAD
154 MEND
155
156 ; --- Macro: REGD ---
157 ;
158 ; Arguments: r == the register symbol to display
159 ; str == an optional name for the value
160 ;
161 ; Use: Writes to VDUStream the value of the given register as
162 ; a decimal value.
163
164 MACRO
165 $label REGD $r,$str
166 $label SAVE
167 MOV R0,$r
168 SWI Stream_WriteS
169 [ "$str" <> ""
170 DCB "$str == ",0
171 |
172 DCB "$r == ",0
173 ]
174 SWI Stream_WriteD32
175 SWI Stream_NewLine
176 LOAD
177 MEND
178
179 ; --- Macro: REGS ---
180 ;
181 ; Arguments: r == the register symbol to display
182 ; str == an optional name for the value
183 ;
184 ; Use: Writes to VDUStream the null terminated string pointed to
185 ; by the given register.
186
187 MACRO
188 $label REGS $r,$str
189 $label SAVE
190 MOV R0,$r
191 SWI Stream_WriteS
192 [ "$str" <> ""
193 DCB "$str == `",0
194 |
195 DCB "$r == `",0
196 ]
197 SWI Stream_Write0
198 MOV R0,#'''
199 SWI Stream_WriteT8
200 SWI Stream_NewLine
201 LOAD
202 MEND
203
204 ; --- Macro: RDUMP ---
205 ;
206 ; Arguments: str == an optional heading string for the register dump
207 ;
208 ; Use: Displays a total register dump.
209
210 MACRO
211 $label RDUMP $str
212 IMPORT stream_regDump
213 $label STMFD R13!,{R0-PC}
214 ADD R0,R13,#16*4
215 STR R0,[R13,#13*4]
216 [ "$str" <> ""
217 SWI Stream_WriteS
218 DCB "$str",10,13,0
219 ]
220 MOV R0,R13
221 BL stream_regDump
222 LDMIA R13,{R0-R14}
223 MEND
224
225 ;----- That's all, folks ----------------------------------------------------
226
227 END