Update convert_A_to_FAC1

This commit is contained in:
Rikard Nordgren authored and FeralChild64 committed 2026-03-29 21:45:24 +02:00
1 parent dfa61a5acd
commit 64ac8b2073
4 files changed
+11 -20

No files matched your search

+1 -1
View File
@@ -236,7 +236,7 @@ Floating point mathematical routines - not official, but well known and broadly
| `$BC1B` | `round_FAC1` | PARTIAL | not fully tested yet |
| `$BC2B` | `sgn_FAC1_A` | DONE | From the Microsoft BASIC, original name: SIGN |
| `$BC39` | `sgn_FAC1` | DONE | From the Microsoft BASIC, original name: SGN |
| `$BC3C` | `convert_A_to_FAC1` | DONE | |
| `$BC3C` | `convert_A_to_FAC1` | DONE | From the Microsoft BASIC, original name: FLOAT |
| `$BC44` | `convert_i16_to_FAC1` | DONE | |
| `$BC58` | `abs_FAC1` | DONE | From the Microsoft BASIC, original name: ABS |
| `$BC5B` | `FCOMP` | DONE | |
+9 -5
View File
@@ -3,22 +3,26 @@
;; #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 - convert int8 in A to FAC1
;
; Input: A - int8 to convert to float
; Result: FAC1
;
; This is verified to be identical to the original Microsoft implementation where it was named FLOAT.
;
; Sets first byte of FAC1 to A, sign extends A into tge second byte and falls through to convert_i16_to_FAC1
;
; - https://codebase64.org/doku.php?id=base:asm_include_file_for_basic_routines
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
;
convert_A_to_FAC1:
sta FAC1_mantissa+0
lda #0
sta FAC1_mantissa+1
jsr sign_extend_A_to_Y
sty FAC1_mantissa
+nop ; To not leave a gap to the fallthrough
ldx #$88
; Fall through to convert_i16_to_FAC1
-13
View File
@@ -1,13 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Math package - helper function to sign extend accumulator into Y
sign_extend_A_to_Y:
cmp #$80 ; Copy sign into carry
ldy #$00 ; Y = $00
bcc @1 ; Branch if not negative
dey ; Y = $FF
@1: rts
+1 -1
View File
@@ -28,7 +28,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
0xB947, 0xB97D,
0xB983, 0xB9BB,
0xBBA2, 0xBC1A,
0xBC2B, 0xBC3B,
0xBC2B, 0xBC43,
0xBC58, 0xBC5A,
0xBC9B, 0xBCF2,
};