From 00c74cdd48df985746e4fd718093fd29bbd72e33 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Fri, 30 Jan 2026 21:09:13 +0100 Subject: [PATCH] Add clear_FAC1 --- STATUS.md | 1 + src/basic/math/bce9.clear_FAC1.s | 28 ++++++++++++++++++++++++++++ tools/similarity.c | 5 +++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/basic/math/bce9.clear_FAC1.s diff --git a/STATUS.md b/STATUS.md index d670befd..b4fd9be6 100644 --- a/STATUS.md +++ b/STATUS.md @@ -241,6 +241,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BC5B` | `FCOMP` | DONE | | | `$BC9B` | `QINT` | NOT DONE | convert FAC1 to 32 bit signed integer | | `$BCCC` | `int_FAC1` | DONE | | +| `$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 | | | `$BDDD` | `FOUT` | NOT DONE | outputs FAC1 to string at $0100 | diff --git a/src/basic/math/bce9.clear_FAC1.s b/src/basic/math/bce9.clear_FAC1.s new file mode 100644 index 00000000..c7fe81f0 --- /dev/null +++ b/src/basic/math/bce9.clear_FAC1.s @@ -0,0 +1,28 @@ +;; #LAYOUT# STD * #TAKE +;; #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 - clear FAC1 +; +; Set each byte of the mantissa of FAC1 to the value of A +; +; This is verified to be identical to the original Microsoft implementation where it was named CLRFAC. +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; + + +clear_FAC1: + sta FAC1_mantissa+0 + sta FAC1_mantissa+1 + sta FAC1_mantissa+2 + sta FAC1_mantissa+3 + tay +clear_FAC1_rts: ; Return point needed elsewhere + rts diff --git a/tools/similarity.c b/tools/similarity.c index bfeabe25..1f156c7d 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,14 +20,15 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 5 +#define NUM_CHUNKS 6 // Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xB849, 0xB84F, 0xB947, 0xB97D, 0xB983, 0xB9BB, 0xBBA2, 0xBC1A, - 0xBC58, 0xBC5A + 0xBC58, 0xBC5A, + 0xBCE9, 0xBCF2, };