From 24f1bc919398c34614a1b2f52d8f68c9796e4ea0 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Wed, 15 Apr 2026 18:48:55 +0200 Subject: [PATCH] Add sqr_FAC2 --- STATUS.md | 2 +- .../{,stubs_math => math_trans}/bf74.interop | 0 .../bf74.sqr_FAC2.s | 19 ++++++++++++++++--- tools/similarity.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) rename src/basic/{,stubs_math => math_trans}/bf74.interop (100%) rename src/basic/{,stubs_math => math_trans}/bf74.sqr_FAC2.s (54%) diff --git a/STATUS.md b/STATUS.md index f40beb54..e8d1a783 100644 --- a/STATUS.md +++ b/STATUS.md @@ -252,7 +252,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BD7E` | `FINLOG` | DONE | From the Microsoft BASIC, original name: FINLOG | | `$BDDD` | `FOUT` | DONE | From the Microsoft BASIC, original name: FOUT | | `$BF71` | `sqr_FAC1` | DONE | From the Microsoft BASIC, original name: SQR | -| `$BF74` | `sqr_FAC2` | NOT DONE | | +| `$BF74` | `sqr_FAC2` | DONE | From the Microsoft BASIC, no label | | `$BF78` | `pwr_FAC2_MEM` | PARTIAL | needs `pwr_FAC2_FAC1` | | `$BF7B` | `pwr_FAC2_FAC1` | NOT DONE | | | `$BFB4` | `toggle_sign_FAC1` | DONE | From the Microsoft BASIC, original name: NEGOP | diff --git a/src/basic/,stubs_math/bf74.interop b/src/basic/math_trans/bf74.interop similarity index 100% rename from src/basic/,stubs_math/bf74.interop rename to src/basic/math_trans/bf74.interop diff --git a/src/basic/,stubs_math/bf74.sqr_FAC2.s b/src/basic/math_trans/bf74.sqr_FAC2.s similarity index 54% rename from src/basic/,stubs_math/bf74.sqr_FAC2.s rename to src/basic/math_trans/bf74.sqr_FAC2.s index 1cb3db61..c6d48c49 100644 --- a/src/basic/,stubs_math/bf74.sqr_FAC2.s +++ b/src/basic/math_trans/bf74.sqr_FAC2.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 - square root of FAC2 ; +; This is verified to be identical to the original Microsoft implementation where it was unnamed +; ; Note: ; - loads .5 into FAC1 and falling through to the exponentiation routine ; @@ -15,8 +19,17 @@ ; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics ; -; XXX provide implementation +!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS { + sqr_FAC2: - +STUB_IMPLEMENTATION + lda #const_HALF + + ; FALLLTROUGH to pwr_FAC2_MEM + + +} else { + jmp do_NOT_IMPLEMENTED_error +} diff --git a/tools/similarity.c b/tools/similarity.c index 15cb5bc3..ec251c1c 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -31,7 +31,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { 0xBD7E, 0xBD90, 0xBDB3, 0xBDC1, 0xBDDD, 0xBF51, - 0xBF71, 0xBF73, + 0xBF71, 0xBF77, 0xBFB4, 0xBFEC, 0xE043, 0xE08C, 0xE264, 0xE2C2, // Two byte gap here is an optimization