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