diff --git a/STATUS.md b/STATUS.md index 73bd6300..ccb1b8b4 100644 --- a/STATUS.md +++ b/STATUS.md @@ -226,7 +226,7 @@ Floating point mathematical routines - not official, but well known and broadly | `$BBC7` | `mov_r_FAC1_TMP2` | PARTIAL | not fully tested yet | | `$BBCA` | `mov_r_FAC1_TMP1` | PARTIAL | not fully tested yet | | `$BBD0` | `mov_r_FAC1_VAR` | PARTIAL | not fully tested yet | -| `$BBD4` | `mov_r_FAC1_MEM` | PARTIAL | not fully tested yet | +| `$BBD4` | `mov_r_FAC1_MEM` | DONE | From the Microsoft BASIC, original name: MOVMF | | `$BBFC` | `mov_FAC2_FAC1` | DONE | From the Microsoft BASIC, original name: MOVFA | | `$BC0C` | `mov_r_FAC1_FAC2` | DONE | From the Microsoft BASIC, original name: MOVAF | | `$BC0F` | `mov_FAC1_FAC2` | DONE | From the Microsoft BASIC, original name: MOVEF | diff --git a/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s b/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s index 3fcad9d5..fca7500f 100644 --- a/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s +++ b/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s @@ -3,16 +3,21 @@ ;; #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 - copy FAC1 to memory location, do not round ; +; This is verified to be identical to the original Microsoft implementation where it was named MOVMF. +; ; Input: ; - .X - address low byte ; - .Y - address high byte ; ; Output: ; - .A - FAC1 exponent -; +; - .Y - 0 + ; See also: ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic ; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics @@ -20,7 +25,25 @@ mov_r_FAC1_MEM: - ; Start by rounding FAC1 - - jsr round_FAC1 - jmp mov_FAC1_MEM + jsr round_FAC1 + stx INDEX+0 + sty INDEX+1 + ldy #4 + lda FAC1_mantissa+3 + sta (INDEX),y + dey + lda FAC1_mantissa+2 + sta (INDEX),y + dey + lda FAC1_mantissa+1 + sta (INDEX),y + dey + lda FAC1_sign + ora #$7F + and FAC1_mantissa + sta (INDEX),y + dey + lda FAC1_exponent + sta (INDEX),y + sty FACOV + rts diff --git a/tools/similarity.c b/tools/similarity.c index c0360de4..5b62e59b 100644 --- a/tools/similarity.c +++ b/tools/similarity.c @@ -24,7 +24,7 @@ int phase_mask[MAX_SIZE+MAX_SIZE]; // 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, - 0xBBFC, 0xBC1A + 0xBBD4, 0xBC1A };