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