# HG changeset patch # User William Astle # Date 1698114208 21600 # Node ID 4d7fa11ebe3f1e430d2368a5444b09e2227ade1c # Parent 6837d10b67fb67b4368f669f58af41436e8ea98d Fix error in float to int and clean up some code diff -r 6837d10b67fb -r 4d7fa11ebe3f src/fps.s --- a/src/fps.s Sun Oct 22 23:54:24 2023 -0600 +++ b/src/fps.s Mon Oct 23 20:23:28 2023 -0600 @@ -1014,16 +1014,16 @@ bne fps_toint2 ; Now convert BCD digit sequence in fpa0 significand to binary value in the low 32 bits of the significand fps_toint3 ldb #32 ; 32 bit shifts needed for whole significand - stb fpa0+fpa.extra ; use extra precision byte as counter + stb fpa0+fpa.exp ; use extra precision byte as counter fps_toint4 lsr fpa0+fpa.sig ; shift a bit into the binary result ror fpa0+fpa.sig+1 ror fpa0+fpa.sig+2 ror fpa0+fpa.sig+3 ror fpa0+fpa.sig+4 + ror fpa0+fpa.extra ror fpa0+fpa.extra+1 ror fpa0+fpa.extra+2 ror fpa0+fpa.extra+3 - ror fpa0+fpa.extra+4 ldu #fpa0+fpa.sig ; point to BCD digits fps_toint5 lda ,u ; get byte to check beq fps_toint8 ; short circuit check if digits are 0 @@ -1038,20 +1038,20 @@ stb ,u+ fps_toint6 cmpu #fpa0+fpa.sig+5 ; done all 5 bytes? blo fps_toint5 ; brif not - dec fpa0+fpa.extra ; done all bits? - bne fps_toint6 ; brif not + dec fpa0+fpa.exp ; done all bits? + bne fps_toint4 ; brif not ldb fpa0+fpa.sign ; do we want negative? bpl fps_toint7 ; brif not ldd zero ; negate the value through subtracting from 0 - subd fpa0+fpa.extra+3 - std fpa0+fpa.extra+3 + subd fpa0+fpa.extra+2 + std fpa0+fpa.extra+2 ldd zero sbcb fpa0+fpa.extra+1 sbca fpa0+fpa.extra + std fpa0+fpa.extra +fps_toint7 ldd fpa0+fpa.extra ; put result in the significand std fpa0+fpa.sig+1 -fps_toint7 ldd fpa0+fpa.extra+1 ; put result in the significand - std fpa0+fpa.sig+1 - ldd fpa0+fpa.extra+3 + ldd fpa0+fpa.extra+2 std fpa0+fpa.sig+3 rts fps_toint8 leau 1,u ; move to next digit