Add QINT
This commit is contained in:
1 parent
00c74cdd48
commit
81eb67adb8
5 files changed
+54
-23
No files matched your search
@@ -239,7 +239,7 @@ Floating point mathematical routines - not official, but well known and broadly
|
|||||||
| `$BC44` | `convert_i16_to_FAC1` | DONE | |
|
| `$BC44` | `convert_i16_to_FAC1` | DONE | |
|
||||||
| `$BC58` | `abs_FAC1` | DONE | From the Microsoft BASIC, original name: ABS |
|
| `$BC58` | `abs_FAC1` | DONE | From the Microsoft BASIC, original name: ABS |
|
||||||
| `$BC5B` | `FCOMP` | DONE | |
|
| `$BC5B` | `FCOMP` | DONE | |
|
||||||
| `$BC9B` | `QINT` | NOT DONE | convert FAC1 to 32 bit signed integer |
|
| `$BC9B` | `QINT` | DONE | From the Microsoft BASIC, original name: QINT |
|
||||||
| `$BCCC` | `int_FAC1` | DONE | |
|
| `$BCCC` | `int_FAC1` | DONE | |
|
||||||
| `$BCE9` | `clear_FAC1` | DONE | From the Microsoft BASIC, original name: CLRFAC |
|
| `$BCE9` | `clear_FAC1` | DONE | From the Microsoft BASIC, original name: CLRFAC |
|
||||||
| `$BCF3` | `FIN` | PARTIAL | Only for 38k memory model + not fully tested yet |
|
| `$BCF3` | `FIN` | PARTIAL | Only for 38k memory model + not fully tested yet |
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
;; #LAYOUT# STD * #TAKE
|
|
||||||
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
|
||||||
;; #LAYOUT# * BASIC_0 #TAKE
|
|
||||||
;; #LAYOUT# * * #IGNORE
|
|
||||||
|
|
||||||
;
|
|
||||||
; Math package - convert FAC1 to 32 bit signed integer
|
|
||||||
;
|
|
||||||
; Output:
|
|
||||||
; - $62-$65, big-endian order
|
|
||||||
;
|
|
||||||
; See also:
|
|
||||||
; - [CM64] Computes Mapping the Commodore 64 - page 115
|
|
||||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
|
||||||
;
|
|
||||||
|
|
||||||
; XXX provide implementation
|
|
||||||
|
|
||||||
QINT:
|
|
||||||
|
|
||||||
+STUB_IMPLEMENTATION
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
;; #LAYOUT# STD * #TAKE
|
||||||
|
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
|
||||||
|
;; #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
;; #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
;
|
||||||
|
; Math package - Quick conversion of FAC1 to 32 bit signed integer
|
||||||
|
;
|
||||||
|
; Output:
|
||||||
|
; - $62-$65, big-endian order
|
||||||
|
;
|
||||||
|
; See also:
|
||||||
|
; - [CM64] Computes Mapping the Commodore 64 - page 115
|
||||||
|
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
QINT:
|
||||||
|
;QUICK GREATEST INTEGER FUNCTION.
|
||||||
|
;LEAVES INT(FAC) IN FACHO&MO&LO SIGNED.
|
||||||
|
;ASSUMES FAC .LT. 2^23 = 8388608
|
||||||
|
|
||||||
|
lda FAC1_exponent
|
||||||
|
beq clear_FAC1 ; If zero, got it.
|
||||||
|
sec
|
||||||
|
sbc #$A0 ; Get number of places to shift.
|
||||||
|
bit FAC1_sign
|
||||||
|
bpl @1
|
||||||
|
tax
|
||||||
|
lda #$FF
|
||||||
|
sta BITS
|
||||||
|
jsr neg_FAC1_mantissa
|
||||||
|
txa
|
||||||
|
@1: ldx #FAC1_exponent
|
||||||
|
cmp #$F9
|
||||||
|
bpl QINT1 ; If number of places >= 7 shift 1 place at a time.
|
||||||
|
jsr shiftr_FAC
|
||||||
|
sty BITS ; Zero bits since adder wants zero.
|
||||||
|
QINT_ret:
|
||||||
|
rts
|
||||||
|
|
||||||
|
QINT1:
|
||||||
|
tay ; Put count in counter
|
||||||
|
lda FAC1_sign
|
||||||
|
and #$80 ; Get sign bit
|
||||||
|
lsr FAC1_mantissa ; Save first shifted byte
|
||||||
|
ora FAC1_mantissa
|
||||||
|
sta FAC1_mantissa
|
||||||
|
jsr short_shift_FAC ; Shift the rest
|
||||||
|
sty BITS ; Zero [BITS]
|
||||||
|
rts
|
||||||
File renamed without changes.
+2
-1
@@ -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 6
|
#define NUM_CHUNKS 7
|
||||||
// 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] = {
|
||||||
0xB849, 0xB84F,
|
0xB849, 0xB84F,
|
||||||
@@ -28,6 +28,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
|
|||||||
0xB983, 0xB9BB,
|
0xB983, 0xB9BB,
|
||||||
0xBBA2, 0xBC1A,
|
0xBBA2, 0xBC1A,
|
||||||
0xBC58, 0xBC5A,
|
0xBC58, 0xBC5A,
|
||||||
|
0xBC9B, 0xBCCB,
|
||||||
0xBCE9, 0xBCF2,
|
0xBCE9, 0xBCF2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user