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