Add poly1 and poly2
This commit is contained in:
1 parent
ba9dd1aff2
commit
306f694181
9 files changed
+84
-35
No files matched your search
@@ -248,8 +248,8 @@ Floating point mathematical routines - not official, but well known and broadly
|
||||
| `$BF7B` | `pwr_FAC2_FAC1` | NOT DONE | |
|
||||
| `$BFB4` | `toggle_sign_FAC1` | DONE | |
|
||||
| `$BFED` | `exp_FAC1` | NOT DONE | |
|
||||
| `$E043` | `poly1_FAC1` | NOT DONE | |
|
||||
| `$E059` | `poly2_FAC1` | NOT DONE | |
|
||||
| `$E043` | `poly1_FAC1` | PARTIAL | not fully tested yet |
|
||||
| `$E059` | `poly2_FAC1` | PARTIAL | not fully tested yet |
|
||||
| `$E097` | `rnd_FAC1` | DONE | |
|
||||
| `$E09A` | `rnd_A` | DONE | |
|
||||
| `$E0BE` | `rnd_generate` | DONE | |
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
!addr FAC1_mantissa = $62 ; $62 - $65
|
||||
!addr FAC1_sign = $66
|
||||
|
||||
!addr SGNFLG = $67 ; -- NOT IMPLEMENTED --
|
||||
!addr SGNFLG = $67 ; Also used as number of terms of series evaluation
|
||||
!addr BITS = $68 ; FAC1 overflow
|
||||
|
||||
!addr __FAC2 = $69 ; $69-$6E floating point accumulator 2 [!] also used for memory move pointers
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Math package - evaluate polynomial with odd and even powers for FAC1 value
|
||||
;
|
||||
; Input:
|
||||
; - .A - table address low byte
|
||||
; - .Y - table address low byte
|
||||
; - table format:
|
||||
; - polynomial degree (8 bit integer)
|
||||
; - oefficients (floats), starting from highest degree, times 1+degree
|
||||
;
|
||||
; Notes:
|
||||
; - uses Horner method
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 207
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
; - https://www.c64-wiki.com/wiki/POLY1
|
||||
;
|
||||
|
||||
; XXX provide implementation
|
||||
|
||||
poly2_FAC1:
|
||||
|
||||
+STUB_IMPLEMENTATION
|
||||
File renamed without changes.
@@ -19,10 +19,14 @@
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 206
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
; - https://www.c64-wiki.com/wiki/POLY1
|
||||
;
|
||||
|
||||
; XXX provide implementation
|
||||
|
||||
poly1_FAC1:
|
||||
|
||||
+STUB_IMPLEMENTATION
|
||||
jsr store_YA_in_ZP ; Store YA in second INDEX pointer
|
||||
jsr mov_r_FAC1_TMP1 ; TMPF1 <- FAC1 (rounds)
|
||||
jsr mov_FAC1_FAC2 ; FAC2 <- FAC1
|
||||
jsr mul_FAC2_FAC1 ; FAC1 <- FAC1 * FAC2 (x^2)
|
||||
jsr poly2_table_in_index2 ; poly2: skip storing YA to ZP
|
||||
ldy #$00 ; FAC1 <- FAC1 * TEMPF1
|
||||
lda #TEMPF1
|
||||
jmp mul_MEM_FAC1
|
||||
File renamed without changes.
@@ -0,0 +1,69 @@
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * BASIC_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
;
|
||||
; Math package - evaluate polynomial with odd and even powers for FAC1 value
|
||||
;
|
||||
; Input:
|
||||
; - .A - table address low byte
|
||||
; - .Y - table address low byte
|
||||
; - FAC1 - value of the independent variable
|
||||
; Outputs: FAC1 holds the calculated value
|
||||
; Clobbers: X, Y, A, FAC2, TEMPF2
|
||||
;
|
||||
; The polynomial table is formatted as:
|
||||
; First one byte represents the degree of the polynomial
|
||||
; Then comes an array of floating point number coefficients starting with the highest degree
|
||||
; Horner's method is used for the calculation.
|
||||
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 207
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
; - https://www.c64-wiki.com/wiki/POLY1
|
||||
;
|
||||
|
||||
|
||||
poly2_FAC1:
|
||||
jsr store_YA_in_ZP
|
||||
|
||||
poly2_table_in_index2: ; Called from poly1
|
||||
ldy #$00 ; FAC1 -> TMPF2
|
||||
ldx #TEMPF2
|
||||
jsr mov_FAC1_MEM
|
||||
|
||||
ldx #$80 ; 0 -> FAC1
|
||||
stx FAC1_exponent
|
||||
|
||||
ldx #0
|
||||
lda (INDEX+2, x) ; degree (degree+1 = num coeffs)
|
||||
sta SGNFLG ; number of terms register
|
||||
inc INDEX+2
|
||||
bcc @1
|
||||
inc INDEX+3
|
||||
|
||||
@1:
|
||||
lda INDEX+2
|
||||
ldy INDEX+3
|
||||
jsr add_MEM_FAC1 ; Add with coefficient
|
||||
ldy #$00
|
||||
lda #TEMPF2
|
||||
jsr mul_MEM_FAC1 ; Multiply with x
|
||||
|
||||
clc ; Add 5 to table pointer
|
||||
lda #$05
|
||||
adc INDEX+2
|
||||
sta INDEX+2
|
||||
bcc @2
|
||||
inc INDEX+3
|
||||
|
||||
@2:
|
||||
dec SGNFLG
|
||||
bpl @1
|
||||
rts
|
||||
|
||||
|
||||
store_YA_in_ZP: ; Used also by poly1
|
||||
sty INDEX+3 ; Store YA in second INDEX pointer
|
||||
sta INDEX+2
|
||||
rts
|
||||
@@ -0,0 +1 @@
|
||||
8 consecutive integers starting from 0. Non-copyrightable
|
||||
@@ -0,0 +1,3 @@
|
||||
STA $24 + LDA $2E $24 = INDEX + 2 and $2E VARTAB+1
|
||||
|
||||
storing and loading from two well known locations in the zero page. Trivial
|
||||
Reference in new issue
Block a user