changeset 99:4d7fa11ebe3f

Fix error in float to int and clean up some code
author William Astle <lost@l-w.ca>
date Mon, 23 Oct 2023 20:23:28 -0600
parents 6837d10b67fb
children 6db72a92ff7a
files src/fps.s
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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