From 015ceec3e17fabd0be8d71eae91dafbf45d425f0 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 1 Nov 2014 17:57:50 +0100 Subject: [PATCH] [Reduction] #569: xcvt ... and even with EMUL being set up and working, TASM still needs to be hacked into actually emitting emulator calls for certain instructions. --- ReC98.inc | 1 + libs/BorlandC/_printf.inc | 11 + libs/BorlandC/emu/nec_fpinit.asm | 1 - libs/BorlandC/math/xcvt.asm | 300 +++++++++++++++++++++++ th01_fuuin.asm | 394 +------------------------------ th01_op.asm | 394 +------------------------------ th01_reiiden.asm | 394 +------------------------------ 7 files changed, 318 insertions(+), 1177 deletions(-) create mode 100644 libs/BorlandC/_printf.inc create mode 100644 libs/BorlandC/math/xcvt.asm diff --git a/ReC98.inc b/ReC98.inc index 3e96e8c8..803ec037 100644 --- a/ReC98.inc +++ b/ReC98.inc @@ -9,6 +9,7 @@ include libs/BorlandC/dos.inc include libs/BorlandC/doserror.inc include libs/BorlandC/fcntl.inc include libs/BorlandC/stdio.inc +include libs/BorlandC/_printf.inc include libs/BorlandC/sys/stat.inc include libs/master.lib/func.inc include libs/master.lib/super.inc diff --git a/libs/BorlandC/_printf.inc b/libs/BorlandC/_printf.inc new file mode 100644 index 00000000..a8fe4e79 --- /dev/null +++ b/libs/BorlandC/_printf.inc @@ -0,0 +1,11 @@ +FLOATS_32_BIT = 1 +F_4byteFloat = 2 +F_8byteFloat = 6 +F_10byteFloat = 8 +MaxSigDigits = 18 +__LTOAMAX__ = 32 +__XCVTDIG__ = 40 +__XCVTMAX__ = 47 +__CVTMAX__ = 48 +NAN_number = 32766 +INF_number = 32767 diff --git a/libs/BorlandC/emu/nec_fpinit.asm b/libs/BorlandC/emu/nec_fpinit.asm index 921c05b0..159ba5ea 100644 --- a/libs/BorlandC/emu/nec_fpinit.asm +++ b/libs/BorlandC/emu/nec_fpinit.asm @@ -469,4 +469,3 @@ __fpuint proc far mov ax, cs:fpinit_100B5 ret __fpuint endp - noemul diff --git a/libs/BorlandC/math/xcvt.asm b/libs/BorlandC/math/xcvt.asm new file mode 100644 index 00000000..0db8d158 --- /dev/null +++ b/libs/BorlandC/math/xcvt.asm @@ -0,0 +1,300 @@ +; int __pascal __near __XCVT(void *valP, int digits, int *signP, char *strP, int ftype) +___XCVT proc near +@@frac = tbyte ptr -10h +@@SW = word ptr -6 +@@ten = word ptr -4 +@@Sign = word ptr -2 +@@ftype = word ptr 4 +@@strP = DPTR_ (6) +@@signP = DPTR_ (6 + dPtrSize) +@@digits = word ptr (6 + dPtrSize + dPtrSize) +@@valP = DPTR_ (6 + dPtrSize + dPtrSize + 2) + + push bp + mov bp, sp + sub sp, 10h + push si + push di + mov [bp+@@Sign], 8000h + mov [bp+@@ten], 10 + push es + LES_ di, [bp+@@valP] + mov ax, 7FFFh + mov bx, [bp+@@ftype] + mov cx, es:[bx+di] + and [bp+@@Sign], cx + and es:[bx+di], ax + shr bx, 1 + shr bx, 1 + shl bx, 1 + jmp word ptr cs:@@type_table[bx] + +@@type_table: + dw offset @@F4bytes + dw offset @@F8bytes + dw offset @@F10bytes + +@@F4bytes: + fld dword ptr es:[di] + jmp short @@its_loaded + +@@F8bytes: + fld qword ptr es:[di] + jmp short @@its_loaded + +@@F10bytes: + and ax, es:[di+8] + cmp ax, 7FFFh + jz short @@F10bytesHacked + and byte ptr es:[di], 0F0h + +@@F10bytesHacked: + fld tbyte ptr es:[di] + +@@its_loaded: + xor bx, bx + shl cx, 1 + rcl bx, 1 + les di, [bp+@@signP] + mov es:[di], bx + fxam + fstsw [bp+@@SW] + db 0CDh, 03Dh ; Hack ('wait' is apparently not emulated?) + mov ax, [bp+@@SW] + and ah, 47h + cmp ah, 40h + jz short @@zero + cmp ah, 5 + jz short @@its_infinity + cmp ah, 1 + jz short @@its_NAN + jmp short @@normal + +@@its_NAN: + mov dx, NAN_number + jmp short @@pop_and_go + +@@its_infinity: + mov dx, INF_number + jmp short @@pop_and_go + +@@zero: + mov dx, 1 + mov al, '0' + LES_ di, [bp+@@signP] + mov word ptr ES_[di], 0 + mov cx, [bp+@@digits] + or cx, cx + jg short @@extSized + neg cx + inc cx + +@@extSized: + cmp cx, __XCVTDIG__ + jbe short @@extLimited + mov cx, __XCVTDIG__ + +@@extLimited: + cld + les di, [bp+@@strP] + rep stosb + xor al, al + stosb + +@@pop_and_go: + fstp st + jmp @@end + +@@normal: + fld st + fstp [bp+@@frac] + db 0CDh, 03Dh ; Hack ('wait' is apparently not emulated?) + mov ax, word ptr [bp+@@frac+8] + sub ax, 3FFFh + mov dx, 4D10h + imul dx + xchg ax, bx + mov ah, 4Dh + mov al, byte ptr [bp+@@frac+7] + shl al, 1 + mul ah + add ax, bx + adc dx, 0 + neg ax + adc dx, 0 + mov ax, [bp+@@digits] + or ax, ax + jg short @@digitPlaces + neg ax + add ax, dx + jl short @@zero + +@@digitPlaces: + cmp ax, MaxSigDigits + jle short @@defaultPlaces + mov ax, MaxSigDigits + +@@defaultPlaces: + mov bx, ax + sub ax, dx + +@@powloop: + jz short @@adjusted + mov si, ax + jge short @@power10 + neg ax + +@@power10: + cmp ax, 4932 + jle short @@getpow + mov ax, 4932 + +@@getpow: + push ax + nopcall _pow10 + pop ax + or si, si + jg short @@increase + fdivp st(1), st + add ax, si + jmp short @@powloop + +@@increase: + fmulp st(1), st + xchg ax, si + sub ax, si + jmp short @@powloop + +@@adjusted: + push bx + nopcall _pow10 + pop ax + fcomp st(1) + fstsw [bp+@@SW] + db 0CDh, 03Dh ; Hack ('wait' is apparently not emulated?) + test byte ptr [bp+@@SW+1], 45h + jz short @@notTooHigh + inc dx + inc bx + cmp bx, MaxSigDigits + ja short @@mustShorten + cmp [bp+@@digits], 0 + jle short @@notTooLow + +@@mustShorten: + fidiv [bp+@@ten] + dec bx + jmp short @@notTooLow + +@@notTooHigh: + mov ax, bx + dec ax + push ax + nopcall _pow10 + pop ax + fcomp st(1) + fstsw [bp+@@SW] + db 0CDh, 03Dh ; Hack ('wait' is apparently not emulated?) + test byte ptr [bp+@@SW+1], 41h + jnz short @@notTooLow + dec dx + dec bx + cmp [bp+@@digits], 0 + jle short @@notTooLow + fimul [bp+@@ten] + inc bx + +@@notTooLow: + or bx, bx + jl short @@jmp_roundToZero + frndint + fbstp [bp+@@frac] + les di, [bp+@@strP] + add di, bx + push di + xor al, al + std + stosb + lea si, [bp+@@frac] + mov cx, 4 + db 0CDh, 03Dh ; Hack ('wait' is apparently not emulated?) + or bx, bx + jnz short @@nextPair + mov ch, SS_[si] + xor ch, 1 + jz short @@maybeRoundup + +@@jmp_roundToZero: + fldz + pop di + jmp @@zero + +@@nextPair: + mov al, SS_[si] + inc si + mov ah, al + shr ah, cl + and al, 0Fh + add ax, '00' + stosb + or ch, al + dec bx + jz short @@maybeRoundup + mov al, ah + stosb + or ch, al + dec bx + jnz short @@nextPair + +@@maybeRoundup: + pop bx + and ch, 0Fh + jnz short @@append + inc dx + cmp [bp+@@digits], 0 + jg short @@put1 + mov BY0 (ES_[bx]), '0' + +@@put1: + inc bx + mov BY0 (ES_[di+1]), '1' + +@@append: + mov cx, [bp+@@digits] + or cx, cx + jg short @@zMax + neg cx + add cx, dx + +@@zMax: + cmp cx, __XCVTDIG__ + jbe short @@zLimited + mov cx, __XCVTDIG__ + +@@zLimited: + mov BY0 (ES_[bx]), 0 + mov ax, bx + sub ax, word ptr [bp+@@strP] + sub cx, ax + jbe short @@end + +@@appendZloop: + mov W0 (ES_[bx]), '0' + inc bx + loop @@appendZloop + +@@end: + cld + LES_ di, [bp+@@valP] + mov bx, [bp+@@ftype] + mov cx, [bp+@@Sign] + or es:[bx+di], cx + pop es + mov ax, dx + pop di + pop si + mov sp, bp + pop bp + ret 10h +___XCVT endp + noemul diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 14337560..59b16c8a 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -1909,7 +1909,7 @@ loc_166A: push si mov ax, [bp+arg_0] push ax - call sub_17CC + call ___xcvt xchg ax, bx les di, [bp+arg_6] cld @@ -2127,397 +2127,7 @@ sub_161E endp pop bp retn -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -sub_17CC proc near - -var_10 = tbyte ptr -10h -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 4 -arg_2 = dword ptr 6 -arg_6 = dword ptr 0Ah -arg_A = word ptr 0Eh -arg_C = dword ptr 10h - - push bp - mov bp, sp - sub sp, 10h - push si - push di - mov [bp+var_2], 8000h - mov [bp+var_4], 0Ah - push es - les di, [bp+arg_C] - mov ax, 7FFFh - mov bx, [bp+arg_0] - mov cx, es:[bx+di] - and [bp+var_2], cx - and es:[bx+di], ax - shr bx, 1 - shr bx, 1 - shl bx, 1 - jmp cs:off_17FC[bx] -; --------------------------------------------------------------------------- -off_17FC dw offset loc_1802 - dw offset loc_1808 - dw offset loc_180E -; --------------------------------------------------------------------------- - -loc_1802: - ; Hack (fld dword ptr es:[di]) - db 0cdh - db 03ch - db 0d9h - db 005h - jmp short loc_181F -; --------------------------------------------------------------------------- - -loc_1808: - ; Hack (fld qword ptr es:[di]) - db 0cdh - db 03ch - db 0ddh - db 005h - jmp short loc_181F -; --------------------------------------------------------------------------- - -loc_180E: - and ax, es:[di+8] - cmp ax, 7FFFh - jz short loc_181B - and byte ptr es:[di], 0F0h - -loc_181B: - ; Hack (fld tbyte ptr es:[di]) - db 0cdh - db 03ch - db 0dbh - db 02dh - -loc_181F: - xor bx, bx - shl cx, 1 - rcl bx, 1 - les di, [bp+arg_6] - mov es:[di], bx - ; Hack (fxam) - db 0cdh - db 035h - db 0e5h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - mov ax, [bp+var_6] - and ah, 47h - cmp ah, 40h - jz short loc_1855 - cmp ah, 5 - jz short loc_1850 - cmp ah, 1 - jz short loc_184B - jmp short loc_1883 -; --------------------------------------------------------------------------- - -loc_184B: - mov dx, 7FFEh - jmp short loc_187D -; --------------------------------------------------------------------------- - -loc_1850: - mov dx, 7FFFh - jmp short loc_187D -; --------------------------------------------------------------------------- - -loc_1855: - mov dx, 1 - mov al, 30h ; '0' - les di, [bp+arg_6] - mov word ptr es:[di], 0 - mov cx, [bp+arg_A] - or cx, cx - jg short loc_186C - neg cx - inc cx - -loc_186C: - cmp cx, 28h ; '(' - jbe short loc_1874 - mov cx, 28h ; '(' - -loc_1874: - cld - les di, [bp+arg_2] - rep stosb - xor al, al - stosb - -loc_187D: - ; Hack (fstp st) - db 0cdh - db 039h - db 0d8h - jmp loc_19C8 -; --------------------------------------------------------------------------- - -loc_1883: - ; Hack (fstp st) - db 0cdh - db 035h - db 0c0h - ; Hack (fstp [bp+var_10]) - db 0cdh - db 037h - db 07eh - db 0f0h - ; Hack (wait) - db 0cdh - db 03dh - mov ax, word ptr [bp+var_10+8] - sub ax, 3FFFh - mov dx, 4D10h - imul dx - xchg ax, bx - mov ah, 4Dh ; 'M' - mov al, byte ptr [bp+var_10+7] - shl al, 1 - mul ah - add ax, bx - adc dx, 0 - neg ax - adc dx, 0 - mov ax, [bp+arg_A] - or ax, ax - jg short loc_18B8 - neg ax - add ax, dx - jl short loc_1855 - -loc_18B8: - cmp ax, 12h - jle short loc_18C0 - mov ax, 12h - -loc_18C0: - mov bx, ax - sub ax, dx - -loc_18C4: - jz short loc_18EE - mov si, ax - jge short loc_18CC - neg ax - -loc_18CC: - cmp ax, 1344h - jle short loc_18D4 - mov ax, 1344h - -loc_18D4: - push ax ; p - nopcall _pow10 - pop ax - or si, si - jg short loc_18E6 - ; Hack (fdivp st(1), st) - db 0cdh - db 03ah - db 0f9h - add ax, si - jmp short loc_18C4 -; --------------------------------------------------------------------------- - -loc_18E6: - ; Hack (fmulp st(1), st) - db 0cdh - db 03ah - db 0c9h - xchg ax, si - sub ax, si - jmp short loc_18C4 -; --------------------------------------------------------------------------- - -loc_18EE: - push bx ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 45h - jz short loc_1918 - inc dx - inc bx - cmp bx, 12h - ja short loc_1911 - cmp [bp+arg_A], 0 - jle short loc_193E - -loc_1911: - ; Hack (fidiv [bp+var_4]) - db 0cdh - db 03ah - db 076h - db 0fch - dec bx - jmp short loc_193E -; --------------------------------------------------------------------------- - -loc_1918: - mov ax, bx - dec ax - push ax ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 41h - jnz short loc_193E - dec dx - dec bx - cmp [bp+arg_A], 0 - jle short loc_193E - ; Hack (fimul [bp+var_4]) - db 0cdh - db 03ah - db 04eh - db 0fch - inc bx - -loc_193E: - or bx, bx - jl short loc_1967 - ; Hack (frndint) - db 0cdh - db 035h - db 0fch - ; Hack (fbstp [bp+var_10]) - db 0cdh - db 03bh - db 076h - db 0f0h - les di, [bp+arg_2] - add di, bx - push di - xor al, al - std - stosb - lea si, [bp+var_10] - mov cx, 4 - ; Hack (wait) - db 0cdh - db 03dh - or bx, bx - jnz short loc_196E - mov ch, ss:[si] - xor ch, 1 - jz short loc_1989 - -loc_1967: - ; Hack (fldz) - db 0cdh - db 035h - db 0eeh - pop di - jmp loc_1855 -; --------------------------------------------------------------------------- - -loc_196E: - mov al, ss:[si] - inc si - mov ah, al - shr ah, cl - and al, 0Fh - add ax, 3030h - stosb - or ch, al - dec bx - jz short loc_1989 - mov al, ah - stosb - or ch, al - dec bx - jnz short loc_196E - -loc_1989: - pop bx - and ch, 0Fh - jnz short loc_19A0 - inc dx - cmp [bp+arg_A], 0 - jg short loc_199A - mov byte ptr es:[bx], 30h ; '0' - -loc_199A: - inc bx - mov byte ptr es:[di+1], 31h ; '1' - -loc_19A0: - mov cx, [bp+arg_A] - or cx, cx - jg short loc_19AB - neg cx - add cx, dx - -loc_19AB: - cmp cx, 28h ; '(' - jbe short loc_19B3 - mov cx, 28h ; '(' - -loc_19B3: - mov byte ptr es:[bx], 0 - mov ax, bx - sub ax, word ptr [bp+arg_2] - sub cx, ax - jbe short loc_19C8 - -loc_19C0: - mov word ptr es:[bx], 30h ; '0' - inc bx - loop loc_19C0 - -loc_19C8: - cld - les di, [bp+arg_C] - mov bx, [bp+arg_0] - mov cx, [bp+var_2] - or es:[bx+di], cx - pop es - mov ax, dx - pop di - pop si - mov sp, bp - pop bp - retn 10h -sub_17CC endp ; sp-analysis failed - +include libs/BorlandC/math/xcvt.asm include libs/BorlandC/fperr.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_op.asm b/th01_op.asm index 8c475cbb..899ea90d 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -1822,7 +1822,7 @@ loc_172A: push si mov ax, [bp+arg_0] push ax - call sub_188C + call ___xcvt xchg ax, bx les di, [bp+arg_6] cld @@ -2040,397 +2040,7 @@ sub_16DE endp pop bp retn -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -sub_188C proc near - -var_10 = tbyte ptr -10h -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 4 -arg_2 = dword ptr 6 -arg_6 = dword ptr 0Ah -arg_A = word ptr 0Eh -arg_C = dword ptr 10h - - push bp - mov bp, sp - sub sp, 10h - push si - push di - mov [bp+var_2], 8000h - mov [bp+var_4], 0Ah - push es - les di, [bp+arg_C] - mov ax, 7FFFh - mov bx, [bp+arg_0] - mov cx, es:[bx+di] - and [bp+var_2], cx - and es:[bx+di], ax - shr bx, 1 - shr bx, 1 - shl bx, 1 - jmp cs:off_18BC[bx] -; --------------------------------------------------------------------------- -off_18BC dw offset loc_18C2 - dw offset loc_18C8 - dw offset loc_18CE -; --------------------------------------------------------------------------- - -loc_18C2: - ; Hack (fld dword ptr es:[di]) - db 0cdh - db 03ch - db 0d9h - db 005h - jmp short loc_18DF -; --------------------------------------------------------------------------- - -loc_18C8: - ; Hack (fld qword ptr es:[di]) - db 0cdh - db 03ch - db 0ddh - db 005h - jmp short loc_18DF -; --------------------------------------------------------------------------- - -loc_18CE: - and ax, es:[di+8] - cmp ax, 7FFFh - jz short loc_18DB - and byte ptr es:[di], 0F0h - -loc_18DB: - ; Hack (fld tbyte ptr es:[di]) - db 0cdh - db 03ch - db 0dbh - db 02dh - -loc_18DF: - xor bx, bx - shl cx, 1 - rcl bx, 1 - les di, [bp+arg_6] - mov es:[di], bx - ; Hack (fxam) - db 0cdh - db 035h - db 0e5h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - mov ax, [bp+var_6] - and ah, 47h - cmp ah, 40h - jz short loc_1915 - cmp ah, 5 - jz short loc_1910 - cmp ah, 1 - jz short loc_190B - jmp short loc_1943 -; --------------------------------------------------------------------------- - -loc_190B: - mov dx, 7FFEh - jmp short loc_193D -; --------------------------------------------------------------------------- - -loc_1910: - mov dx, 7FFFh - jmp short loc_193D -; --------------------------------------------------------------------------- - -loc_1915: - mov dx, 1 - mov al, 30h ; '0' - les di, [bp+arg_6] - mov word ptr es:[di], 0 - mov cx, [bp+arg_A] - or cx, cx - jg short loc_192C - neg cx - inc cx - -loc_192C: - cmp cx, 28h ; '(' - jbe short loc_1934 - mov cx, 28h ; '(' - -loc_1934: - cld - les di, [bp+arg_2] - rep stosb - xor al, al - stosb - -loc_193D: - ; Hack (fstp st) - db 0cdh - db 039h - db 0d8h - jmp loc_1A88 -; --------------------------------------------------------------------------- - -loc_1943: - ; Hack (fstp st) - db 0cdh - db 035h - db 0c0h - ; Hack (fstp [bp+var_10]) - db 0cdh - db 037h - db 07eh - db 0f0h - ; Hack (wait) - db 0cdh - db 03dh - mov ax, word ptr [bp+var_10+8] - sub ax, 3FFFh - mov dx, 4D10h - imul dx - xchg ax, bx - mov ah, 4Dh ; 'M' - mov al, byte ptr [bp+var_10+7] - shl al, 1 - mul ah - add ax, bx - adc dx, 0 - neg ax - adc dx, 0 - mov ax, [bp+arg_A] - or ax, ax - jg short loc_1978 - neg ax - add ax, dx - jl short loc_1915 - -loc_1978: - cmp ax, 12h - jle short loc_1980 - mov ax, 12h - -loc_1980: - mov bx, ax - sub ax, dx - -loc_1984: - jz short loc_19AE - mov si, ax - jge short loc_198C - neg ax - -loc_198C: - cmp ax, 1344h - jle short loc_1994 - mov ax, 1344h - -loc_1994: - push ax ; p - nopcall _pow10 - pop ax - or si, si - jg short loc_19A6 - ; Hack (fdivp st(1), st) - db 0cdh - db 03ah - db 0f9h - add ax, si - jmp short loc_1984 -; --------------------------------------------------------------------------- - -loc_19A6: - ; Hack (fmulp st(1), st) - db 0cdh - db 03ah - db 0c9h - xchg ax, si - sub ax, si - jmp short loc_1984 -; --------------------------------------------------------------------------- - -loc_19AE: - push bx ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 45h - jz short loc_19D8 - inc dx - inc bx - cmp bx, 12h - ja short loc_19D1 - cmp [bp+arg_A], 0 - jle short loc_19FE - -loc_19D1: - ; Hack (fidiv [bp+var_4]) - db 0cdh - db 03ah - db 076h - db 0fch - dec bx - jmp short loc_19FE -; --------------------------------------------------------------------------- - -loc_19D8: - mov ax, bx - dec ax - push ax ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 41h - jnz short loc_19FE - dec dx - dec bx - cmp [bp+arg_A], 0 - jle short loc_19FE - ; Hack (fimul [bp+var_4]) - db 0cdh - db 03ah - db 04eh - db 0fch - inc bx - -loc_19FE: - or bx, bx - jl short loc_1A27 - ; Hack (frndint) - db 0cdh - db 035h - db 0fch - ; Hack (fbstp [bp+var_10]) - db 0cdh - db 03bh - db 076h - db 0f0h - les di, [bp+arg_2] - add di, bx - push di - xor al, al - std - stosb - lea si, [bp+var_10] - mov cx, 4 - ; Hack (wait) - db 0cdh - db 03dh - or bx, bx - jnz short loc_1A2E - mov ch, ss:[si] - xor ch, 1 - jz short loc_1A49 - -loc_1A27: - ; Hack (fldz) - db 0cdh - db 035h - db 0eeh - pop di - jmp loc_1915 -; --------------------------------------------------------------------------- - -loc_1A2E: - mov al, ss:[si] - inc si - mov ah, al - shr ah, cl - and al, 0Fh - add ax, 3030h - stosb - or ch, al - dec bx - jz short loc_1A49 - mov al, ah - stosb - or ch, al - dec bx - jnz short loc_1A2E - -loc_1A49: - pop bx - and ch, 0Fh - jnz short loc_1A60 - inc dx - cmp [bp+arg_A], 0 - jg short loc_1A5A - mov byte ptr es:[bx], 30h ; '0' - -loc_1A5A: - inc bx - mov byte ptr es:[di+1], 31h ; '1' - -loc_1A60: - mov cx, [bp+arg_A] - or cx, cx - jg short loc_1A6B - neg cx - add cx, dx - -loc_1A6B: - cmp cx, 28h ; '(' - jbe short loc_1A73 - mov cx, 28h ; '(' - -loc_1A73: - mov byte ptr es:[bx], 0 - mov ax, bx - sub ax, word ptr [bp+arg_2] - sub cx, ax - jbe short loc_1A88 - -loc_1A80: - mov word ptr es:[bx], 30h ; '0' - inc bx - loop loc_1A80 - -loc_1A88: - cld - les di, [bp+arg_C] - mov bx, [bp+arg_0] - mov cx, [bp+var_2] - or es:[bx+di], cx - pop es - mov ax, dx - pop di - pop si - mov sp, bp - pop bp - retn 10h -sub_188C endp ; sp-analysis failed - +include libs/BorlandC/math/xcvt.asm include libs/BorlandC/fperr.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_reiiden.asm b/th01_reiiden.asm index f79e78b0..3b76309a 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -2209,7 +2209,7 @@ loc_1B04: push si mov ax, [bp+arg_0] push ax - call sub_2006 + call ___xcvt xchg ax, bx les di, [bp+arg_6] cld @@ -3106,397 +3106,7 @@ sub_1F84 endp pop bp retf -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_2006 proc near - -var_10 = tbyte ptr -10h -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 4 -arg_2 = dword ptr 6 -arg_6 = dword ptr 0Ah -arg_A = word ptr 0Eh -arg_C = dword ptr 10h - - push bp - mov bp, sp - sub sp, 10h - push si - push di - mov [bp+var_2], 8000h - mov [bp+var_4], 0Ah - push es - les di, [bp+arg_C] - mov ax, 7FFFh - mov bx, [bp+arg_0] - mov cx, es:[bx+di] - and [bp+var_2], cx - and es:[bx+di], ax - shr bx, 1 - shr bx, 1 - shl bx, 1 - jmp cs:off_2036[bx] -; --------------------------------------------------------------------------- -off_2036 dw offset loc_203C - dw offset loc_2042 - dw offset loc_2048 -; --------------------------------------------------------------------------- - -loc_203C: - ; Hack (fld dword ptr es:[di]) - db 0cdh - db 03ch - db 0d9h - db 005h - jmp short loc_2059 -; --------------------------------------------------------------------------- - -loc_2042: - ; Hack (fld qword ptr es:[di]) - db 0cdh - db 03ch - db 0ddh - db 005h - jmp short loc_2059 -; --------------------------------------------------------------------------- - -loc_2048: - and ax, es:[di+8] - cmp ax, 7FFFh - jz short loc_2055 - and byte ptr es:[di], 0F0h - -loc_2055: - ; Hack (fld tbyte ptr es:[di]) - db 0cdh - db 03ch - db 0dbh - db 02dh - -loc_2059: - xor bx, bx - shl cx, 1 - rcl bx, 1 - les di, [bp+arg_6] - mov es:[di], bx - ; Hack (fxam) - db 0cdh - db 035h - db 0e5h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - mov ax, [bp+var_6] - and ah, 47h - cmp ah, 40h - jz short loc_208F - cmp ah, 5 - jz short loc_208A - cmp ah, 1 - jz short loc_2085 - jmp short loc_20BD -; --------------------------------------------------------------------------- - -loc_2085: - mov dx, 7FFEh - jmp short loc_20B7 -; --------------------------------------------------------------------------- - -loc_208A: - mov dx, 7FFFh - jmp short loc_20B7 -; --------------------------------------------------------------------------- - -loc_208F: - mov dx, 1 - mov al, 30h ; '0' - les di, [bp+arg_6] - mov word ptr es:[di], 0 - mov cx, [bp+arg_A] - or cx, cx - jg short loc_20A6 - neg cx - inc cx - -loc_20A6: - cmp cx, 28h ; '(' - jbe short loc_20AE - mov cx, 28h ; '(' - -loc_20AE: - cld - les di, [bp+arg_2] - rep stosb - xor al, al - stosb - -loc_20B7: - ; Hack (fstp st) - db 0cdh - db 039h - db 0d8h - jmp loc_2202 -; --------------------------------------------------------------------------- - -loc_20BD: - ; Hack (fstp st) - db 0cdh - db 035h - db 0c0h - ; Hack (fstp [bp+var_10]) - db 0cdh - db 037h - db 07eh - db 0f0h - ; Hack (wait) - db 0cdh - db 03dh - mov ax, word ptr [bp+var_10+8] - sub ax, 3FFFh - mov dx, 4D10h - imul dx - xchg ax, bx - mov ah, 4Dh ; 'M' - mov al, byte ptr [bp+var_10+7] - shl al, 1 - mul ah - add ax, bx - adc dx, 0 - neg ax - adc dx, 0 - mov ax, [bp+arg_A] - or ax, ax - jg short loc_20F2 - neg ax - add ax, dx - jl short loc_208F - -loc_20F2: - cmp ax, 12h - jle short loc_20FA - mov ax, 12h - -loc_20FA: - mov bx, ax - sub ax, dx - -loc_20FE: - jz short loc_2128 - mov si, ax - jge short loc_2106 - neg ax - -loc_2106: - cmp ax, 1344h - jle short loc_210E - mov ax, 1344h - -loc_210E: - push ax ; p - nopcall _pow10 - pop ax - or si, si - jg short loc_2120 - ; Hack (fdivp st(1), st) - db 0cdh - db 03ah - db 0f9h - add ax, si - jmp short loc_20FE -; --------------------------------------------------------------------------- - -loc_2120: - ; Hack (fmulp st(1), st) - db 0cdh - db 03ah - db 0c9h - xchg ax, si - sub ax, si - jmp short loc_20FE -; --------------------------------------------------------------------------- - -loc_2128: - push bx ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 45h - jz short loc_2152 - inc dx - inc bx - cmp bx, 12h - ja short loc_214B - cmp [bp+arg_A], 0 - jle short loc_2178 - -loc_214B: - ; Hack (fidiv [bp+var_4]) - db 0cdh - db 03ah - db 076h - db 0fch - dec bx - jmp short loc_2178 -; --------------------------------------------------------------------------- - -loc_2152: - mov ax, bx - dec ax - push ax ; p - nopcall _pow10 - pop ax - ; Hack (fcomp st(1)) - db 0cdh - db 034h - db 0d9h - ; Hack (fnstsw [bp+var_6]) - db 0cdh - db 039h - db 07eh - db 0fah - ; Hack (wait) - db 0cdh - db 03dh - test byte ptr [bp+var_6+1], 41h - jnz short loc_2178 - dec dx - dec bx - cmp [bp+arg_A], 0 - jle short loc_2178 - ; Hack (fimul [bp+var_4]) - db 0cdh - db 03ah - db 04eh - db 0fch - inc bx - -loc_2178: - or bx, bx - jl short loc_21A1 - ; Hack (frndint) - db 0cdh - db 035h - db 0fch - ; Hack (fbstp [bp+var_10]) - db 0cdh - db 03bh - db 076h - db 0f0h - les di, [bp+arg_2] - add di, bx - push di - xor al, al - std - stosb - lea si, [bp+var_10] - mov cx, 4 - ; Hack (wait) - db 0cdh - db 03dh - or bx, bx - jnz short loc_21A8 - mov ch, ss:[si] - xor ch, 1 - jz short loc_21C3 - -loc_21A1: - ; Hack (fldz) - db 0cdh - db 035h - db 0eeh - pop di - jmp loc_208F -; --------------------------------------------------------------------------- - -loc_21A8: - mov al, ss:[si] - inc si - mov ah, al - shr ah, cl - and al, 0Fh - add ax, 3030h - stosb - or ch, al - dec bx - jz short loc_21C3 - mov al, ah - stosb - or ch, al - dec bx - jnz short loc_21A8 - -loc_21C3: - pop bx - and ch, 0Fh - jnz short loc_21DA - inc dx - cmp [bp+arg_A], 0 - jg short loc_21D4 - mov byte ptr es:[bx], 30h ; '0' - -loc_21D4: - inc bx - mov byte ptr es:[di+1], 31h ; '1' - -loc_21DA: - mov cx, [bp+arg_A] - or cx, cx - jg short loc_21E5 - neg cx - add cx, dx - -loc_21E5: - cmp cx, 28h ; '(' - jbe short loc_21ED - mov cx, 28h ; '(' - -loc_21ED: - mov byte ptr es:[bx], 0 - mov ax, bx - sub ax, word ptr [bp+arg_2] - sub cx, ax - jbe short loc_2202 - -loc_21FA: - mov word ptr es:[bx], 30h ; '0' - inc bx - loop loc_21FA - -loc_2202: - cld - les di, [bp+arg_C] - mov bx, [bp+arg_0] - mov cx, [bp+var_2] - or es:[bx+di], cx - pop es - mov ax, dx - pop di - pop si - mov sp, bp - pop bp - retn 10h -sub_2006 endp ; sp-analysis failed - +include libs/BorlandC/math/xcvt.asm include libs/BorlandC/fperr.asm ; =============== S U B R O U T I N E =======================================