From 7079b013bbac3189b105da1e036706ebe7916bda Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Thu, 10 Jul 2008 18:37:51 +0000 Subject: [PATCH] fixed ftoa procedure in calculator (fixed bug reported by Albom) git-svn-id: svn://kolibrios.org@822 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/other/calc/trunk/calc.asm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/programs/other/calc/trunk/calc.asm b/programs/other/calc/trunk/calc.asm index 5f1febc42d..dc1fd95af9 100644 --- a/programs/other/calc/trunk/calc.asm +++ b/programs/other/calc/trunk/calc.asm @@ -468,14 +468,14 @@ ftoa: ; fpu st0 -> [integer],[decimal] no_neg: fld [tmp2] - fist [integer] - fisub [integer] - fldcw [controlWord] cmp byte [sign], 0 ; change fraction to positive je no_neg2 fchs no_neg2: + fadd [smallValueForRounding] + fist [integer] + fisub [integer] mov [res],0 ; convert 6 decimal numbers mov edi,6 @@ -499,6 +499,7 @@ ftoa: ; fpu st0 -> [integer],[decimal] jmp newd real_done: + fldcw [controlWord] mov eax,[res] mov [decimal],eax cmp [integer],0x80000000 @@ -510,10 +511,10 @@ ftoa: ; fpu st0 -> [integer],[decimal] mov [dsign],byte '+' cmp [sign],byte 0 ; convert negative result je no_negative - mov eax,[integer] - not eax - inc eax - mov [integer],eax +; mov eax,[integer] +; not eax +; inc eax +; mov [integer],eax mov [dsign],byte '-' no_negative: @@ -866,6 +867,7 @@ res dd 0 trans1 dq 0 trans2 dq 0 controlWord dw 1 +smallValueForRounding dq 0.0000005 ; 1/2 from last significant digit multipl: dd 10,16,2 dsign: