Rev 1088 | Rev 1396 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1088 | Rev 1314 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | 6 | ||
- | 7 | $Revision: 1314 $ |
|
7 | $Revision: 1088 $ |
8 | |
8 | 9 | _esp equ esp |
|
9 | 10 | ||
10 | ; |
11 | ; |
11 | ; Formatted Debug Output (FDO) |
12 | ; Formatted Debug Output (FDO) |
12 | ; Copyright (c) 2005-2006, mike.dld |
13 | ; Copyright (c) 2005-2006, mike.dld |
13 | ; Created: 2005-01-29, Changed: 2006-11-10 |
14 | ; Created: 2005-01-29, Changed: 2006-11-10 |
14 | ; |
15 | ; |
15 | ; For questions and bug reports, mail to mike.dld@gmail.com |
16 | ; For questions and bug reports, mail to mike.dld@gmail.com |
16 | ; |
17 | ; |
17 | ; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
18 | ; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
18 | ; |
19 | ; |
19 | 20 | ||
20 | ; to be defined: |
21 | ; to be defined: |
21 | ; __DEBUG__ equ 1 |
22 | ; __DEBUG__ equ 1 |
22 | ; __DEBUG_LEVEL__ equ 5 |
23 | ; __DEBUG_LEVEL__ equ 5 |
23 | 24 | ||
24 | macro debug_func name { |
25 | macro debug_func name { |
25 | if used name |
26 | if used name |
26 | name@of@func equ name |
27 | name@of@func equ name |
27 | } |
28 | } |
28 | 29 | ||
29 | macro debug_beginf { |
30 | macro debug_beginf { |
30 | align 4 |
31 | align 4 |
31 | name@of@func: |
32 | name@of@func: |
32 | } |
33 | } |
33 | 34 | ||
34 | debug_endf fix end if |
35 | debug_endf fix end if |
35 | 36 | ||
36 | macro DEBUGS _sign,[_str] { |
37 | macro DEBUGS _sign,[_str] { |
37 | common |
38 | common |
38 | local tp |
39 | local tp |
39 | tp equ 0 |
40 | tp equ 0 |
40 | match _arg:_num,_str \{ |
41 | match _arg:_num,_str \{ |
41 | DEBUGS_N _sign,_num,_arg |
42 | DEBUGS_N _sign,_num,_arg |
42 | tp equ 1 |
43 | tp equ 1 |
43 | \} |
44 | \} |
44 | match =0 _arg,tp _str \{ |
45 | match =0 _arg,tp _str \{ |
45 | DEBUGS_N _sign,,_arg |
46 | DEBUGS_N _sign,,_arg |
46 | \} |
47 | \} |
47 | } |
48 | } |
48 | 49 | ||
49 | macro DEBUGS_N _sign,_num,[_str] { |
50 | macro DEBUGS_N _sign,_num,[_str] { |
50 | common |
51 | common |
51 | pushf |
52 | pushf |
52 | pushad |
53 | pushad |
53 | local ..str,..label,is_str |
54 | local ..str,..label,is_str |
54 | is_str = 0 |
55 | is_str = 0 |
55 | forward |
56 | forward |
56 | if _str eqtype '' |
57 | if _str eqtype '' |
57 | is_str = 1 |
58 | is_str = 1 |
58 | end if |
59 | end if |
59 | common |
60 | common |
60 | if is_str = 1 |
61 | if is_str = 1 |
61 | jmp ..label |
62 | jmp ..label |
62 | ..str db _str,0 |
63 | ..str db _str,0 |
63 | ..label: |
64 | ..label: |
64 | add esp,4*8+4 |
65 | ; add esp,4*8+4 |
- | 66 | esp equ esp+4*8+4 |
|
65 | mov edx,..str |
67 | mov edx,..str |
- | 68 | esp equ _esp |
|
66 | sub esp,4*8+4 |
69 | ; sub esp,4*8+4 |
67 | else |
70 | else |
68 | mov edx,_str |
71 | mov edx,_str |
69 | end if |
72 | end if |
70 | if ~_num eq |
73 | if ~_num eq |
71 | if _num eqtype eax |
74 | if _num eqtype eax |
72 | if _num in |
75 | if _num in |
73 | mov esi,_num |
76 | mov esi,_num |
74 | else if ~_num eq esi |
77 | else if ~_num eq esi |
75 | movzx esi,_num |
78 | movzx esi,_num |
76 | end if |
79 | end if |
77 | else if _num eqtype 0 |
80 | else if _num eqtype 0 |
78 | mov esi,_num |
81 | mov esi,_num |
79 | else |
82 | else |
80 | local tp |
83 | local tp |
81 | tp equ 0 |
84 | tp equ 0 |
82 | match [_arg],_num \{ |
85 | match [_arg],_num \{ |
83 | mov esi,dword[_arg] |
86 | mov esi,dword[_arg] |
84 | tp equ 1 |
87 | tp equ 1 |
85 | \} |
88 | \} |
86 | match =0 =dword[_arg],tp _num \{ |
89 | match =0 =dword[_arg],tp _num \{ |
87 | mov esi,dword[_arg] |
90 | mov esi,dword[_arg] |
88 | tp equ 1 |
91 | tp equ 1 |
89 | \} |
92 | \} |
90 | match =0 =word[_arg],tp _num \{ |
93 | match =0 =word[_arg],tp _num \{ |
91 | movzx esi,word[_arg] |
94 | movzx esi,word[_arg] |
92 | tp equ 1 |
95 | tp equ 1 |
93 | \} |
96 | \} |
94 | match =0 =byte[_arg],tp _num \{ |
97 | match =0 =byte[_arg],tp _num \{ |
95 | movzx esi,byte[_arg] |
98 | movzx esi,byte[_arg] |
96 | tp equ 1 |
99 | tp equ 1 |
97 | \} |
100 | \} |
98 | match =0,tp \{ |
101 | match =0,tp \{ |
99 | 'Error: specified string width is incorrect' |
102 | 'Error: specified string width is incorrect' |
100 | \} |
103 | \} |
101 | end if |
104 | end if |
102 | else |
105 | else |
103 | mov esi,0x7FFFFFFF |
106 | mov esi,0x7FFFFFFF |
104 | end if |
107 | end if |
105 | call fdo_debug_outstr |
108 | call fdo_debug_outstr |
106 | popad |
109 | popad |
107 | popf |
110 | popf |
108 | } |
111 | } |
109 | 112 | ||
110 | macro DEBUGD _sign,_dec { |
113 | macro DEBUGD _sign,_dec { |
111 | local tp |
114 | local tp |
112 | tp equ 0 |
115 | tp equ 0 |
113 | match _arg:_num,_dec \{ |
116 | match _arg:_num,_dec \{ |
114 | DEBUGD_N _sign,_num,_arg |
117 | DEBUGD_N _sign,_num,_arg |
115 | tp equ 1 |
118 | tp equ 1 |
116 | \} |
119 | \} |
117 | match =0 _arg,tp _dec \{ |
120 | match =0 _arg,tp _dec \{ |
118 | DEBUGD_N _sign,,_arg |
121 | DEBUGD_N _sign,,_arg |
119 | \} |
122 | \} |
120 | } |
123 | } |
121 | 124 | ||
122 | macro DEBUGD_N _sign,_num,_dec { |
125 | macro DEBUGD_N _sign,_num,_dec { |
123 | pushf |
126 | pushf |
124 | pushad |
127 | pushad |
125 | if (~_num eq) |
128 | if (~_num eq) |
126 | if (_dec eqtype eax | _dec eqtype 0) |
129 | if (_dec eqtype eax | _dec eqtype 0) |
127 | 'Error: precision allowed only for in-memory variables' |
130 | 'Error: precision allowed only for in-memory variables' |
128 | end if |
131 | end if |
129 | if (~_num in <1,2,4>) |
132 | if (~_num in <1,2,4>) |
130 | if _sign |
133 | if _sign |
131 | 'Error: 1, 2 and 4 are only allowed for precision in %d' |
134 | 'Error: 1, 2 and 4 are only allowed for precision in %d' |
132 | else |
135 | else |
133 | 'Error: 1, 2 and 4 are only allowed for precision in %u' |
136 | 'Error: 1, 2 and 4 are only allowed for precision in %u' |
134 | end if |
137 | end if |
135 | end if |
138 | end if |
136 | end if |
139 | end if |
137 | if _dec eqtype eax |
140 | if _dec eqtype eax |
138 | if _dec in |
141 | if _dec in |
139 | mov eax,_dec |
142 | mov eax,_dec |
140 | else if ~_dec eq eax |
143 | else if ~_dec eq eax |
141 | if _sign = 1 |
144 | if _sign = 1 |
142 | movsx eax,_dec |
145 | movsx eax,_dec |
143 | else |
146 | else |
144 | movzx eax,_dec |
147 | movzx eax,_dec |
145 | end if |
148 | end if |
146 | end if |
149 | end if |
147 | else if _dec eqtype 0 |
150 | else if _dec eqtype 0 |
148 | mov eax,_dec |
151 | mov eax,_dec |
149 | else |
152 | else |
150 | add esp,4*8+4 |
153 | ; add esp,4*8+4 |
- | 154 | esp equ esp+4*8+4 |
|
151 | if _num eq |
155 | if _num eq |
152 | mov eax,dword _dec |
156 | mov eax,dword _dec |
153 | else if _num = 1 |
157 | else if _num = 1 |
154 | if _sign = 1 |
158 | if _sign = 1 |
155 | movsx eax,byte _dec |
159 | movsx eax,byte _dec |
156 | else |
160 | else |
157 | movzx eax,byte _dec |
161 | movzx eax,byte _dec |
158 | end if |
162 | end if |
159 | else if _num = 2 |
163 | else if _num = 2 |
160 | if _sign = 1 |
164 | if _sign = 1 |
161 | movsx eax,word _dec |
165 | movsx eax,word _dec |
162 | else |
166 | else |
163 | movzx eax,word _dec |
167 | movzx eax,word _dec |
164 | end if |
168 | end if |
165 | else |
169 | else |
166 | mov eax,dword _dec |
170 | mov eax,dword _dec |
167 | end if |
171 | end if |
- | 172 | esp equ _esp |
|
168 | sub esp,4*8+4 |
173 | ; sub esp,4*8+4 |
169 | end if |
174 | end if |
170 | mov cl,_sign |
175 | mov cl,_sign |
171 | call fdo_debug_outdec |
176 | call fdo_debug_outdec |
172 | popad |
177 | popad |
173 | popf |
178 | popf |
174 | } |
179 | } |
175 | 180 | ||
176 | macro DEBUGH _sign,_hex { |
181 | macro DEBUGH _sign,_hex { |
177 | local tp |
182 | local tp |
178 | tp equ 0 |
183 | tp equ 0 |
179 | match _arg:_num,_hex \{ |
184 | match _arg:_num,_hex \{ |
180 | DEBUGH_N _sign,_num,_arg |
185 | DEBUGH_N _sign,_num,_arg |
181 | tp equ 1 |
186 | tp equ 1 |
182 | \} |
187 | \} |
183 | match =0 _arg,tp _hex \{ |
188 | match =0 _arg,tp _hex \{ |
184 | DEBUGH_N _sign,,_arg |
189 | DEBUGH_N _sign,,_arg |
185 | \} |
190 | \} |
186 | } |
191 | } |
187 | 192 | ||
188 | macro DEBUGH_N _sign,_num,_hex { |
193 | macro DEBUGH_N _sign,_num,_hex { |
189 | pushf |
194 | pushf |
190 | pushad |
195 | pushad |
191 | if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
196 | if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
192 | 'Error: 1..8 are only allowed for precision in %x' |
197 | 'Error: 1..8 are only allowed for precision in %x' |
193 | end if |
198 | end if |
194 | if _hex eqtype eax |
199 | if _hex eqtype eax |
195 | if _hex in |
200 | if _hex in |
196 | if ~_hex eq eax |
201 | if ~_hex eq eax |
197 | mov eax,_hex |
202 | mov eax,_hex |
198 | end if |
203 | end if |
199 | mov edx,8 |
204 | mov edx,8 |
200 | else if _hex in |
205 | else if _hex in |
201 | if ~_hex eq ax |
206 | if ~_hex eq ax |
202 | movzx eax,_hex |
207 | movzx eax,_hex |
203 | end if |
208 | end if |
204 | if (_num eq) |
209 | if (_num eq) |
205 | mov edx,4 |
210 | mov edx,4 |
206 | end if |
211 | end if |
207 | else if _hex in |
212 | else if _hex in |
208 | if ~_hex eq al |
213 | if ~_hex eq al |
209 | movzx eax,_hex |
214 | movzx eax,_hex |
210 | end if |
215 | end if |
211 | if (_num eq) |
216 | if (_num eq) |
212 | mov edx,2 |
217 | mov edx,2 |
213 | end if |
218 | end if |
214 | end if |
219 | end if |
215 | else if _hex eqtype 0 |
220 | else if _hex eqtype 0 |
216 | mov eax,_hex |
221 | mov eax,_hex |
217 | else |
222 | else |
218 | add esp,4*8+4 |
223 | ; add esp,4*8+4 |
- | 224 | esp equ esp+4*8+4 |
|
219 | mov eax,dword _hex |
225 | mov eax,dword _hex |
- | 226 | esp equ _esp |
|
220 | sub esp,4*8+4 |
227 | ; sub esp,4*8+4 |
221 | end if |
228 | end if |
222 | if ~_num eq |
229 | if ~_num eq |
223 | mov edx,_num |
230 | mov edx,_num |
224 | else |
231 | else |
225 | if ~_hex eqtype eax |
232 | if ~_hex eqtype eax |
226 | mov edx,8 |
233 | mov edx,8 |
227 | end if |
234 | end if |
228 | end if |
235 | end if |
229 | call fdo_debug_outhex |
236 | call fdo_debug_outhex |
230 | popad |
237 | popad |
231 | popf |
238 | popf |
232 | } |
239 | } |
233 | 240 | ||
234 | ;----------------------------------------------------------------------------- |
241 | ;----------------------------------------------------------------------------- |
235 | 242 | ||
236 | debug_func fdo_debug_outchar |
243 | debug_func fdo_debug_outchar |
237 | debug_beginf |
244 | debug_beginf |
238 | pushad |
245 | pushad |
239 | movzx ebx,al |
246 | movzx ebx,al |
240 | mov eax,1 |
247 | mov eax,1 |
241 | mov ecx,sys_msg_board |
248 | mov ecx,sys_msg_board |
242 | call ecx ; sys_msg_board |
249 | call ecx ; sys_msg_board |
243 | popad |
250 | popad |
244 | ret |
251 | ret |
245 | debug_endf |
252 | debug_endf |
246 | 253 | ||
247 | debug_func fdo_debug_outstr |
254 | debug_func fdo_debug_outstr |
248 | debug_beginf |
255 | debug_beginf |
249 | mov eax,1 |
256 | mov eax,1 |
250 | .l1: dec esi |
257 | .l1: dec esi |
251 | js .l2 |
258 | js .l2 |
252 | movzx ebx,byte[edx] |
259 | movzx ebx,byte[edx] |
253 | or bl,bl |
260 | or bl,bl |
254 | jz .l2 |
261 | jz .l2 |
255 | mov ecx,sys_msg_board |
262 | mov ecx,sys_msg_board |
256 | call ecx ; sys_msg_board |
263 | call ecx ; sys_msg_board |
257 | inc edx |
264 | inc edx |
258 | jmp .l1 |
265 | jmp .l1 |
259 | .l2: ret |
266 | .l2: ret |
260 | debug_endf |
267 | debug_endf |
261 | 268 | ||
262 | debug_func fdo_debug_outdec |
269 | debug_func fdo_debug_outdec |
263 | debug_beginf |
270 | debug_beginf |
264 | or cl,cl |
271 | or cl,cl |
265 | jz @f |
272 | jz @f |
266 | or eax,eax |
273 | or eax,eax |
267 | jns @f |
274 | jns @f |
268 | neg eax |
275 | neg eax |
269 | push eax |
276 | push eax |
270 | mov al,'-' |
277 | mov al,'-' |
271 | call fdo_debug_outchar |
278 | call fdo_debug_outchar |
272 | pop eax |
279 | pop eax |
273 | @@: push 10 |
280 | @@: push 10 |
274 | pop ecx |
281 | pop ecx |
275 | push -'0' |
282 | push -'0' |
276 | .l1: xor edx,edx |
283 | .l1: xor edx,edx |
277 | div ecx |
284 | div ecx |
278 | push edx |
285 | push edx |
279 | test eax,eax |
286 | test eax,eax |
280 | jnz .l1 |
287 | jnz .l1 |
281 | .l2: pop eax |
288 | .l2: pop eax |
282 | add al,'0' |
289 | add al,'0' |
283 | jz .l3 |
290 | jz .l3 |
284 | call fdo_debug_outchar |
291 | call fdo_debug_outchar |
285 | jmp .l2 |
292 | jmp .l2 |
286 | .l3: ret |
293 | .l3: ret |
287 | debug_endf |
294 | debug_endf |
288 | 295 | ||
289 | debug_func fdo_debug_outhex |
296 | debug_func fdo_debug_outhex |
290 | __fdo_hexdigits db '0123456789ABCDEF' |
297 | __fdo_hexdigits db '0123456789ABCDEF' |
291 | debug_beginf |
298 | debug_beginf |
292 | mov cl,dl |
299 | mov cl,dl |
293 | neg cl |
300 | neg cl |
294 | add cl,8 |
301 | add cl,8 |
295 | shl cl,2 |
302 | shl cl,2 |
296 | rol eax,cl |
303 | rol eax,cl |
297 | .l1: rol eax,4 |
304 | .l1: rol eax,4 |
298 | push eax |
305 | push eax |
299 | and eax,0x0000000F |
306 | and eax,0x0000000F |
300 | mov al,[__fdo_hexdigits+eax] |
307 | mov al,[__fdo_hexdigits+eax] |
301 | call fdo_debug_outchar |
308 | call fdo_debug_outchar |
302 | pop eax |
309 | pop eax |
303 | dec edx |
310 | dec edx |
304 | jnz .l1 |
311 | jnz .l1 |
305 | ret |
312 | ret |
306 | debug_endf |
313 | debug_endf |
307 | 314 | ||
308 | ;----------------------------------------------------------------------------- |
315 | ;----------------------------------------------------------------------------- |
309 | 316 | ||
310 | macro DEBUGF _level,_format,[_arg] { |
317 | macro DEBUGF _level,_format,[_arg] { |
311 | common |
318 | common |
312 | if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
319 | if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
313 | local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
320 | local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
314 | _debug_str_ equ __debug_str_ # a1 |
321 | _debug_str_ equ __debug_str_ # a1 |
315 | a1 = 0 |
322 | a1 = 0 |
316 | c2 = 0 |
323 | c2 = 0 |
317 | c3 = 0 |
324 | c3 = 0 |
318 | f2 = 0 |
325 | f2 = 0 |
319 | repeat ..lbl-..f1 |
326 | repeat ..lbl-..f1 |
320 | virtual at 0 |
327 | virtual at 0 |
321 | db _format,0,0 |
328 | db _format,0,0 |
322 | load c1 word from %-1 |
329 | load c1 word from %-1 |
323 | end virtual |
330 | end virtual |
324 | if c1 = '%s' |
331 | if c1 = '%s' |
325 | virtual at 0 |
332 | virtual at 0 |
326 | db _format,0,0 |
333 | db _format,0,0 |
327 | store word 0 at %-1 |
334 | store word 0 at %-1 |
328 | load c1 from f2-c2 |
335 | load c1 from f2-c2 |
329 | end virtual |
336 | end virtual |
330 | if c1 <> 0 |
337 | if c1 <> 0 |
331 | DEBUGS 0,_debug_str_+f2-c2 |
338 | DEBUGS 0,_debug_str_+f2-c2 |
332 | end if |
339 | end if |
333 | c2 = c2 + 1 |
340 | c2 = c2 + 1 |
334 | f2 = %+1 |
341 | f2 = %+1 |
335 | DEBUGF_HELPER S,a1,0,_arg |
342 | DEBUGF_HELPER S,a1,0,_arg |
336 | else if c1 = '%x' |
343 | else if c1 = '%x' |
337 | virtual at 0 |
344 | virtual at 0 |
338 | db _format,0,0 |
345 | db _format,0,0 |
339 | store word 0 at %-1 |
346 | store word 0 at %-1 |
340 | load c1 from f2-c2 |
347 | load c1 from f2-c2 |
341 | end virtual |
348 | end virtual |
342 | if c1 <> 0 |
349 | if c1 <> 0 |
343 | DEBUGS 0,_debug_str_+f2-c2 |
350 | DEBUGS 0,_debug_str_+f2-c2 |
344 | end if |
351 | end if |
345 | c2 = c2 + 1 |
352 | c2 = c2 + 1 |
346 | f2 = %+1 |
353 | f2 = %+1 |
347 | DEBUGF_HELPER H,a1,0,_arg |
354 | DEBUGF_HELPER H,a1,0,_arg |
348 | else if c1 = '%d' | c1 = '%u' |
355 | else if c1 = '%d' | c1 = '%u' |
349 | local c4 |
356 | local c4 |
350 | if c1 = '%d' |
357 | if c1 = '%d' |
351 | c4 = 1 |
358 | c4 = 1 |
352 | else |
359 | else |
353 | c4 = 0 |
360 | c4 = 0 |
354 | end if |
361 | end if |
355 | virtual at 0 |
362 | virtual at 0 |
356 | db _format,0,0 |
363 | db _format,0,0 |
357 | store word 0 at %-1 |
364 | store word 0 at %-1 |
358 | load c1 from f2-c2 |
365 | load c1 from f2-c2 |
359 | end virtual |
366 | end virtual |
360 | if c1 <> 0 |
367 | if c1 <> 0 |
361 | DEBUGS 0,_debug_str_+f2-c2 |
368 | DEBUGS 0,_debug_str_+f2-c2 |
362 | end if |
369 | end if |
363 | c2 = c2 + 1 |
370 | c2 = c2 + 1 |
364 | f2 = %+1 |
371 | f2 = %+1 |
365 | DEBUGF_HELPER D,a1,c4,_arg |
372 | DEBUGF_HELPER D,a1,c4,_arg |
366 | else if c1 = '\n' |
373 | else if c1 = '\n' |
367 | c3 = c3 + 1 |
374 | c3 = c3 + 1 |
368 | end if |
375 | end if |
369 | end repeat |
376 | end repeat |
370 | virtual at 0 |
377 | virtual at 0 |
371 | db _format,0,0 |
378 | db _format,0,0 |
372 | load c1 from f2-c2 |
379 | load c1 from f2-c2 |
373 | end virtual |
380 | end virtual |
374 | if (c1<>0)&(f2<>..lbl-..f1-1) |
381 | if (c1<>0)&(f2<>..lbl-..f1-1) |
375 | DEBUGS 0,_debug_str_+f2-c2 |
382 | DEBUGS 0,_debug_str_+f2-c2 |
376 | end if |
383 | end if |
377 | virtual at 0 |
384 | virtual at 0 |
378 | ..f1 db _format,0 |
385 | ..f1 db _format,0 |
379 | ..lbl: |
386 | ..lbl: |
380 | __debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
387 | __debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
381 | end virtual |
388 | end virtual |
382 | end if |
389 | end if |
383 | } |
390 | } |
384 | 391 | ||
385 | macro __include_debug_strings dummy,[_id,_fmt,_len] { |
392 | macro __include_debug_strings dummy,[_id,_fmt,_len] { |
386 | common |
393 | common |
387 | local c1,a1,a2 |
394 | local c1,a1,a2 |
388 | forward |
395 | forward |
389 | if defined _len & ~_len eq |
396 | if defined _len & ~_len eq |
390 | _id: |
397 | _id: |
391 | a1 = 0 |
398 | a1 = 0 |
392 | a2 = 0 |
399 | a2 = 0 |
393 | repeat _len |
400 | repeat _len |
394 | virtual at 0 |
401 | virtual at 0 |
395 | db _fmt,0,0 |
402 | db _fmt,0,0 |
396 | load c1 word from %+a2-1 |
403 | load c1 word from %+a2-1 |
397 | end virtual |
404 | end virtual |
398 | if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
405 | if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
399 | db 0 |
406 | db 0 |
400 | a2 = a2 + 1 |
407 | a2 = a2 + 1 |
401 | else if (c1='\n') |
408 | else if (c1='\n') |
402 | dw $0A0D |
409 | dw $0A0D |
403 | a1 = a1 + 1 |
410 | a1 = a1 + 1 |
404 | a2 = a2 + 1 |
411 | a2 = a2 + 1 |
405 | else |
412 | else |
406 | db c1 and 0x0FF |
413 | db c1 and 0x0FF |
407 | end if |
414 | end if |
408 | end repeat |
415 | end repeat |
409 | db 0 |
416 | db 0 |
410 | end if |
417 | end if |
411 | } |
418 | } |
412 | 419 | ||
413 | macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
420 | macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
414 | common |
421 | common |
415 | local num |
422 | local num |
416 | num = 0 |
423 | num = 0 |
417 | forward |
424 | forward |
418 | if num = _num |
425 | if num = _num |
419 | DEBUG#_letter _sign,_arg |
426 | DEBUG#_letter _sign,_arg |
420 | end if |
427 | end if |
421 | num = num+1 |
428 | num = num+1 |
422 | common |
429 | common |
423 | _num = _num+1 |
430 | _num = _num+1 |
424 | } |
431 | } |
425 | 432 | ||
426 | macro include_debug_strings { |
433 | macro include_debug_strings { |
427 | if __DEBUG__ = 1 |
434 | if __DEBUG__ = 1 |
428 | match dbg_str,__debug_strings \{ |
435 | match dbg_str,__debug_strings \{ |
429 | __include_debug_strings dbg_str |
436 | __include_debug_strings dbg_str |
430 | \} |
437 | \} |
431 | end if |
438 | end if |
432 | }>>>>>1,2,3,4,5,6,7,8>1,2,4> |
439 | }>>>>>1,2,3,4,5,6,7,8>1,2,4> |