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