Update mov_MEM_FAC2 and get_FAC2_via_INDEX

This commit is contained in:
Rikard Nordgren authored and FeralChild64 committed 2026-03-29 21:45:24 +02:00
1 parent 135522352a
commit 061440c7e1
4 files changed
+27 -28

No files matched your search

+2 -2
View File
@@ -218,8 +218,8 @@ Floating point mathematical routines - not official, but well known and broadly
| `$B9EA` | `log_FAC1` | PARTIAL | not fully tested yet | | `$B9EA` | `log_FAC1` | PARTIAL | not fully tested yet |
| `$BA28` | `mul_MEM_FAC1` | DONE | | | `$BA28` | `mul_MEM_FAC1` | DONE | |
| `$BA2B` | `mul_FAC2_FAC1` | DONE | | | `$BA2B` | `mul_FAC2_FAC1` | DONE | |
| `$BA8C` | `mov_MEM_FAC2` | DONE | | | `$BA8C` | `mov_MEM_FAC2` | DONE | From the Microsoft BASIC, original name: CONUPK |
| `$BA90` | `get_FAC2_via_INDEX` | DONE | | | `$BA90` | `get_FAC2_via_INDEX` | DONE | From the Microsoft BASIC, no label |
| `$BAE2` | `mul10_FAC1` | DONE | | | `$BAE2` | `mul10_FAC1` | DONE | |
| `$BAFE` | `div10_FAC1_p` | DONE | | | `$BAFE` | `div10_FAC1_p` | DONE | |
| `$BB0F` | `div_MEM_FAC1` | DONE | | | `$BB0F` | `div_MEM_FAC1` | DONE | |
+7 -2
View File
@@ -2,7 +2,10 @@
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 ;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE ;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE ;; #LAYOUT# * * #IGNORE
;
; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - fetch FAC2 from memory location ; Math package - fetch FAC2 from memory location
; ;
; Input: ; Input:
@@ -16,6 +19,8 @@
; Preserves: ; Preserves:
; - .X - (experimentation with original ROM) ; - .X - (experimentation with original ROM)
; ;
; This is verified to be identical to the original Microsoft implementation where it was named CONUPK.
;
; See also: ; See also:
; - [CM64] Computes Mapping the Commodore 64 - page 114 ; - [CM64] Computes Mapping the Commodore 64 - page 114
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
@@ -24,7 +29,7 @@
mov_MEM_FAC2: mov_MEM_FAC2:
sty INDEX+1
sta INDEX+0 sta INDEX+0
sty INDEX+1
; FALLTHROUGH to get_FAC2_via_INDEX ; FALLTHROUGH to get_FAC2_via_INDEX
+16 -23
View File
@@ -3,9 +3,13 @@
;; #LAYOUT# * BASIC_0 #TAKE ;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE ;; #LAYOUT# * * #IGNORE
; ; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - Mov MEM to FAC2 with address in INDEX zero page register ; Math package - Mov MEM to FAC2 with address in INDEX zero page register
; ;
; This is verified to be identical to the original Microsoft implementation where it was named CONUPK (partial).
;
; See also: ; See also:
; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True ; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True
; ;
@@ -14,36 +18,25 @@
get_FAC2_via_INDEX: get_FAC2_via_INDEX:
; Now copy the data from RAM to FAC2, for the format description see: ldy #4
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 lda (INDEX),Y
; Copy the mantissa
ldy #$04
lda (INDEX), y
sta FAC2_mantissa+3 sta FAC2_mantissa+3
dey dey
lda (INDEX), y lda (INDEX),Y
sta FAC2_mantissa+2 sta FAC2_mantissa+2
dey dey
lda (INDEX), y lda (INDEX),Y
sta FAC2_mantissa+1 sta FAC2_mantissa+1
dey dey
lda (INDEX), y lda (INDEX),Y
sta FAC2_sign sta FAC2_sign
ora #$80 ; clear the sign bit eor FAC1_sign ; Set sign for multiplication/division
sta ARISGN
lda FAC2_sign
ora #$80 ; Set mantissa high bit
sta FAC2_mantissa+0 sta FAC2_mantissa+0
; Copy the exponent
dey dey
lda (INDEX), y lda (INDEX),Y
sta FAC2_exponent sta FAC2_exponent
lda FAC1_exponent ; Set flags from FAC1_exponent
; Return the FAC1 exponent
lda FAC1_exponent
rts rts
+2 -1
View File
@@ -20,7 +20,7 @@ int matches[MAX_SIZE];
int phase_mask[MAX_SIZE+MAX_SIZE]; int phase_mask[MAX_SIZE+MAX_SIZE];
#define NUM_CHUNKS 8 #define NUM_CHUNKS 9
// Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC // Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC
unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = { unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
0xB391, 0xB39D, 0xB391, 0xB39D,
@@ -29,6 +29,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
0xB8D2, 0xB8D5, 0xB8D2, 0xB8D5,
0xB947, 0xB97D, 0xB947, 0xB97D,
0xB983, 0xB9BB, 0xB983, 0xB9BB,
0xBA8C, 0xBAB6,
0xBBA2, 0xBC1A, 0xBBA2, 0xBC1A,
0xBC2B, 0xBCF2, 0xBC2B, 0xBCF2,
}; };