From 7eda12aa3401d4c9c92776b046e424369ea2a7db Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Wed, 8 Apr 2026 21:21:23 +0200 Subject: [PATCH] Update FINLOG --- STATUS.md | 2 +- src/basic/math/bd7e.FINLOG.s | 21 ++++++++++++++------- tools/similarity.c | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/STATUS.md b/STATUS.md index 38842206..138d7653 100644 --- a/STATUS.md +++ b/STATUS.md @@ -249,7 +249,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BCCC` | `int_FAC1` | DONE | From the Microsoft BASIC, original name: INT | | `$BCE9` | `clear_FAC1` | DONE | From the Microsoft BASIC, original name: CLRFAC | | `$BCF3` | `FIN` | PARTIAL | Only for 38k memory model + not fully tested yet | -| `$BD7E` | `FINLOG` | DONE | | +| `$BD7E` | `FINLOG` | DONE | From the Microsoft BASIC, original name: FINLOG | | `$BDDD` | `FOUT` | NOT DONE | outputs FAC1 to string at $0100 | | `$BF71` | `sqr_FAC1` | PARTIAL | needs `sqr_FAC2` | | `$BF74` | `sqr_FAC2` | NOT DONE | | diff --git a/src/basic/math/bd7e.FINLOG.s b/src/basic/math/bd7e.FINLOG.s index a5980a36..7bd8570f 100644 --- a/src/basic/math/bd7e.FINLOG.s +++ b/src/basic/math/bd7e.FINLOG.s @@ -3,17 +3,24 @@ ;; #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 - add an ASCII digit in A that has been converted to a signed integer to FAC1 ; +; This is verified to be identical to the original Microsoft implementation where it was named FINLOG. +; ; See also: ; - [CM64] Computes Mapping the Commodore 64 - page 113 ; FINLOG: - pha - jsr mov_FAC1_FAC2 - pla - jsr convert_A_to_FAC1 - jsr add_FAC2_FAC1 - rts + pha + jsr mov_r_FAC1_FAC2 + pla + jsr convert_A_to_FAC1 + lda FAC2_sign + eor FAC1_sign + sta ARISGN ; Resultant sign + ldx FAC1_exponent ; Set signs on thing to add + jmp add_FAC2_FAC1 diff --git a/tools/similarity.c b/tools/similarity.c index f199988d..be5e9bc4 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 6 +#define NUM_CHUNKS 7 // 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, @@ -28,6 +28,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xB849, 0xB97D, 0xB983, 0xB9BB, 0xBA28, 0xBCF2, + 0xBD7E, 0xBD90, 0xBFB4, 0xBFBE, };