diff --git a/STATUS.md b/STATUS.md index 34e90738..0efd5a5b 100644 --- a/STATUS.md +++ b/STATUS.md @@ -218,8 +218,8 @@ Floating point mathematical routines - not official, but well known and broadly | `$B9EA` | `log_FAC1` | PARTIAL | not fully tested yet | | `$BA28` | `mul_MEM_FAC1` | DONE | | | `$BA2B` | `mul_FAC2_FAC1` | DONE | | -| `$BA8C` | `mov_MEM_FAC2` | DONE | | -| `$BA90` | `get_FAC2_via_INDEX` | DONE | | +| `$BA8C` | `mov_MEM_FAC2` | DONE | From the Microsoft BASIC, original name: CONUPK | +| `$BA90` | `get_FAC2_via_INDEX` | DONE | From the Microsoft BASIC, no label | | `$BAE2` | `mul10_FAC1` | DONE | | | `$BAFE` | `div10_FAC1_p` | DONE | | | `$BB0F` | `div_MEM_FAC1` | DONE | | diff --git a/src/basic/math_mov/ba8c.mov_MEM_FAC2.s b/src/basic/math_mov/ba8c.mov_MEM_FAC2.s index d6692529..548c7f5a 100644 --- a/src/basic/math_mov/ba8c.mov_MEM_FAC2.s +++ b/src/basic/math_mov/ba8c.mov_MEM_FAC2.s @@ -2,7 +2,10 @@ ;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 ;; #LAYOUT# * BASIC_0 #TAKE ;; #LAYOUT# * * #IGNORE -; + +; This file is under the MIT license, it contains code released by Microsoft Corporation. +; See LICENSE for more information. + ; Math package - fetch FAC2 from memory location ; ; Input: @@ -16,6 +19,8 @@ ; Preserves: ; - .X - (experimentation with original ROM) ; +; This is verified to be identical to the original Microsoft implementation where it was named CONUPK. +; ; See also: ; - [CM64] Computes Mapping the Commodore 64 - page 114 ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic @@ -24,7 +29,7 @@ mov_MEM_FAC2: - sty INDEX+1 - sta INDEX+0 + sta INDEX+0 + sty INDEX+1 ; FALLTHROUGH to get_FAC2_via_INDEX diff --git a/src/basic/math_mov/ba90.get_FAC2_via_INDEX.s b/src/basic/math_mov/ba90.get_FAC2_via_INDEX.s index 4b135a21..b910e226 100644 --- a/src/basic/math_mov/ba90.get_FAC2_via_INDEX.s +++ b/src/basic/math_mov/ba90.get_FAC2_via_INDEX.s @@ -3,9 +3,13 @@ ;; #LAYOUT# * BASIC_0 #TAKE ;; #LAYOUT# * * #IGNORE -; +; This file is under the MIT license, it contains code released by Microsoft Corporation. +; See LICENSE for more information. + ; Math package - Mov MEM to FAC2 with address in INDEX zero page register ; +; This is verified to be identical to the original Microsoft implementation where it was named CONUPK (partial). +; ; See also: ; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True ; @@ -14,36 +18,25 @@ get_FAC2_via_INDEX: - ; Now copy the data from RAM to FAC2, for the format description see: - ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 - - ; Copy the mantissa - - ldy #$04 - lda (INDEX), y - sta FAC2_mantissa+3 - - dey - lda (INDEX), y - sta FAC2_mantissa+2 - - dey - lda (INDEX), y - sta FAC2_mantissa+1 - - dey - lda (INDEX), y - sta FAC2_sign - ora #$80 ; clear the sign bit - sta FAC2_mantissa+0 - - ; Copy the exponent - - dey - lda (INDEX), y - sta FAC2_exponent - - ; Return the FAC1 exponent - - lda FAC1_exponent - rts + ldy #4 + lda (INDEX),Y + sta FAC2_mantissa+3 + dey + lda (INDEX),Y + sta FAC2_mantissa+2 + dey + lda (INDEX),Y + sta FAC2_mantissa+1 + dey + lda (INDEX),Y + sta FAC2_sign + eor FAC1_sign ; Set sign for multiplication/division + sta ARISGN + lda FAC2_sign + ora #$80 ; Set mantissa high bit + sta FAC2_mantissa+0 + dey + lda (INDEX),Y + sta FAC2_exponent + lda FAC1_exponent ; Set flags from FAC1_exponent + rts diff --git a/tools/similarity.c b/tools/similarity.c index 713deee0..1df1c286 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,7 +20,7 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 8 +#define NUM_CHUNKS 9 // Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xB391, 0xB39D, @@ -29,6 +29,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xB8D2, 0xB8D5, 0xB947, 0xB97D, 0xB983, 0xB9BB, + 0xBA8C, 0xBAB6, 0xBBA2, 0xBC1A, 0xBC2B, 0xBCF2, };