# HG changeset patch # User William Astle # Date 1694397947 21600 # Node ID 718f9b7381b39d389c8499c8df8355db5946830f # Parent ba559f231929cf1041cabcdcecf4913f17f78231 Slight improvements to some floating point code diff -r ba559f231929 -r 718f9b7381b3 src/number.s --- 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