Unify fdo.inc and debug-fdo.inc files.

git-svn-id: svn://kolibrios.org@7657 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2019-05-16 00:49:45 +00:00
parent 9f3f8b346e
commit fab3b3a411
2 changed files with 117 additions and 87 deletions

View File

@ -1,13 +1,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$ $Revision$
_esp equ esp
; ;
; Formatted Debug Output (FDO) ; Formatted Debug Output (FDO)
; Copyright (c) 2005-2006, mike.dld ; Copyright (c) 2005-2006, mike.dld
@ -22,6 +20,12 @@ _esp equ esp
; __DEBUG__ equ 1 ; __DEBUG__ equ 1
; __DEBUG_LEVEL__ equ 5 ; __DEBUG_LEVEL__ equ 5
_esp equ esp
macro put_board {
call sys_msg_board
}
macro debug_func name { macro debug_func name {
if used name if used name
name@of@func equ name name@of@func equ name
@ -243,7 +247,7 @@ debug_beginf
pushad pushad
movzx ecx, al movzx ecx, al
mov ebx, 1 mov ebx, 1
call sys_msg_board put_board
popad popad
ret ret
debug_endf debug_endf
@ -257,7 +261,7 @@ debug_beginf
movzx ecx, byte[edx] movzx ecx, byte[edx]
or cl, cl or cl, cl
jz .l2 jz .l2
call sys_msg_board put_board
inc edx inc edx
jmp .l1 jmp .l1
.l2: .l2:
@ -391,6 +395,17 @@ macro DEBUGF _level,_format,[_arg] {
end if end if
} }
macro DEBUGFG _level, _group, _format, [_arg] {
common
if _group eqtype
DEBUGF _level, _format,_arg
else
if _level >= _group
DEBUGF 999, _format,_arg
end if
end if
}
macro __include_debug_strings dummy,[_id,_fmt,_len] { macro __include_debug_strings dummy,[_id,_fmt,_len] {
common common
local c1,a1,a2 local c1,a1,a2

View File

@ -12,6 +12,12 @@
; __DEBUG__ equ 1 ; __DEBUG__ equ 1
; __DEBUG_LEVEL__ equ 5 ; __DEBUG_LEVEL__ equ 5
_esp equ esp
macro put_board {
mcall 63
}
macro debug_func name { macro debug_func name {
if used name if used name
name@of@func equ name name@of@func equ name
@ -52,38 +58,38 @@ macro DEBUGS_N _sign,_num,[_str] {
jmp ..label jmp ..label
..str db _str,0 ..str db _str,0
..label: ..label:
add esp,4*8+4 mov edx, ..str
mov edx,..str
sub esp,4*8+4
else else
mov edx,_str esp equ esp+4*8+4
mov edx, _str
esp equ _esp
end if end if
if ~_num eq if ~_num eq
if _num eqtype eax if _num eqtype eax
if _num in <eax,ebx,ecx,edx,edi,ebp,esp> if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
mov esi,_num mov esi, _num
else if ~_num eq esi else if ~_num eq esi
movzx esi,_num movzx esi, _num
end if end if
else if _num eqtype 0 else if _num eqtype 0
mov esi,_num mov esi, _num
else else
local tp local tp
tp equ 0 tp equ 0
match [_arg],_num \{ match [_arg],_num \{
mov esi,dword[_arg] mov esi, dword[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =dword[_arg],tp _num \{ match =0 =dword[_arg],tp _num \{
mov esi,dword[_arg] mov esi, dword[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =word[_arg],tp _num \{ match =0 =word[_arg],tp _num \{
movzx esi,word[_arg] movzx esi, word[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =byte[_arg],tp _num \{ match =0 =byte[_arg],tp _num \{
movzx esi,byte[_arg] movzx esi, byte[_arg]
tp equ 1 tp equ 1
\} \}
match =0,tp \{ match =0,tp \{
@ -91,7 +97,7 @@ macro DEBUGS_N _sign,_num,[_str] {
\} \}
end if end if
else else
mov esi,0x7FFFFFFF mov esi, 0x7FFFFFFF
end if end if
call fdo_debug_outstr call fdo_debug_outstr
popad popad
@ -127,38 +133,40 @@ macro DEBUGD_N _sign,_num,_dec {
end if end if
if _dec eqtype eax if _dec eqtype eax
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
mov eax,_dec mov eax, _dec
else if ~_dec eq eax else if ~_dec eq eax
if _sign = 1 if _sign = 1
movsx eax,_dec movsx eax, _dec
else else
movzx eax,_dec movzx eax, _dec
end if end if
end if end if
else if _dec eqtype 0 else if _dec eqtype 0
mov eax,_dec mov eax, _dec
else else
add esp,4*8+4 ; add esp,4*8+4
esp equ esp+4*8+4
if _num eq if _num eq
mov eax,dword _dec mov eax, dword _dec
else if _num = 1 else if _num = 1
if _sign = 1 if _sign = 1
movsx eax,byte _dec movsx eax, byte _dec
else else
movzx eax,byte _dec movzx eax, byte _dec
end if end if
else if _num = 2 else if _num = 2
if _sign = 1 if _sign = 1
movsx eax,word _dec movsx eax, word _dec
else else
movzx eax,word _dec movzx eax, word _dec
end if end if
else else
mov eax,dword _dec mov eax, dword _dec
end if end if
sub esp,4*8+4 esp equ _esp
; sub esp,4*8+4
end if end if
mov cl,_sign mov cl, _sign
call fdo_debug_outdec call fdo_debug_outdec
popad popad
popf popf
@ -185,36 +193,39 @@ macro DEBUGH_N _sign,_num,_hex {
if _hex eqtype eax if _hex eqtype eax
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
if ~_hex eq eax if ~_hex eq eax
mov eax,_hex mov eax, _hex
end if end if
mov edx, 8
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
if ~_hex eq ax if ~_hex eq ax
movzx eax,_hex movzx eax, _hex
end if end if
shl eax,16
if (_num eq) if (_num eq)
mov edx,4 mov edx, 4
end if end if
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
if ~_hex eq al if ~_hex eq al
movzx eax,_hex movzx eax, _hex
end if end if
shl eax,24
if (_num eq) if (_num eq)
mov edx,2 mov edx, 2
end if end if
end if end if
else if _hex eqtype 0 else if _hex eqtype 0
mov eax,_hex mov eax, _hex
else else
add esp,4*8+4 ; add esp,4*8+4
mov eax,dword _hex esp equ esp+4*8+4
sub esp,4*8+4 mov eax, dword _hex
esp equ _esp
; sub esp,4*8+4
end if end if
if ~_num eq if ~_num eq
mov edx,_num mov edx, _num
else else
mov edx,8 if ~_hex eqtype eax
mov edx, 8
end if
end if end if
call fdo_debug_outhex call fdo_debug_outhex
popad popad
@ -226,68 +237,72 @@ macro DEBUGH_N _sign,_num,_hex {
debug_func fdo_debug_outchar debug_func fdo_debug_outchar
debug_beginf debug_beginf
pushad pushad
mov cl,al movzx ecx, al
mov ebx,1 mov ebx, 1
mov eax,63 put_board
mcall
popad popad
ret ret
debug_endf debug_endf
debug_func fdo_debug_outstr debug_func fdo_debug_outstr
debug_beginf debug_beginf
mov eax,63 mov ebx, 1
mov ebx,1 .l1:
.l1: dec esi dec esi
js .l2 js .l2
mov cl,[edx] movzx ecx, byte[edx]
or cl,cl or cl, cl
jz .l2 jz .l2
mcall put_board
inc edx inc edx
jmp .l1 jmp .l1
.l2: ret .l2:
ret
debug_endf debug_endf
debug_func fdo_debug_outdec debug_func fdo_debug_outdec
debug_beginf debug_beginf
or cl,cl or cl, cl
jz @f jz @f
or eax,eax or eax, eax
jns @f jns @f
neg eax neg eax
push eax push eax
mov al,'-' mov al, '-'
call fdo_debug_outchar call fdo_debug_outchar
pop eax pop eax
@@: push 10 @@:
pop ecx movi ecx, 10
push -'0' push -'0'
.l1: xor edx,edx .l1:
xor edx, edx
div ecx div ecx
push edx push edx
test eax,eax test eax, eax
jnz .l1 jnz .l1
.l2: pop eax .l2:
add al,'0' pop eax
add al, '0'
jz .l3 jz .l3
call fdo_debug_outchar call fdo_debug_outchar
jmp .l2 jmp .l2
.l3: ret .l3:
ret
debug_endf debug_endf
debug_func fdo_debug_outhex debug_func fdo_debug_outhex
__fdo_hexdigits db '0123456789ABCDEF' __fdo_hexdigits db '0123456789ABCDEF'
debug_beginf debug_beginf
mov cl,dl mov cl, dl
neg cl neg cl
add cl,8 add cl, 8
shl cl,2 shl cl, 2
rol eax,cl rol eax, cl
.l1: rol eax,4 .l1:
rol eax, 4
push eax push eax
and eax,0x0000000F and eax, 0x0000000F
mov al,[__fdo_hexdigits+eax] mov al, [__fdo_hexdigits+eax]
call fdo_debug_outchar call fdo_debug_outchar
pop eax pop eax
dec edx dec edx