Update tan_FAC1
This commit is contained in:
1 parent
1383c70ddc
commit
85f921a172
4 files changed
+34
-16
No files matched your search
@@ -53,7 +53,8 @@
|
||||
!addr FORPNT = $49 ; $49-$4A -- NOT IMPLEMENTED --
|
||||
!addr OPPTR = $4B ; $4B-$4C helper variable for expression computation, [!] our usage details are different
|
||||
!addr OPMASK = $4D ; -- NOT IMPLEMENTED --
|
||||
!addr DEFPNT = $4E ; $4E-$4F -- NOT IMPLEMENTED --
|
||||
!addr DEFPNT = $4E ; $4E-$4F
|
||||
!addr TEMPF3 = DEFPNT
|
||||
!addr DSCPNT = $50 ; $50-$52 temporary area fro string handling, [!] our usage might differ
|
||||
!addr FOUR6 = $53 ; size of variable content (float = 5, integer = 2, string descriptor = 3)
|
||||
!addr JMPER = $54 ; $54-$56 -- NOT IMPLEMENTED --
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
;; #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 - tangent of FAC1 in radians
|
||||
;
|
||||
; This is verified to be almost identical to the original Microsoft implementation where it was named TAN.
|
||||
; The difference is the optimization of the jsr to mov_r_FAC1_MEM
|
||||
;
|
||||
; See also:
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 210
|
||||
; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
@@ -18,17 +23,28 @@
|
||||
|
||||
|
||||
tan_FAC1:
|
||||
jsr mov_r_FAC1_TMP1 ; TMP1 = x
|
||||
jsr sin_FAC1 ; FAC1 = sin(x)
|
||||
jsr mov_r_FAC1_TMP2 ; TMP2 = sin(x)
|
||||
lda #TEMPF1
|
||||
ldy #0
|
||||
jsr mov_MEM_FAC1 ; FAC1 = x
|
||||
jsr COS ; FAC1 = cos(x)
|
||||
lda #TEMPF2
|
||||
ldy #0
|
||||
jsr mov_MEM_FAC2 ; FAC2 = sin(x)
|
||||
jmp div_FAC2_FAC1 ; FAC1 = tan(x)
|
||||
|
||||
jsr mov_r_FAC1_TMP1 ; Mov FAC1 into temporary
|
||||
lda #$00
|
||||
sta TANSGN ; Remember whether to negate
|
||||
jsr sin_FAC1 ; Compute the sin
|
||||
ldx #<TEMPF3
|
||||
ldy #>TEMPF3
|
||||
jsr mov_r_FAC1_MEM ; In the original BASIC this does jsr GMOVMF that jmps to mov_r_FAC1_MEM
|
||||
lda #<TEMPF1
|
||||
ldy #>TEMPF1
|
||||
jsr mov_MEM_FAC1 ; Put this memory loc into FAC1
|
||||
lda #$00
|
||||
sta FAC1_sign ; Start off positive
|
||||
lda TANSGN
|
||||
jsr COSC ; Compute cosine
|
||||
lda #<TEMPF3 ; Address of sine value
|
||||
ldy #>TEMPF3
|
||||
GFDIV:
|
||||
jmp div_MEM_FAC1 ; Divide sine by cosine and return
|
||||
COSC:
|
||||
pha
|
||||
jmp SIN1
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user