utils.obj fix: "0" converted

git-svn-id: svn://kolibrios.org@4887 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Akyltist 2014-04-24 03:27:40 +00:00
parent 113812d57f
commit b4f89a0b48

View File

@ -7,297 +7,297 @@
;-----------------------------------------------------------------------------+ ;-----------------------------------------------------------------------------+
proc FloatToString lpFloat:DWORD, lpResult:DWORD proc FloatToString lpFloat:DWORD, lpResult:DWORD
; ‹®ª «ì­ë¥ ¯¥à¥¬¥­­ë¥ ; ‹®ª «ì­ë¥ ¯¥à¥¬¥­­ë¥
local digits_count:DWORD local digits_count:DWORD
local old_cw:WORD local old_cw:WORD
local new_cw:WORD local new_cw:WORD
local saved_float:TBYTE local saved_float:TBYTE
local tmp1 rb 11h local tmp1 rb 11h
local tmp2 rb 11h local tmp2 rb 11h
; ‘®åà ­¨âì ¢á¥ à¥£¨áâàë ; ‘®åà ­¨âì ¢á¥ à¥£¨áâàë
pusha pusha
; “ª § â¥«ì ­  áâபã-¯à¨¥¬­¨ª ; “ª § â¥«ì ­  áâபã-¯à¨¥¬­¨ª
mov edi,[lpResult] mov edi,[lpResult]
; <EFBFBD>â® ­®«ì? ; <EFBFBD>â® ­®«ì?
lea esi,[lpFloat] mov esi,[lpFloat]
cmp dword [esi],0 cmp dword [esi],0
jne loc_not_zero jne loc_not_zero
cmp dword [esi+4],0 cmp dword [esi+4],0
jne loc_not_zero jne loc_not_zero
cmp word [esi+8],0 cmp word [esi+8],0
jne loc_not_zero jne loc_not_zero
; ‡ ¯¨á âì ¢ áâப㠭®«ì ; ‡ ¯¨á âì ¢ áâப㠭®«ì
mov al,'0' mov al,'0'
stosb stosb
jmp loc_ret jmp loc_ret
loc_not_zero: loc_not_zero:
; ‘ª®¯¨à®¢ âì ç¨á«® ¢ «®ª «ì­ãî ¯¥à¥¬¥­­ãî ; ‘ª®¯¨à®¢ âì ç¨á«® ¢ «®ª «ì­ãî ¯¥à¥¬¥­­ãî
push edi push edi
mov esi,[lpFloat] mov esi,[lpFloat]
lea edi,[saved_float] lea edi,[saved_float]
movsd movsd
movsd movsd
movsw movsw
pop edi pop edi
; —¨á«® ®âà¨æ â¥«ì­®¥? ; —¨á«® ®âà¨æ â¥«ì­®¥?
cmp dword [saved_float+6],0 cmp dword [saved_float+6],0
jge loc_not_signed jge loc_not_signed
; <EFBFBD>ਢ¥á⨠ç¨á«® ª  ¡á®«îâ­®¬ã §­ ç¥­¨î ; <EFBFBD>ਢ¥á⨠ç¨á«® ª  ¡á®«îâ­®¬ã §­ ç¥­¨î
and byte [saved_float+9],7Fh and byte [saved_float+9],7Fh
; ‡ ¯¨á âì ¢ áâப㠬¨­ãá ; ‡ ¯¨á âì ¢ áâப㠬¨­ãá
mov al,'-' mov al,'-'
stosb stosb
loc_not_signed: loc_not_signed:
; <EFBFBD>஢¥à¨âì ç¨á«® ­  ­ «¨ç¨¥ ¤à®¡­®© ç á⨠¨ ; <EFBFBD>஢¥à¨âì ç¨á«® ­  ­ «¨ç¨¥ ¤à®¡­®© ç á⨠¨
; ¯®¤áç¨â âì ª®«¨ç¥á⢮ æ¨äà ¢ ­¥¬ ; ¯®¤áç¨â âì ª®«¨ç¥á⢮ æ¨äà ¢ ­¥¬
fclex fclex
; ‘®åà ­¨âì ã¯à ¢«ïî饥 á«®¢® ; ‘®åà ­¨âì ã¯à ¢«ïî饥 á«®¢®
fstcw [old_cw] fstcw [old_cw]
; “áâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢® ; “áâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢®
mov [new_cw],0000001001111111b mov [new_cw],0000001001111111b
fldcw [new_cw] fldcw [new_cw]
lea esi,[saved_float] lea esi,[saved_float]
fld tbyte [esi] fld tbyte [esi]
fld st fld st
; ‚뤥«¨âì ¬ ­â¨ááã ¨ ¯®à冷ª ; ‚뤥«¨âì ¬ ­â¨ááã ¨ ¯®à冷ª
fxtract fxtract
fstp st fstp st
fldlg2 fldlg2
; <EFBFBD>®«ãç¨âì ª®«¨ç¥á⢮ æ¨äà ¢ ç¨á«¥ ; <EFBFBD>®«ãç¨âì ª®«¨ç¥á⢮ æ¨äà ¢ ç¨á«¥
fmulp st1,st fmulp st1,st
fistp [digits_count] fistp [digits_count]
; …᫨ æ¨äà ¡®«ìè¥ 16, â® ç¨á«® ®â®¡à ¦ ¥âáï ¢ ; …᫨ æ¨äà ¡®«ìè¥ 16, â® ç¨á«® ®â®¡à ¦ ¥âáï ¢
; ­®à¬ «¨§®¢ ­­®¬ ¢¨¤¥ á ¬ ­â¨áᮩ ¨ íªá¯®­¥­â®© ; ­®à¬ «¨§®¢ ­­®¬ ¢¨¤¥ á ¬ ­â¨áᮩ ¨ íªá¯®­¥­â®©
cmp [digits_count],10h cmp [digits_count],10h
jnb loc_not_integer jnb loc_not_integer
; ç¨á«  ¥áâì ¤à®¡­ ï ç áâì? ; ç¨á«  ¥áâì ¤à®¡­ ï ç áâì?
fld st fld st
frndint frndint
fcomp st1 fcomp st1
fstsw ax fstsw ax
test ah,01000000b test ah,01000000b
; „ , ®â®¡à ¦ âì ç¨á«® á ¤à®¡­®© ç áâìî ; „ , ®â®¡à ¦ âì ç¨á«® á ¤à®¡­®© ç áâìî
jz loc_not_integer jz loc_not_integer
; –¥«®¥ ç¨á«® ¡¥§ ¤à®¡­®© ç á⨠¨ íªá¯®­¥­âë ; –¥«®¥ ç¨á«® ¡¥§ ¤à®¡­®© ç á⨠¨ íªá¯®­¥­âë
lea eax,[tmp1] lea eax,[tmp1]
fbstp [eax] fbstp [eax]
; <EFBFBD>¥à¥¢¥á⨠BCD-ç¨á«® ¢ áâபã ; <EFBFBD>¥à¥¢¥á⨠BCD-ç¨á«® ¢ áâபã
push edi push edi
lea esi,[tmp1+8] lea esi,[tmp1+8]
lea edi,[tmp2] lea edi,[tmp2]
mov ecx, 9 mov ecx, 9
@@: @@:
std std
xor eax,eax xor eax,eax
lodsb lodsb
cld cld
rol ax,12 rol ax,12
rol ah,4 rol ah,4
add ax,'00' add ax,'00'
stosw stosw
loop @b loop @b
pop edi pop edi
; <EFBFBD>யãáâ¨âì «¨¤¨àãî騩 ­®«ì ; <EFBFBD>யãáâ¨âì «¨¤¨àãî騩 ­®«ì
mov eax,11h mov eax,11h
mov ecx,[digits_count] mov ecx,[digits_count]
sub eax,ecx sub eax,ecx
inc ecx inc ecx
lea esi,[tmp2+eax] lea esi,[tmp2+eax]
cmp byte [esi],'0' cmp byte [esi],'0'
jne @f jne @f
inc esi inc esi
dec ecx dec ecx
@@: @@:
; <EFBFBD>¥à¥­¥á⨠¯®«ã祭­®¥ ç¨á«® ¨§ ¢à¥¬¥­­®£® ¡ãä¥à  ; <EFBFBD>¥à¥­¥á⨠¯®«ã祭­®¥ ç¨á«® ¨§ ¢à¥¬¥­­®£® ¡ãä¥à 
rep movsb rep movsb
jmp loc_clear_stack jmp loc_clear_stack
loc_not_integer: loc_not_integer:
mov eax,10h mov eax,10h
sub eax,[digits_count] sub eax,[digits_count]
; <EFBFBD>८¡à §®¢ âì ç¨á«® ¢ 楫®¥ ¤® 16 à §à冷¢ ; <EFBFBD>८¡à §®¢ âì ç¨á«® ¢ 楫®¥ ¤® 16 à §à冷¢
mov ecx,eax mov ecx,eax
cmp eax,0 cmp eax,0
jge @f jge @f
neg eax neg eax
@@: @@:
; „«ï ç¨á¥« ¡®«ìè¥ 0 ª®à४â¨à®¢ª  ®ªà㣫¥­¨ï ¢ áâ®à®­ã 0 ; „«ï ç¨á¥« ¡®«ìè¥ 0 ª®à४â¨à®¢ª  ®ªà㣫¥­¨ï ¢ áâ®à®­ã 0
mov [new_cw],0000101001111111b mov [new_cw],0000101001111111b
cmp ecx,0 cmp ecx,0
jge @f jge @f
mov [new_cw],0000011001111111b mov [new_cw],0000011001111111b
@@: @@:
; “áâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢® ; “áâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢®
fldcw [new_cw] fldcw [new_cw]
; ‚®§¢¥á⨠10 ¢ á⥯¥­ì ª®«¨ç¥á⢠ æ¨äà ; ‚®§¢¥á⨠10 ¢ á⥯¥­ì ª®«¨ç¥á⢠ æ¨äà
fld [float2] fld [float2]
fld [float2] fld [float2]
@@: @@:
fmul st,st1 fmul st,st1
dec eax dec eax
cmp eax,1 cmp eax,1
ja @b ja @b
; <EFBFBD>®ç¨áâ¨âì á⥪ ; <EFBFBD>®ç¨áâ¨âì á⥪
fxch st1 fxch st1
fstp st fstp st
; …᫨ ç¨á«® ¬¥­ìè¥ 0, ⮠㬭®¦¨âì, ¨­ ç¥ à §¤¥«¨âì ; …᫨ ç¨á«® ¬¥­ìè¥ 0, ⮠㬭®¦¨âì, ¨­ ç¥ à §¤¥«¨âì
cmp ecx,0 cmp ecx,0
jge @f jge @f
fdivp st1,st fdivp st1,st
jmp loc_rounded jmp loc_rounded
@@: @@:
fmulp st1,st fmulp st1,st
loc_rounded: loc_rounded:
; <EFBFBD>®«ã祭­®¥ §­ ç¥­¨¥ ¬¥­ìè¥ 1.0e16 ? ; <EFBFBD>®«ã祭­®¥ §­ ç¥­¨¥ ¬¥­ìè¥ 1.0e16 ?
fcom [float1] fcom [float1]
fstsw ax fstsw ax
test ah,1 test ah,1
jz @f jz @f
fmul [float2] fmul [float2]
dec [digits_count] dec [digits_count]
@@: @@:
; –¥«®¥ ç¨á«® ¡¥§ ¤à®¡­®© ç á⨠¨ íªá¯®­¥­âë ; –¥«®¥ ç¨á«® ¡¥§ ¤à®¡­®© ç á⨠¨ íªá¯®­¥­âë
lea eax,[tmp1] lea eax,[tmp1]
fbstp [eax] fbstp [eax]
; <EFBFBD>¥à¥¢¥á⨠BCD-ç¨á«® ¢ áâபã ; <EFBFBD>¥à¥¢¥á⨠BCD-ç¨á«® ¢ áâபã
push edi push edi
lea esi,[tmp1+8] lea esi,[tmp1+8]
lea edi,[tmp2] lea edi,[tmp2]
mov ecx, 9 mov ecx, 9
@@: @@:
std std
xor eax,eax xor eax,eax
lodsb lodsb
cld cld
rol ax,12 rol ax,12
rol ah,4 rol ah,4
add ax,'00' add ax,'00'
stosw stosw
loop @b loop @b
pop edi pop edi
; —¨á«ã âॡã¥âáï ¬ ­â¨áá  ¨ íªá¯®­¥­â ? ; —¨á«ã âॡã¥âáï ¬ ­â¨áá  ¨ íªá¯®­¥­â ?
lea esi,[tmp2+1] lea esi,[tmp2+1]
mov ecx,[digits_count] mov ecx,[digits_count]
cmp ecx,-0Fh cmp ecx,-0Fh
jl loc_mantiss_and_exponent jl loc_mantiss_and_exponent
cmp ecx,10h cmp ecx,10h
jg loc_mantiss_and_exponent jg loc_mantiss_and_exponent
; ‡ ¯®«­¨âì ¤à®¡­ãî ç áâì ç¨á«  ; ‡ ¯®«­¨âì ¤à®¡­ãî ç áâì ç¨á« 
inc ecx inc ecx
cmp ecx,0 cmp ecx,0
jg @f jg @f
mov ax,'0.' mov ax,'0.'
stosw stosw
neg ecx neg ecx
mov al,'0' mov al,'0'
rep stosb rep stosb
mov ecx,10h mov ecx,10h
jmp loc_fraction_filled jmp loc_fraction_filled
@@: @@:
rep movsb rep movsb
mov al,'.' mov al,'.'
stosb stosb
mov ecx,10h mov ecx,10h
sub ecx,[digits_count] sub ecx,[digits_count]
loc_fraction_filled: loc_fraction_filled:
rep movsb rep movsb
jmp @f jmp @f
loc_clear_fraction: loc_clear_fraction:
; “¤ «¨âì § ¢¥àè î騥 ­ã«¨ ¤à®¡­®© ç á⨠; “¤ «¨âì § ¢¥àè î騥 ­ã«¨ ¤à®¡­®© ç áâ¨
dec edi dec edi
@@: @@:
cmp byte [edi-1],'0' cmp byte [edi-1],'0'
jz loc_clear_fraction jz loc_clear_fraction
cmp byte [edi-1],'.' cmp byte [edi-1],'.'
jnz @f jnz @f
dec edi dec edi
@@: @@:
jmp loc_clear_stack jmp loc_clear_stack
loc_mantiss_and_exponent: loc_mantiss_and_exponent:
; „஡­ ï ç áâì ¬ ­â¨ááë ; „஡­ ï ç áâì ¬ ­â¨ááë
movsb movsb
mov al,'.' mov al,'.'
stosb stosb
movsd movsd
movsd movsd
movsw movsw
; “¤ «¨âì § ¢¥àè î騥 ­ã«¨ ¤à®¡­®© ç á⨠; “¤ «¨âì § ¢¥àè î騥 ­ã«¨ ¤à®¡­®© ç áâ¨
@@: @@:
cmp byte [edi-1],'0' cmp byte [edi-1],'0'
jne @f jne @f
cmp byte [edi-2],'.' cmp byte [edi-2],'.'
je @f je @f
dec edi dec edi
jmp @b jmp @b
@@: @@:
; ‘¨¬¢®« ¨ §­ ª íªá¯®­¥­âë ; ‘¨¬¢®« ¨ §­ ª íªá¯®­¥­âë
mov al,'e' mov al,'e'
stosb stosb
mov al,'+' mov al,'+'
mov ebx,[digits_count] mov ebx,[digits_count]
cmp ebx, 0 cmp ebx, 0
jge @f jge @f
mov al,'-' mov al,'-'
neg ebx neg ebx
@@: @@:
stosb stosb
; ‡­ ç¥­¨¥ íªá¯®­¥­âë ; ‡­ ç¥­¨¥ íªá¯®­¥­âë
mov eax,ebx mov eax,ebx
mov ecx,10 mov ecx,10
mov ebx,4 mov ebx,4
@@: @@:
dec ebx dec ebx
xor edx,edx xor edx,edx
div ecx div ecx
add dl,'0' add dl,'0'
mov [tmp1+ebx],dl mov [tmp1+ebx],dl
or ebx,ebx or ebx,ebx
jnz @b jnz @b
; <EFBFBD>யãáâ¨âì «¨¤¨àãî騥 ­ã«¨ íªá¯®­¥­âë ; <EFBFBD>யãáâ¨âì «¨¤¨àãî騥 ­ã«¨ íªá¯®­¥­âë
mov ecx,4 mov ecx,4
lea esi,[tmp1] lea esi,[tmp1]
@@: @@:
lodsb lodsb
cmp al,'0' cmp al,'0'
jne @f jne @f
dec ecx dec ecx
jmp @b jmp @b
@@: @@:
dec esi dec esi
rep movsb rep movsb
loc_clear_stack: loc_clear_stack:
; ‚®ááâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢® ; ‚®ááâ ­®¢¨âì ã¯à ¢«ïî饥 á«®¢®
fldcw [old_cw] fldcw [old_cw]
loc_ret: loc_ret:
; Žª®­ç ­¨¥ áâப¨ ; Žª®­ç ­¨¥ áâப¨
mov al,0 mov al,0
stosb stosb
; ‚®ááâ ­®¢¨âì ¢á¥ à¥£¨áâàë ; ‚®ááâ ­®¢¨âì ¢á¥ à¥£¨áâàë
popa popa
ret ret
float1 dq 1.0e16 float1 dq 1.0e16
float2 dq 10.0 float2 dq 10.0