diff --git a/STATUS.md b/STATUS.md index e53296df..2b398dc9 100644 --- a/STATUS.md +++ b/STATUS.md @@ -223,7 +223,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BA2B` | `mul_FAC2_FAC1` | DONE | From the Microsoft BASIC, original name: FMULTT | | `$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 | | +| `$BAE2` | `mul10_FAC1` | DONE | From the Microsoft BASIC, original name: MUL10 | | `$BAFE` | `div10_FAC1_p` | DONE | | | `$BB0F` | `div_MEM_FAC1` | DONE | | | `$BB12` | `div_FAC2_FAC1` | DONE | | diff --git a/src/basic/math/bae2.mul10_FAC1.s b/src/basic/math/bae2.mul10_FAC1.s index 6eb6b434..e2adaf27 100644 --- a/src/basic/math/bae2.mul10_FAC1.s +++ b/src/basic/math/bae2.mul10_FAC1.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 - multiply FAC1 by 10 ; +; This is verified to be identical to the original Microsoft implementation where it was named MUL10 +; ; See also: ; - [CM64] Computes Mapping the Commodore 64 - page 114 ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic @@ -14,28 +18,17 @@ mul10_FAC1: - ; Handle special case of FAC1 equal 0 +MUL10: - lda FAC1_exponent - beq mul10_FAC1_done - - ; Start by multiplying FAC1 by 2 - - jsr mul10_FAC1_mul2 - - ; Move FAC1 to FAC2, so that FAC1 = FAC2 = 2 * initial - - jsr mov_FAC1_FAC2 - - ; Multiply FAC1 by 4 - - jsr mul10_FAC1_mul2 - jsr mul10_FAC1_mul2 - - ; Now we have FAC1 = 8 * initial and FAC2 = 2 * initial; so just add these 2 values - - jmp add_FAC2_FAC1 - -mul10_FAC1_done: - - rts + jsr mov_r_FAC1_FAC2 + tax + beq MUL10R + clc + adc #2 + bcs GOOVER ; Closest jmp to overflow +FINML6: ldx #0 + stx ARISGN + jsr FADDC + inc FAC1_exponent + beq GOOVER +MUL10R: rts diff --git a/tools/similarity.c b/tools/similarity.c index 4c80306f..2e6dd772 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -27,7 +27,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xB3A2, 0xB3A5, 0xB849, 0xB97D, 0xB983, 0xB9BB, - 0xBA28, 0xBAE1, + 0xBA28, 0xBAF8, 0xBB8F, 0xBCF2, };