diff --git a/STATUS.md b/STATUS.md index b4995691..2e526373 100644 --- a/STATUS.md +++ b/STATUS.md @@ -235,7 +235,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BC39` | `sgn_FAC1` | DONE | | | `$BC3C` | `convert_A_to_FAC1` | DONE | | | `$BC44` | `convert_i16_to_FAC1` | DONE | | -| `$BC58` | `abs_FAC1` | NOT DONE | | +| `$BC58` | `abs_FAC1` | DONE | From the Microsoft BASIC, original name: ABS | | `$BC5B` | `FCOMP` | DONE | | | `$BC9B` | `QINT` | NOT DONE | convert FAC1 to 32 bit signed integer | | `$BCCC` | `int_FAC1` | DONE | | diff --git a/src/basic/,stubs_math/bc58.abs_FAC1.s b/src/basic/,stubs_math/bc58.abs_FAC1.s deleted file mode 100644 index caf41ff8..00000000 --- a/src/basic/,stubs_math/bc58.abs_FAC1.s +++ /dev/null @@ -1,19 +0,0 @@ -;; #LAYOUT# STD * #TAKE -;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -;; #LAYOUT# * BASIC_0 #TAKE -;; #LAYOUT# * * #IGNORE - -; -; Math package - absolute value -; -; See also: -; - [CM64] Computes Mapping the Commodore 64 - page 115 -; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -; - -; XXX provide implementation - -abs_FAC1: - - +STUB_IMPLEMENTATION diff --git a/src/basic/math/bc58.abs_FAC1.s b/src/basic/math/bc58.abs_FAC1.s new file mode 100644 index 00000000..7ac6e8dd --- /dev/null +++ b/src/basic/math/bc58.abs_FAC1.s @@ -0,0 +1,17 @@ +;; #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 - absolute value of FAC1 +; +; This is verified to be identical to the original Microsoft implementation where it was named ABS. +; + +abs_FAC1: + + lsr FAC1_sign + rts diff --git a/src/basic/,stubs_math/bc58.interop b/src/basic/math/bc58.interop similarity index 100% rename from src/basic/,stubs_math/bc58.interop rename to src/basic/math/bc58.interop diff --git a/tools/similarity.c b/tools/similarity.c index b7cc704f..9b5573a5 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -20,11 +20,12 @@ int matches[MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE]; -#define NUM_CHUNKS 1 +#define NUM_CHUNKS 3 // 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, - 0xBBA2, 0xBC1A + 0xBBA2, 0xBC1A, + 0xBC58, 0xBC5A };