1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4 ;; Distributed under terms of the GNU General Public License ;;
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ; Formatted Debug Output (FDO)
10 ; Copyright (c) 2005-2006, mike.dld
11 ; Created: 2005-01-29, Changed: 2006-11-10
13 ; For questions and bug reports, mail to mike.dld@gmail.com
15 ; Available format specifiers are: %s, %d, %u, %x (with partial width support)
20 ; __DEBUG_LEVEL__ equ 5
22 macro debug_func name {
34 macro DEBUGS _sign,[_str] {
38 match _arg:_num,_str \{
39 DEBUGS_N _sign,_num,_arg
42 match =0 _arg,tp _str \{
47 macro DEBUGS_N _sign,_num,[_str] {
51 local ..str,..label,is_str
70 if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
84 match =0 =dword[_arg],tp _num \{
88 match =0 =word[_arg],tp _num \{
92 match =0 =byte[_arg],tp _num \{
97 'Error: specified string width is incorrect'
103 call fdo_debug_outstr
108 macro DEBUGD _sign,_dec {
111 match _arg:_num,_dec \{
112 DEBUGD_N _sign,_num,_arg
115 match =0 _arg,tp _dec \{
120 macro DEBUGD_N _sign,_num,_dec {
124 if (_dec eqtype eax | _dec eqtype 0)
125 'Error: precision allowed only for in-memory variables'
127 if (~_num in <1,2,4>)
129 'Error: 1, 2 and 4 are only allowed for precision in %d'
131 'Error: 1, 2 and 4 are only allowed for precision in %u'
136 if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
145 else if _dec eqtype 0
169 call fdo_debug_outdec
174 macro DEBUGH _sign,_hex {
177 match _arg:_num,_hex \{
178 DEBUGH_N _sign,_num,_arg
181 match =0 _arg,tp _hex \{
186 macro DEBUGH_N _sign,_num,_hex {
189 if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>)
190 'Error: 1..8 are only allowed for precision in %x'
193 if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
198 else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
205 else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
213 else if _hex eqtype 0
227 call fdo_debug_outhex
232 ;-----------------------------------------------------------------------------
234 debug_func fdo_debug_outchar
239 if defined SysMsgBoard._pe_import
248 debug_func fdo_debug_outstr
256 if defined SysMsgBoard._pe_import
266 debug_func fdo_debug_outdec
275 call fdo_debug_outchar
288 call fdo_debug_outchar
293 debug_func fdo_debug_outhex
294 __fdo_hexdigits db '0123456789ABCDEF'
304 mov al,[__fdo_hexdigits+eax]
305 call fdo_debug_outchar
312 ;-----------------------------------------------------------------------------
314 macro DEBUGF _level,_format,[_arg] {
316 if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
317 local ..f1,f2,a1,a2,c1,c2,c3,..lbl
318 _debug_str_ equ __debug_str_ # a1
326 load c1 word from %-1
335 DEBUGS 0,_debug_str_+f2-c2
339 DEBUGF_HELPER S,a1,0,_arg
347 DEBUGS 0,_debug_str_+f2-c2
351 DEBUGF_HELPER H,a1,0,_arg
352 else if c1 = '%d' | c1 = '%u'
365 DEBUGS 0,_debug_str_+f2-c2
369 DEBUGF_HELPER D,a1,c4,_arg
378 if (c1<>0)&(f2<>..lbl-..f1-1)
379 DEBUGS 0,_debug_str_+f2-c2
384 __debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
389 macro __include_debug_strings dummy,[_id,_fmt,_len] {
393 if defined _len & ~_len eq
400 load c1 word from %+a2-1
402 if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
417 macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
423 DEBUG#_letter _sign,_arg
430 macro include_debug_strings {
432 match dbg_str,__debug_strings \{
433 __include_debug_strings dbg_str