changeset 115:03eb6d6b49b4

Correct order of initialization in floating point division
author William Astle <lost@l-w.ca>
date Wed, 27 Dec 2023 00:07:05 -0700
parents df803556bfae
children e72cda5e5ee2
files src/fps.s
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/fps.s	Wed Dec 27 00:05:31 2023 -0700
+++ b/src/fps.s	Wed Dec 27 00:07:05 2023 -0700
@@ -649,15 +649,6 @@
                 lda fpa0+fpa.sign               ; calculate result sign (XOR of argument signs)
                 eora fpa1+fpa.sign
                 sta fpa0+fpa.sign
-                ldd fpa0+fpa.sig                ; initialize residue to dividend
-                std fpa1+fpa.sig
-                ldd fpa0+fpa.sig+2
-                std fpa1+fpa.sig+2
-                lda fpa0+fpa.sig+4
-                sta fpa1+fpa.sig+4
-                ldd #11                         ; initialize digit counter and nonzero seen flag
-                std fpaextra+5
-                sta fpaextra+7                  ; set ongoing extra carry digits to zero 
                 ldd #0x9999                     ;* calculate 9's complement of divisor for later; we'll introduce a carry
                 subd fpa1+fpa.sig               ;* to the first byte to complete the 10's complement's +1 to save doing
                 std fpaextra                    ;* the extra work here
@@ -667,6 +658,15 @@
                 lda #0x99
                 suba fpa1+fpa.sig+4
                 sta fpaextra+4
+                ldd fpa0+fpa.sig                ; initialize residue to dividend
+                std fpa1+fpa.sig+5
+                ldd fpa0+fpa.sig+2
+                std fpa1+fpa.sig+7
+                lda fpa0+fpa.sig+4
+                sta fpa1+fpa.sig+9
+                ldd #11                         ; initialize digit counter and nonzero seen flag
+                std fpaextra+5
+                sta fpaextra+7                  ; set ongoing extra carry digits to zero 
                 bsr fps_div3                    ; calculate the quotient byte by byte
                 stb fpa0+fpa.sig
                 bsr fps_div3