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