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