From 03db0610a882934355e34a4bd424671fe2b3ab45 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Thu, 29 Jan 2026 20:12:53 +0100 Subject: [PATCH] Add inc_FAC1 --- STATUS.md | 1 + src/basic/math/b96F.inc_FAC1.s | 30 ++++++++++++++++++++++++++++++ tools/similarity.c | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/basic/math/b96F.inc_FAC1.s diff --git a/STATUS.md b/STATUS.md index 2e526373..ff2a3d89 100644 --- a/STATUS.md +++ b/STATUS.md @@ -212,6 +212,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$B86A` | `add_FAC2_FAC1` | DONE | | | `$B8FE` | `normal_FAC1` | DONE | | | `$B947` | `inv_FAC1_mantissa` | DONE | | +| `$B96F` | `inc_FAC1` | DONE | From the Microsoft BASIC, original name: INCFAC | | `$B9EA` | `log_FAC1` | PARTIAL | not fully tested yet | | `$BA28` | `mul_MEM_FAC1` | DONE | | | `$BA2B` | `mul_FAC2_FAC1` | DONE | | diff --git a/src/basic/math/b96F.inc_FAC1.s b/src/basic/math/b96F.inc_FAC1.s new file mode 100644 index 00000000..80bdba00 --- /dev/null +++ b/src/basic/math/b96F.inc_FAC1.s @@ -0,0 +1,30 @@ +;; #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 - increment FAC1 +; +; This is verified to be identical to the original Microsoft implementation where it was named INCFAC. +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; + +inc_FAC1: + + inc FAC1_mantissa+3 + bne inc_FAC1_ret + inc FAC1_mantissa+2 + bne inc_FAC1_ret + inc FAC1_mantissa+1 + bne inc_FAC1_ret + inc FAC1_mantissa+0 + +inc_FAC1_ret: + + rts diff --git a/tools/similarity.c b/tools/similarity.c index 9b5573a5..2fbbb228 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,10 +20,11 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 3 +#define NUM_CHUNKS 4 // 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, + 0xB96F, 0xB97D, 0xBBA2, 0xBC1A, 0xBC58, 0xBC5A };