Mercurial > hg > index.cgi
changeset 78:718f9b7381b3
Slight improvements to some floating point code
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 10 Sep 2023 20:05:47 -0600 |
parents | ba559f231929 |
children | df86e6d64ce2 |
files | src/number.s |
diffstat | 1 files changed, 5 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/number.s Thu Aug 10 00:24:52 2023 -0600 +++ b/src/number.s Sun Sep 10 20:05:47 2023 -0600 @@ -109,9 +109,7 @@ pshs b ; apply exponent counter to exponent lda val.fpexp,x suba ,s+ - bls fp_normalize6 ; brif we underflowed to zero - bcc fp_normalize3 ; brif we did not overflow -OVERROR2 jmp OVERROR ; raise overflow + bls fp_normalize6 ; brif we underflowed to zero; overflow is impossible fp_normalize3 lsl ,s+ ; set C if the high bit of extra precision is set bcs fp_normalize5 ; brif bit set - we have to do rounding fp_normalize4 rts ; return if no rounding @@ -125,8 +123,8 @@ bne fp_normalize4 ; brif high word doesn't carry ror val.fpmant,x ; shift right C in to high bit of mantissa (already set to get here) inc val.fpexp,x ; bump exponent for a right shift - beq OVERROR2 ; brif it overflows (> +127) - rts ; return result (only possible result was mantissa wrapped to zero) + bne fp_normalize4 ; brif it doesn't overflow (> +127) +OVERROR2 jmp OVERROR ; raise overflow fp_normalize6 clr val.fpmant,x ; clear mantissa clr val.fpmant+1,x clr val.fpmant+2,x @@ -150,7 +148,7 @@ adcb val.int+1,u adca val.int,u std val.int,y - lbvs OVERROR ; brif calculation overflowed + bvs OVERROR2 ; brif calculation overflowed rts val_sub ldb val.type,x ; get type of left operand stb val.type,y ; set result type @@ -163,7 +161,7 @@ sbcb val.int+1,u sbca val.int,u std val.int,y - lbvs OVERROR ; brif overflow + bvs OVERROR2 ; brif overflow rts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FP subtraction: just invert the sign of the second operand and add; operands must be writable and they should be