Mercurial > hg > index.cgi
changeset 89:f519075cc164
Fix various issues with floating point number display
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 16 Oct 2023 23:42:51 -0600 |
parents | a8467c798450 |
children | f1d847f69c0d |
files | src/fps.s |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fps.s Mon Oct 16 23:42:35 2023 -0600 +++ b/src/fps.s Mon Oct 16 23:42:51 2023 -0600 @@ -22,8 +22,8 @@ rts fps_unpack1b sex ; get sign flag to store sta fpa1+fpa.sign ; set accumulator - anda #0x7f ; lose sign from exponent - sta fpa1+fpa.exp ; set exponent + andb #0x7f ; lose sign from exponent + stb fpa1+fpa.exp ; set exponent ldd 1,x ; copy signficand over std fpa1+fpa.sig ldd 3,x @@ -43,8 +43,8 @@ rts fps_unpack0b sex ; get sign flag to store sta fpa0+fpa.sign ; set accumulator - anda #0x7f ; lose sign from exponent - sta fpa0+fpa.exp ; set exponent + andb #0x7f ; lose sign from exponent + stb fpa0+fpa.exp ; set exponent ldd 1,x ; copy signficand over std fpa0+fpa.sig ldd 3,x @@ -811,9 +811,10 @@ inca ; count digit bitb #0x0f ; is right digit set? beq fps_toascii3 ; brif not - we've counted all the sigificant digits - deca ; done all significant digits? - bne fps_toascii2 ; brif not -fps_toascii3 stb fpaextra ; save significant digits that exist + inca ; count the digit + cmpx #fpa0+fpa.sig+5 ; done all significant digits? + blo fps_toascii2 ; brif not +fps_toascii3 sta fpaextra ; save significant digits that exist lda fpa0+fpa.exp ; fetch exponent suba #64 ; remove bias sta fpa0+fpa.exp ; save for later @@ -823,11 +824,10 @@ blt fps_toascii15 ; brif too many - do scientific notation ldd #'0*256+'. ; put a leading "0." std ,u++ - ldb fpa0+fpa.exp ; get exponent back - addb fpaextra ; add number of available significant digits - beq fps_toascii5 ; brif no leading digits + ldb fpa0+fpa.exp ; get exponent back, which is the number of leading digits (negative) + bra fps_toascii4a ; go add leading zeroes if needed fps_toascii4 sta ,u+ ; put a zero - incb ; done all +fps_toascii4a incb ; done all bne fps_toascii4 ; brif not fps_toascii5 ldx #fpa0+fpa.sig ; point to significand ldd #0xf000 ; set digit mask and counter @@ -839,11 +839,12 @@ lsra ; right justify digit lsra lsra + lsra fps_toascii7 adda #0x30 ; turn it into ascii sta ,u+ ; stuff it in the output dec fpaextra ; done all digits? beq fps_toascii9 ; brif so - cmpa fpaextra+1 ; are we at the decimal point? + dec fpaextra+1 ; are we at the decimal point? bne fps_toascii8 ; brif not lda #'. ; put a decimal sta ,u+