mtdbg fpu: 1)simplified code

2)two pass bcd to string converter
3)new output format

git-svn-id: svn://kolibrios.org@4912 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-04-30 11:45:59 +00:00
parent 1fc27dcb6e
commit 324a77be90
2 changed files with 97 additions and 149 deletions

View File

@ -723,15 +723,21 @@ draw_register:
draw_fpu_register_2: draw_fpu_register_2:
.str_buf equ esp .str_buf equ esp
.bcd_man equ .str_buf+32 .cvt_buf equ .str_buf+32
.bcd_exp equ .bcd_man+12 .bcd_man equ .cvt_buf+16
.exp equ .bcd_exp+12 .bcd_exp equ .bcd_man+10
.exp equ .bcd_exp+10
.tmp equ .exp+4 .tmp equ .exp+4
.lcl_end equ .tmp+4
sub esp, 32+12+12+4+4 sub esp, 32+16+10+10+4+4
mov eax, 0x20202020
mov edi, .str_buf mov edi, .str_buf
shl ebp, 16
lea eax, ['ST0:'+ebp]
stosd
mov eax, 0x20202020
stosd
stosd stosd
stosd stosd
stosd stosd
@ -740,43 +746,40 @@ draw_fpu_register_2:
;int3 ;int3
;nop ;nop
mov edx, ebp
shl edx, 4
movzx eax, word [_fsw] movzx eax, word [_fsw]
shr eax, 11 shr eax, 11
add eax, ebp add eax, ebp
shr ebp, 12
and eax, 7 and eax, 7
bt dword [_ftw], eax bt dword [_ftw], eax
jc .A6M jc .A6M
mov dword [.str_buf],' emp' mov dword [.str_buf+8],' emp'
mov word [.str_buf+4],'ty' mov word [.str_buf+8+4],'ty'
jmp .display jmp .display
mov cx, [_st0+edx+8] mov cx, [_st0+ebp+8]
and cx, 0x7FFF ;clear sign flag and cx, 0x7FFF ;clear sign flag
jz .A6M jz .A6M
cmp cx, 0x7FFF cmp cx, 0x7FFF
jne .decode jne .decode
mov dword [.str_buf], ' inv' mov dword [.str_buf+6], ' inv'
mov dword [.str_buf+4], 'alid' mov dword [.str_buf+6+4], 'alid'
jmp .display jmp .display
.A6M: .A6M:
mov eax, dword [_st0+edx] mov eax, dword [_st0+ebp]
or eax, dword [_st0+edx+4] or eax, dword [_st0+ebp+4]
jnz .decode jnz .decode
mov dword [.str_buf], ' 0.0' mov dword [.str_buf+10], ' 0.0'
jmp .display jmp .display
.decode: .decode:
fld tword [_st0+edx] fld tword [_st0+ebp]
fabs fabs
fld st0 fld st0
fldlg2 fldlg2
@ -833,114 +836,74 @@ draw_fpu_register_2:
fimul dword [n_digits] fimul dword [n_digits]
fbstp tword [.bcd_man] fbstp tword [.bcd_man]
lea esi, [.bcd_man-1] lea edi, [.cvt_buf]
mov edi, .str_buf mov edx, dword [.bcd_man]
mov ecx, 8
mov ecx, 9
mov eax, 0x10000
mov al, [esi+ecx+1]
cmp al, 0x80 ; check for sign
jne .mantis_2_str
mov al, '-'
stosb
.mantis_2_str:
mov al, [esi+ecx]
test al, al
jnz @f
bt eax, 16
jc .skip_lb
@@: @@:
mov ah, al xor eax, eax
shr al, 4 shld eax, edx, 4
jnz .write_h
bt eax, 16
jc .skip_hb
.write_h:
add al, 0x30
stosb stosb
btr eax, 16 shl edx, 4
jnc .skip_hb loop @B
mov al, '.'
lea esi, [.cvt_buf+7]
lea edi, [.str_buf+13]
mov ecx, 7
mov ah, 0x30
std
.skip_z:
lodsb
test al, al
jnz .body
loop .skip_z
.body:
add al, ah
stosb stosb
lodsb
.skip_hb: jcxz .point
mov al, ah loop .body
and al, 0x0F .point:
jnz .write_lb dec edi
add al, ah
bt eax, 16 mov ah, '.'
jc .skip_lb
.write_lb:
add al,0x30
stosb
btr eax, 16
jnc .skip_lb
mov al, '.'
stosb
.skip_lb:
loop .mantis_2_str
mov eax, [.exp]
test eax, eax
jz .display
mov ax, ' e'
stosw stosw
lea esi, [.bcd_exp-1] bt word [_st0+ebp+8], 15
mov ecx, 9 jnc .m_sign
mov eax,0x10000
mov al, [esi+ecx+1]
cmp al, 0x80
jne .exp_2_str
mov al, '-' mov al, '-'
stosb mov [edi+1], al
.exp_2_str: .m_sign:
mov al, [esi+ecx] cld
mov dx, word [.bcd_exp]
test dx, dx
jz .display
lea edi, [.str_buf+15]
mov ax, 'E '
cmp byte [.bcd_exp+9], 0x80
jne .w_e_sign
mov ax, 'E-'
.w_e_sign:
stosw
mov ecx, 4
.skip_lz:
xor eax, eax
shld ax,dx,4
shl dx, 4
test al, al test al, al
jnz @f jnz .w_exp
loop .skip_lz
bt eax, 16 .w_exp:
jc .skip_lb2
@@:
mov ah, al
shr al, 4
jnz .write_h2
bt eax, 16
jc .skip_hb2
.write_h2:
add al, 0x30 add al, 0x30
stosb stosb
btr eax, 16 xor eax, eax
shld ax, dx, 4
.skip_hb2: shl dx,4
loop .w_exp
mov al, ah
and al, 0x0F
jnz .write_lb2
bt eax, 16
jc .skip_lb2
.write_lb2:
add al, 0x30
stosb
btr eax, 16
.skip_lb2:
loop .exp_2_str
.display: .display:
@ -952,16 +915,16 @@ draw_fpu_register_2:
mov ecx, (COLOR_TXT_NORMAL or 0x40000000) mov ecx, (COLOR_TXT_NORMAL or 0x40000000)
mov eax, dword [_st0+edx] mov eax, dword [_st0+ebp]
cmp eax, dword [_st0+(oldcontext-context)+edx] cmp eax, dword [_st0+(oldcontext-context)+ebp]
jne .scol jne .scol
mov eax, dword [_st0+edx+4] mov eax, dword [_st0+ebp+4]
cmp eax, dword [_st0+(oldcontext-context)+edx+4] cmp eax, dword [_st0+(oldcontext-context)+ebp+4]
jne .scol jne .scol
mov ax, word [_st0+edx+8] mov ax, word [_st0+ebp+8]
cmp ax, word [_st0+(oldcontext-context)+edx+8] cmp ax, word [_st0+(oldcontext-context)+ebp+8]
je .do_label je .do_label
.scol: .scol:
@ -971,18 +934,13 @@ draw_fpu_register_2:
; draw a text string in the window ; draw a text string in the window
mov eax, 4 mov eax, 4
mov esi, eax mov esi, 21
lea edx, [fpu_strs+ebp*4] mov edx, .str_buf
mov edi, COLOR_BG_NORMAL mov edi, COLOR_BG_NORMAL
int 0x40 int 0x40
mov esi, 16 shr ebp, 4
mov edx, .str_buf add esp, 32+16+10+10+4+4
add ebx, 0x180000
int 0x40
sub ebx, 0x180000
add esp, 32+12+12+4+4
ret ret

View File

@ -2304,16 +2304,6 @@ regs_strs:
db 'EIP=' db 'EIP='
db 'EFLAGS=' db 'EFLAGS='
fpu_strs:
db 'ST0='
db 'ST1='
db 'ST2='
db 'ST3='
db 'ST4='
db 'ST5='
db 'ST6='
db 'ST7='
sse_strs: sse_strs:
db '-XMM0-' db '-XMM0-'
db '-XMM1-' db '-XMM1-'
@ -2334,7 +2324,7 @@ avx_strs:
db '-YMM7-' db '-YMM7-'
align 4 align 4
n_digits dd 100000000 n_digits dd 10000000
debuggee_pid dd 0 debuggee_pid dd 0
bSuspended db 0 bSuspended db 0
bAfterGo db 0 bAfterGo db 0