add exponent reading ..e+.., ..e-..

git-svn-id: svn://kolibrios.org@7615 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2019-03-21 20:08:47 +00:00
parent 6af7c83564
commit 0c01e81393

View File

@ -39,9 +39,10 @@ Data_BCD DT ?
Data_Flag DB ? Data_Flag DB ?
; ‡­ ª १ã«ìâ â  (¥á«¨ ­¥ 0 - ®âà¨æ â¥«ì­®¥ ç¨á«®) ; ‡­ ª १ã«ìâ â  (¥á«¨ ­¥ 0 - ®âà¨æ â¥«ì­®¥ ç¨á«®)
Data_Sign DB ? Data_Sign DB ?
; ‡­ ª १ã«ìâ â  - 0 ¤«ï ..e+.. ¨ 1 ¤«ï ..e-..
Data_Sign_Exp DB ?
align 4
db 0 ;㪠§ â¥«ì ­  ᤢ¨£ ¢ ¯ ¬ïâ¨
; ‘âப  ¤«ï åà ­¥­¨ï ç¨á«  ¢ ª®¤¥ ASCII ; ‘âப  ¤«ï åà ­¥­¨ï ç¨á«  ¢ ª®¤¥ ASCII
Data_String DB 32 DUP (?) Data_String DB 32 DUP (?)
@ -75,8 +76,7 @@ DoubleFloat_to_String:
je .NoShifts ;­¥â æ¨äà ¯®á«¥ § ¯ï⮩ je .NoShifts ;­¥â æ¨äà ¯®á«¥ § ¯ï⮩
jl .Error ;®è¨¡ª  jl .Error ;®è¨¡ª 
dec BX dec BX
shl BX, 3 ;㬭®¦ ¥¬ ­  8 lea ebx,[MConst+8*ebx]
add EBX, MConst
fmul qword [EBX] ;㬭®¦¨âì ­  ª®­áâ ­âã fmul qword [EBX] ;㬭®¦¨âì ­  ª®­áâ ­âã
.NoShifts: .NoShifts:
; ˆ§¢«¥çì ç¨á«® ¢ ª®¤¥ BCD ; ˆ§¢«¥çì ç¨á«® ¢ ª®¤¥ BCD
@ -197,36 +197,37 @@ String_to_DoubleFloat:
mov word [Data_BCD+8],0 mov word [Data_BCD+8],0
; Žç¨é ¥¬ ¡ ©â §­ ª  ; Žç¨é ¥¬ ¡ ©â §­ ª 
mov [Data_Sign],0 mov [Data_Sign],0
; ‡ ­®á¨¬ ¢ SI 㪠§ â¥«ì ­  áâபã ; ‡ ­®á¨¬ ¢ esi 㪠§ â¥«ì ­  áâபã
mov ESI, Data_String mov esi, Data_String
; <EFBFBD>யã᪠¥¬ ¯à®¡¥«ë ¯¥à¥¤ ç¨á«®¬ ; <EFBFBD>யã᪠¥¬ ¯à®¡¥«ë ¯¥à¥¤ ç¨á«®¬
mov ecx,64 ;§ é¨â  ®â § æ¨ª«¨¢ ­¨ï mov ecx,64 ;§ é¨â  ®â § æ¨ª«¨¢ ­¨ï
.ShiftIgnore: .ShiftIgnore:
lodsb lodsb
cmp AL,' ' cmp al,' '
jne .ShiftIgnoreEnd jne .ShiftIgnoreEnd
loop .ShiftIgnore loop .ShiftIgnore
jmp .Error jmp .Error
align 4 align 4
.ShiftIgnoreEnd: .ShiftIgnoreEnd:
; <EFBFBD>஢¥à塞 §­ ª ç¨á«  ; <EFBFBD>஢¥à塞 §­ ª ç¨á« 
cmp AL,'-' cmp al,'-'
jne .Positive jne .Positive
mov [Data_Sign],80h mov [Data_Sign],80h
lodsb lodsb
.Positive: .Positive:
mov [Data_Flag],0 ;¯à¨§­ ª ­ «¨ç¨ï â®çª¨ mov [Data_Flag],0 ;¯à¨§­ ª ­ «¨ç¨ï â®çª¨
mov DX,0 ;¯®§¨æ¨ï â®çª¨ xor edx,edx ;¯®§¨æ¨ï â®çª¨
mov ecx,18 ;¬ ªá. ç¨á«® à §à冷¢ mov ecx,18 ;¬ ªá. ç¨á«® à §à冷¢
align 4
.ASCIItoBCDConversion: .ASCIItoBCDConversion:
cmp AL,'.' ;â®çª ? cmp al,'.' ;â®çª ?
jne .NotDot jne .NotDot
cmp [Data_Flag],0 ;â®çª  ­¥ ¢áâà¥ç « áì? cmp [Data_Flag],0 ;â®çª  ­¥ ¢áâà¥ç « áì?
jne .Error jne .Error ;¥á«¨ â®çª  㦥 ¡ë« 
mov [Data_Flag],1 mov [Data_Flag],1
lodsb lodsb
cmp AL,0 ;ª®­¥æ áâப¨? or al,al ;ª®­¥æ áâப¨?
jne .NotDot jnz .NotDot
jmp .ASCIItoBCDConversionEnd jmp .ASCIItoBCDConversionEnd
align 4 align 4
.NotDot: .NotDot:
@ -234,71 +235,146 @@ align 4
; ¥á«¨ ®­  ¥é¥ ­¥ ¢áâà¥ç « áì ; ¥á«¨ ®­  ¥é¥ ­¥ ¢áâà¥ç « áì
cmp [Data_Flag],0 cmp [Data_Flag],0
jnz .Figures jnz .Figures
inc DX inc edx
.Figures: .Figures:
cmp al,'e'
je .exp_form
cmp al,'E'
jne @f
.exp_form:
call string_ExpForm ;¥á«¨ ç¨á«® ¢ ä®à¬ â¥ ..e..
or al,al
jnz .Error
jmp .ASCIItoBCDConversionEnd
@@:
; ‘¨¬¢®«ë ç¨á«  ¤®«¦­ë ¡ëâì æ¨äà ¬¨ ; ‘¨¬¢®«ë ç¨á«  ¤®«¦­ë ¡ëâì æ¨äà ¬¨
cmp AL,'0' cmp al,'0'
jb .Error jb .Error
cmp AL,'9' cmp al,'9'
ja .Error ja .Error
; <EFBFBD>¨è¥¬ ®ç¥à¥¤­ãî æ¨äàã ¢ ¬« ¤èãî â¥âà ¤ã BCD ; <EFBFBD>¨è¥¬ ®ç¥à¥¤­ãî æ¨äàã ¢ ¬« ¤èãî â¥âà ¤ã BCD
and AL,0Fh and al,15 ;ᨬ¢®«ë 0-9 ¯¥à¥¢®¤¨¬ ¢ ç¨á«®
or byte [Data_BCD],AL or byte [Data_BCD],al
; <EFBFBD>஢¥àª  ­  ª®­¥æ áâப¨ ; <EFBFBD>஢¥àª  ­  ª®­¥æ áâப¨
cmp byte [ESI],0 cmp byte [esi],0
je .ASCIItoBCDConversionEnd je .ASCIItoBCDConversionEnd
; ‘¤¢¨£ ¥¬ BCD ­  4 à §à鸞 ¢«¥¢® ; ‘¤¢¨£ ¥¬ BCD ­  4 à §à鸞 ¢«¥¢®
; (ᤢ¨£ ¥¬ áâ à訥 2 ¡ ©â ) ; (ᤢ¨£ ¥¬ áâ à訥 2 ¡ ©â )
mov AX,word [Data_BCD+6] mov ax,word [Data_BCD+6]
shld word [Data_BCD+8],AX,4 shld word [Data_BCD+8],ax,4
; (ᤢ¨£ ¥¬ á।­¨¥ 4 ¡ ©â ) ; (ᤢ¨£ ¥¬ á।­¨¥ 4 ¡ ©â )
mov EAX, dword [Data_BCD] mov eax,dword [Data_BCD]
shld dword [Data_BCD+4],EAX,4 shld dword [Data_BCD+4],eax,4
; (ᤢ¨£ ¥¬ ¬« ¤è¨¥ 4 ¡ ©â ) ; (ᤢ¨£ ¥¬ ¬« ¤è¨¥ 4 ¡ ©â )
shl dword [Data_BCD],4 shl dword [Data_BCD],4
; ‡ £à㦠¥¬ á«¥¤ãî騩 ᨬ¢®« ¢ AL ; ‡ £à㦠¥¬ á«¥¤ãî騩 ᨬ¢®« ¢ AL
lodsb lodsb
loop .ASCIItoBCDConversion loop .ASCIItoBCDConversion ;¥á«¨ ­¥ ª®¬¯¨«. â® ¯®áâ ¢¨âì dec ecx, jnz ...
; …᫨ 19-© ᨬ¢®« ­¥ 0 ¨ ­¥ â®çª , ; …᫨ 19-© ᨬ¢®« ­¥ 0 ¨ ­¥ â®çª ,
; â® ®è¨¡ª  ¯¥à¥¯®«­¥­¨ï ; â® ®è¨¡ª  ¯¥à¥¯®«­¥­¨ï
cmp AL,'.' cmp al,'.'
jne .NotDot2 jne .NotDot2
inc ecx inc ecx ;¯à®¯ã᪠â®çª¨ ¢ ª®­æ¥ ®ç¥­ì ¡®«ì讣® ç¨á« 
lodsb lodsb
.NotDot2: .NotDot2:
cmp AL,0 or al,al ;¯¥à¥¯®«­¥­¨¥ à §à來®© á¥âª¨?
jne .Error ;¯¥à¥¯®«­¥­¨¥ à §à來®© á¥âª¨ jz .ASCIItoBCDConversionEnd
align 4
.Error: ; <EFBFBD>ਠ«î¡®© ®è¨¡ª¥ ®¡­ã«¨âì १ã«ìâ â
fldz ;§ ­¥á⨠­®«ì á á⥪ ᮯà®æ¥áá®à 
fstp [Data_Double]
jmp .End
; <EFBFBD><EFBFBD>…Ž<EFBFBD><EFBFBD>€‡Žœ —ˆ‘‹Ž ˆ‡ ŠŽ„€ BCD …™…<EFBFBD><EFBFBD>Ž… —ˆ‘‹Ž ; <EFBFBD><EFBFBD>…Ž<EFBFBD><EFBFBD>€‡Žœ —ˆ‘‹Ž ˆ‡ ŠŽ„€ BCD …™…<EFBFBD><EFBFBD>Ž… —ˆ‘‹Ž
.ASCIItoBCDConversionEnd: .ASCIItoBCDConversionEnd:
; ‚¯¨á âì §­ ª ¢ áâ à訩 ¡ ©â ; ‚¯¨á âì §­ ª ¢ áâ à訩 ¡ ©â
mov AL,[Data_Sign] mov al,[Data_Sign]
mov byte [Data_BCD+9],AL mov byte [Data_BCD+9],al
; ‘¡à®á¨âì ॣ¨áâàë ᮯà®æ¥áá®à  ; ‘¡à®á¨âì ॣ¨áâàë ᮯà®æ¥áá®à 
fninit fninit
; ‡ £à㧨âì ¢ ᮯà®æ¥áá®à ç¨á«® ¢ BCD-ä®à¬ â¥ ; ‡ £à㧨âì ¢ ᮯà®æ¥áá®à ç¨á«® ¢ BCD-ä®à¬ â¥
fbld [Data_BCD] fbld [Data_BCD]
; ‚ëç¨á«¨âì ­®¬¥à ¤¥«¨â¥«ï ; ‚ëç¨á«¨âì ­®¬¥à ¤¥«¨â¥«ï ¨«¨ ¬­®¦¨â¥«ï
mov EBX,18+1 lea ebx,[ecx+edx-18]
sub BX,CX cmp ebx,0
sub BX,DX jle .NoMul ;¥á«¨ ç¨á«® e-..
cmp EBX,0 dec ebx
je .NoDiv jz .NoDiv ;¥á«¨ ç¨á«® e+0
dec EBX dec ebx
shl EBX,3 ;㬭®¦ ¥¬ ­  8 lea ebx,[MConst+8*ebx]
add EBX, MConst fmul qword [ebx] ;㬭®¦¨âì ­  ª®­áâ ­âã (¤«ï ç¨á¥« á ¯à¨áâ ¢ª®© e+..)
fdiv qword [EBX] ;à §¤¥«¨âì ­  ª®­áâ ­âã jmp .NoDiv
.NoDiv:; ‚ë£à㧨âì ç¨á«® ¢ ¤¢®¨ç­®¬ ä®à¬ â¥ .NoMul:
fstp [Data_Double] neg ebx
jmp .End lea ebx,[MConst+8*ebx]
align 4 fdiv qword [ebx] ;à §¤¥«¨âì ­  ª®­áâ ­âã
.Error:; <EFBFBD>ਠ«î¡®© ®è¨¡ª¥ ®¡­ã«¨âì १ã«ìâ â .NoDiv: ;‚ë£à㧨âì ç¨á«® ¢ ¤¢®¨ç­®¬ ä®à¬ â¥
fldz ;§ ­¥á⨠­®«ì á á⥪ ᮯà®æ¥áá®à  fstp [Data_Double]
fstp [Data_Double]
.End: .End:
popad popad
ret ret
;output:
; eax - 1 if error
; edx += size
align 4
proc string_ExpForm uses ebx
mov [Data_Sign_Exp],0
xor eax,eax
lodsb
cmp al,'+'
jne @f
lodsb
@@:
cmp al,'-'
jne @f
inc [Data_Sign_Exp]
lodsb
@@:
xor ebx,ebx
.cycle0:
cmp al,0
je .cycle0end
cmp al,9
je .cycle0end
cmp al,10
je .cycle0end
cmp al,13
je .cycle0end
cmp al,' '
je .cycle0end
cmp al,'0'
jb .Error
cmp al,'9'
ja .Error
imul ebx,10
and eax,15 ;ᨬ¢®«ë 0-9 ¯¥à¥¢®¤¨¬ ¢ ç¨á«®
add ebx,eax
lodsb
jmp .cycle0
.cycle0end:
cmp [Data_Sign_Exp],0
je @f
neg ebx
@@:
cmp [Data_Flag],0 ;â®çª  ­¥ ¢áâà¥ç « áì?
jne @f
dec edx
@@:
add edx,ebx
xor eax,eax
jmp @f
.Error:
xor eax,eax
inc eax
@@:
ret
endp
align 4 align 4
proc str_cat uses eax ecx edi esi, str1:dword, str2:dword proc str_cat uses eax ecx edi esi, str1:dword, str2:dword
mov esi,dword[str2] mov esi,dword[str2]