Merge pull request #104 from rikardn/trans
Add config option for transcendental BASIC functions
This commit is contained in:
35 files changed
+152
No files matched your search
@@ -35,6 +35,7 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \
|
|||||||
src/basic/math \
|
src/basic/math \
|
||||||
src/basic/math_consts \
|
src/basic/math_consts \
|
||||||
src/basic/math_mov \
|
src/basic/math_mov \
|
||||||
|
src/basic/math_trans \
|
||||||
src/basic/memory \
|
src/basic/memory \
|
||||||
src/basic/print \
|
src/basic/print \
|
||||||
src/basic/rom_revision \
|
src/basic/rom_revision \
|
||||||
|
|||||||
@@ -114,6 +114,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND NO
|
;; #CONFIG# COLORS_BRAND NO
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND NO
|
;; #CONFIG# COLORS_BRAND NO
|
||||||
|
|||||||
@@ -105,6 +105,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND YES
|
;; #CONFIG# COLORS_BRAND YES
|
||||||
|
|||||||
@@ -88,6 +88,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Built-in DOS configuration
|
; --- Built-in DOS configuration
|
||||||
|
|
||||||
;; #CONFIG# UNIT_SDCARD 27
|
;; #CONFIG# UNIT_SDCARD 27
|
||||||
|
|||||||
@@ -103,6 +103,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND NO
|
;; #CONFIG# COLORS_BRAND NO
|
||||||
|
|||||||
@@ -103,6 +103,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND NO
|
;; #CONFIG# COLORS_BRAND NO
|
||||||
|
|||||||
@@ -93,6 +93,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND YES
|
;; #CONFIG# COLORS_BRAND YES
|
||||||
|
|||||||
@@ -95,6 +95,11 @@
|
|||||||
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
;; #CONFIG# BCD_SAFE_INTERRUPTS YES
|
||||||
|
|
||||||
|
|
||||||
|
; --- BASIC features
|
||||||
|
|
||||||
|
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS NO
|
||||||
|
|
||||||
|
|
||||||
; --- Eye candy
|
; --- Eye candy
|
||||||
|
|
||||||
;; #CONFIG# COLORS_BRAND YES
|
;; #CONFIG# COLORS_BRAND YES
|
||||||
|
|||||||
File renamed without changes.
@@ -22,6 +22,8 @@
|
|||||||
; 5. Multiply by LOG(2) giving LOG(X)
|
; 5. Multiply by LOG(2) giving LOG(X)
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
log_FAC1:
|
log_FAC1:
|
||||||
lda FAC1_exponent ; Store exponent for later
|
lda FAC1_exponent ; Store exponent for later
|
||||||
@@ -62,3 +64,8 @@ log_FAC1:
|
|||||||
ldy #>const_LOG_2 ; FAC1 <- FAC1 * log(2.0)
|
ldy #>const_LOG_2 ; FAC1 <- FAC1 * log(2.0)
|
||||||
lda #<const_LOG_2
|
lda #<const_LOG_2
|
||||||
jmp mul_MEM_FAC1
|
jmp mul_MEM_FAC1
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -15,8 +15,16 @@
|
|||||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||||
;
|
;
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
sqr_FAC1:
|
sqr_FAC1:
|
||||||
|
|
||||||
jsr mov_FAC1_FAC2
|
jsr mov_FAC1_FAC2
|
||||||
|
|
||||||
; FALLLTROUGH to sqr_FAC2
|
; FALLLTROUGH to sqr_FAC2
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -17,8 +17,16 @@
|
|||||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||||
;
|
;
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
pwr_FAC2_MEM:
|
pwr_FAC2_MEM:
|
||||||
|
|
||||||
jsr mov_MEM_FAC1
|
jsr mov_MEM_FAC1
|
||||||
|
|
||||||
; FALLTROUGH to pwr_FAC2_FAC1
|
; FALLTROUGH to pwr_FAC2_FAC1
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -21,6 +21,9 @@
|
|||||||
; - https://www.c64-wiki.com/wiki/POLY1
|
; - https://www.c64-wiki.com/wiki/POLY1
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly1_FAC1:
|
poly1_FAC1:
|
||||||
jsr store_YA_in_ZP ; Store YA in second INDEX pointer
|
jsr store_YA_in_ZP ; Store YA in second INDEX pointer
|
||||||
jsr mov_r_FAC1_TMP1 ; TMPF1 <- FAC1 (rounds)
|
jsr mov_r_FAC1_TMP1 ; TMPF1 <- FAC1 (rounds)
|
||||||
@@ -30,3 +33,8 @@ poly1_FAC1:
|
|||||||
ldy #$00 ; FAC1 <- FAC1 * TEMPF1
|
ldy #$00 ; FAC1 <- FAC1 * TEMPF1
|
||||||
lda #TEMPF1
|
lda #TEMPF1
|
||||||
jmp mul_MEM_FAC1
|
jmp mul_MEM_FAC1
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -24,6 +24,9 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly2_FAC1:
|
poly2_FAC1:
|
||||||
jsr store_YA_in_ZP
|
jsr store_YA_in_ZP
|
||||||
|
|
||||||
@@ -67,3 +70,8 @@ store_YA_in_ZP: ; Used also by poly1
|
|||||||
sty INDEX+3 ; Store YA in second INDEX pointer
|
sty INDEX+3 ; Store YA in second INDEX pointer
|
||||||
sta INDEX+2
|
sta INDEX+2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
@@ -13,9 +13,18 @@
|
|||||||
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
COS:
|
COS:
|
||||||
ldy #>const_HALF_PI
|
ldy #>const_HALF_PI
|
||||||
lda #<const_HALF_PI
|
lda #<const_HALF_PI
|
||||||
jsr add_MEM_FAC1
|
jsr add_MEM_FAC1
|
||||||
|
|
||||||
; FALLTHROUGH to SIN
|
; FALLTHROUGH to SIN
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
@@ -12,6 +12,8 @@
|
|||||||
; - https://www.c64-wiki.com/wiki/SIN
|
; - https://www.c64-wiki.com/wiki/SIN
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
sin_FAC1:
|
sin_FAC1:
|
||||||
|
|
||||||
@@ -53,3 +55,8 @@ sin_next:
|
|||||||
ldy #>poly_sin
|
ldy #>poly_sin
|
||||||
lda #<poly_sin
|
lda #<poly_sin
|
||||||
jmp poly1_FAC1
|
jmp poly1_FAC1
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
; tan(x) = sin(x) / cos(x)
|
; tan(x) = sin(x) / cos(x)
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
tan_FAC1:
|
tan_FAC1:
|
||||||
jsr mov_r_FAC1_TMP1 ; TMP1 = x
|
jsr mov_r_FAC1_TMP1 ; TMP1 = x
|
||||||
jsr sin_FAC1 ; FAC1 = sin(x)
|
jsr sin_FAC1 ; FAC1 = sin(x)
|
||||||
@@ -25,3 +29,8 @@ tan_FAC1:
|
|||||||
ldy #0
|
ldy #0
|
||||||
jsr mov_MEM_FAC2 ; FAC2 = sin(x)
|
jsr mov_MEM_FAC2 ; FAC2 = sin(x)
|
||||||
jmp div_FAC2_FAC1 ; FAC1 = tan(x)
|
jmp div_FAC2_FAC1 ; FAC1 = tan(x)
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
; 5. Adjust sign of result and offset with pi/2 if needed as per above
|
; 5. Adjust sign of result and offset with pi/2 if needed as per above
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
atn_FAC1:
|
atn_FAC1:
|
||||||
lda FAC1_sign ; Save sign of FAC1 on the stack
|
lda FAC1_sign ; Save sign of FAC1 on the stack
|
||||||
pha
|
pha
|
||||||
@@ -55,3 +58,8 @@ atn_skipoffset:
|
|||||||
|
|
||||||
atn_out:
|
atn_out:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
; Polynomial for the atn function
|
; Polynomial for the atn function
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly_atn:
|
poly_atn:
|
||||||
|
|
||||||
!byte $0B ; series length - 1
|
!byte $0B ; series length - 1
|
||||||
@@ -21,3 +25,6 @@ poly_atn:
|
|||||||
+PUT_CONST_POLY_ATN_10
|
+PUT_CONST_POLY_ATN_10
|
||||||
+PUT_CONST_POLY_ATN_11
|
+PUT_CONST_POLY_ATN_11
|
||||||
+PUT_CONST_POLY_ATN_12
|
+PUT_CONST_POLY_ATN_12
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
; Polynomial for the exponential function
|
; Polynomial for the exponential function
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly_exp:
|
poly_exp:
|
||||||
|
|
||||||
!byte $07 ; series length - 1
|
!byte $07 ; series length - 1
|
||||||
@@ -17,3 +21,6 @@ poly_exp:
|
|||||||
+PUT_CONST_POLY_EXP_6
|
+PUT_CONST_POLY_EXP_6
|
||||||
+PUT_CONST_POLY_EXP_7
|
+PUT_CONST_POLY_EXP_7
|
||||||
+PUT_CONST_POLY_EXP_8
|
+PUT_CONST_POLY_EXP_8
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
; Polynomial for the logarithm function
|
; Polynomial for the logarithm function
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly_log:
|
poly_log:
|
||||||
|
|
||||||
!byte $03 ; series length - 1
|
!byte $03 ; series length - 1
|
||||||
@@ -13,3 +17,6 @@ poly_log:
|
|||||||
+PUT_CONST_POLY_LOG_2
|
+PUT_CONST_POLY_LOG_2
|
||||||
+PUT_CONST_POLY_LOG_3
|
+PUT_CONST_POLY_LOG_3
|
||||||
+PUT_CONST_POLY_LOG_4
|
+PUT_CONST_POLY_LOG_4
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
; Polynomial for the sine function
|
; Polynomial for the sine function
|
||||||
|
|
||||||
|
|
||||||
|
!ifdef CONFIG_TRANSCENDENTAL_FUNCTIONS {
|
||||||
|
|
||||||
|
|
||||||
poly_sin:
|
poly_sin:
|
||||||
|
|
||||||
!byte $05 ; series length - 1
|
!byte $05 ; series length - 1
|
||||||
@@ -21,3 +24,6 @@ poly_sin:
|
|||||||
; Constant 0.75 needed for sine calculation
|
; Constant 0.75 needed for sine calculation
|
||||||
sin_three_quarters:
|
sin_three_quarters:
|
||||||
!byte $80, $40, $00, $00, $00
|
!byte $80, $40, $00, $00, $00
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$A3 + BCC $03 + JMP fragment
|
||||||
|
|
||||||
|
Fragments
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$A6 + LDA #$01 + BIT fragment
|
||||||
|
|
||||||
|
Fragments
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$B0 + LDA #$00 + STA fragment
|
||||||
|
|
||||||
|
Fragments
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$E0 + LDA #$00 + JSR fragment
|
||||||
|
|
||||||
|
Fragments
|
||||||
Reference in new issue
Block a user