naming cleanup in math routines
This commit is contained in:
1 parent
a2cd07a94c
commit
4673f825af
39 files changed
+127
-125
No files matched your search
@@ -19,5 +19,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
FADDT:
|
||||
add_FAC2_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -14,5 +14,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
LOG:
|
||||
log_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -19,5 +19,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
FMULT:
|
||||
mul_FAC2_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
MUL10:
|
||||
mul10_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -17,5 +17,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
DIV10:
|
||||
div10_FAC1_p:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -19,5 +19,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
FDIVT:
|
||||
div_FAC2_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
SIGN:
|
||||
sgn_FAC1_A:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
SGN:
|
||||
sgn_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
ABS:
|
||||
abs_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
INT:
|
||||
int_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
SQR:
|
||||
sqr_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
SQR2:
|
||||
sqr_FAC2:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -14,5 +14,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
EXP:
|
||||
exp_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -23,5 +23,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
POLY1:
|
||||
poly1_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -23,5 +23,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
POLY2:
|
||||
poly2_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
File renamed without changes.
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
SIN:
|
||||
sin_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
TAN:
|
||||
tan_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
// XXX provide implementation
|
||||
|
||||
ATN:
|
||||
atn_FAC1:
|
||||
STUB_IMPLEMENTATION()
|
||||
@@ -3,7 +3,7 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Math package - add RAM to FAC1
|
||||
// Math package - subtract FAC1 from memory variable
|
||||
//
|
||||
// Input:
|
||||
// - .A - address low byte
|
||||
@@ -15,8 +15,8 @@
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
FADD:
|
||||
sub_MEM_FAC1:
|
||||
|
||||
jsr CONUPK
|
||||
jsr mov_MEM_FAC2
|
||||
|
||||
// FALLTROUGH to FADDT
|
||||
// FALLTROUGH to sub_FAC2_FAC1
|
||||
File renamed without changes.
@@ -5,19 +5,20 @@
|
||||
//
|
||||
// Math package - subtract FAC1 from FAC2
|
||||
//
|
||||
// Input:
|
||||
// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag
|
||||
//
|
||||
// Note:
|
||||
// - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?)
|
||||
//
|
||||
// See also:
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 112
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
// XXX provide implementation
|
||||
// XXX test this
|
||||
|
||||
FSUBT:
|
||||
STUB_IMPLEMENTATION()
|
||||
sub_FAC2_FAC1:
|
||||
|
||||
// Toggle FAC1 sign
|
||||
lda FAC1_sign
|
||||
eor #$FF
|
||||
sta FAC1_sign
|
||||
|
||||
// Perform addition
|
||||
jmp add_FAC2_FAC1
|
||||
@@ -3,7 +3,7 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Math package - subtract FAC1 from RAM
|
||||
// Math package - add memory variable to FAC1
|
||||
//
|
||||
// Input:
|
||||
// - .A - address low byte
|
||||
@@ -15,8 +15,8 @@
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
FSUB:
|
||||
add_MEM_FAC1:
|
||||
|
||||
jsr CONUPK
|
||||
jsr mov_MEM_FAC2
|
||||
|
||||
// FALLTROUGH to FSUBT
|
||||
// FALLTROUGH to add_FAC2_FAC1
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp NORMAL
|
||||
jmp normal_FAC1
|
||||
@@ -18,8 +18,8 @@
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
FMUL:
|
||||
mul_MEM_FAC1:
|
||||
|
||||
jsr CONUPK
|
||||
jsr mov_MEM_FAC2
|
||||
|
||||
// FALLTROUGH to FMULT
|
||||
// FALLTROUGH to mul_FAC2_FAC1
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp CONUPK
|
||||
jmp mov_MEM_FAC2
|
||||
@@ -15,8 +15,8 @@
|
||||
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
|
||||
//
|
||||
|
||||
FDIV:
|
||||
div_MEM_FAC1:
|
||||
|
||||
jsr CONUPK
|
||||
jsr mov_MEM_FAC2
|
||||
|
||||
// FALLTROUGH to FDIVT
|
||||
// FALLTROUGH to div_FAC2_FAC1
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp MOVFM
|
||||
jmp mov_MEM_FAC1
|
||||
@@ -14,9 +14,9 @@
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
//
|
||||
|
||||
MOVAF:
|
||||
movr_FAC1_FAC2:
|
||||
|
||||
// First round FAC1
|
||||
jsr ROUND
|
||||
jsr round_FAC1
|
||||
|
||||
// FALLTROUGH to MOVFA
|
||||
// FALLTROUGH to mov_FAC1_FAC2
|
||||
@@ -0,0 +1,7 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp mov_FAC1_FAC2
|
||||
@@ -1,7 +0,0 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp ROUND
|
||||
@@ -4,4 +4,5 @@
|
||||
|
||||
// Just a compatibility jump - our routine is longer than original one
|
||||
|
||||
jmp MOVFA
|
||||
jmp round_FAC1
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
//
|
||||
|
||||
NEGOP:
|
||||
toggle_sign_FAC1:
|
||||
|
||||
lda FAC1_exponent
|
||||
beq !+ // do not toggle the sign if value is 0
|
||||
@@ -21,7 +21,7 @@
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
//
|
||||
|
||||
MOVFA:
|
||||
mov_FAC1_FAC2:
|
||||
|
||||
// Copy the exponent
|
||||
lda FAC1_exponent
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
// XXX test this
|
||||
|
||||
MOVFM:
|
||||
mov_MEM_FAC1:
|
||||
|
||||
// Checked in the available documentation:
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
@@ -3,7 +3,7 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Math package - fetch FAC2 from RAM location
|
||||
// Math package - fetch FAC2 from memory location
|
||||
//
|
||||
// Input:
|
||||
// - .A - address low byte
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
// XXX test this
|
||||
|
||||
CONUPK:
|
||||
mov_MEM_FAC2:
|
||||
|
||||
// Checked in the available documentation:
|
||||
// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
||||
@@ -13,20 +13,20 @@
|
||||
|
||||
// XXX test this
|
||||
|
||||
NORMAL:
|
||||
normal_FAC1:
|
||||
|
||||
lda FAC1_exponent
|
||||
beq normal_end // branch if our float is 0
|
||||
beq normal_FAC1_end // branch if our float is 0
|
||||
|
||||
lda FAC1_mantissa+3
|
||||
beq normal_by_byte // branch if we can move the whole byte
|
||||
beq normal_FAC1_by_byte // branch if we can move the whole byte
|
||||
|
||||
and #$80
|
||||
bne normal_end // branch if already normalized
|
||||
bne normal_FAC1_end // branch if already normalized
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
normal_by_bit:
|
||||
normal_FAC1_by_bit:
|
||||
|
||||
// First check the current exponent
|
||||
|
||||
@@ -49,10 +49,10 @@ normal_by_bit:
|
||||
rol FAC1_mantissa+1
|
||||
rol FAC1_mantissa+0
|
||||
|
||||
bcc NORMAL // branch if next iteration needed
|
||||
bcc normal_FAC1 // branch if next iteration needed
|
||||
rts
|
||||
|
||||
normal_by_byte:
|
||||
normal_FAC1_by_byte:
|
||||
|
||||
// First decrement the exponent by 8, but not below 0
|
||||
|
||||
@@ -63,7 +63,7 @@ normal_by_byte:
|
||||
lda #$00
|
||||
!:
|
||||
sta FAC1_exponent
|
||||
beq normal_end // branch if our float reached 0
|
||||
beq normal_FAC1_end // branch if our float reached 0
|
||||
|
||||
// Now multiply the mantissa by 8 by moving the whole bytes
|
||||
|
||||
@@ -87,7 +87,7 @@ normal_by_byte:
|
||||
ora FAC1_mantissa+2
|
||||
ora FAC1_mantissa+3
|
||||
|
||||
bne NORMAL // not 0 - branch to next iteration
|
||||
bne normal_FAC1 // not 0 - branch to next iteration
|
||||
|
||||
// Our mantissa reached 0 - mark exponent as 0 and finish
|
||||
|
||||
@@ -95,6 +95,6 @@ normal_by_byte:
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
normal_end:
|
||||
normal_FAC1_end:
|
||||
|
||||
rts
|
||||
@@ -12,15 +12,15 @@
|
||||
|
||||
// XXX test this
|
||||
|
||||
ROUND:
|
||||
round_FAC1:
|
||||
|
||||
// If number is 0, do not do anything
|
||||
|
||||
lda FAC1_exponent
|
||||
beq round_done
|
||||
beq round_FAC1_done
|
||||
|
||||
lda FACOV
|
||||
bpl round_zero_FACOV // branch if it is enough to clear FACOV
|
||||
bpl round_FAC1_zero_FACOV // branch if it is enough to clear FACOV
|
||||
|
||||
// Increment the 4 bytes of matissa
|
||||
|
||||
@@ -28,20 +28,20 @@ ROUND:
|
||||
// we could have used INW on 65C02 and above, the code would have been smaller!
|
||||
|
||||
inc FAC1_mantissa+3
|
||||
bne round_zero_FACOV
|
||||
bne round_FAC1_zero_FACOV
|
||||
inc FAC1_mantissa+2
|
||||
bne round_zero_FACOV
|
||||
bne round_FAC1_zero_FACOV
|
||||
inc FAC1_mantissa+1
|
||||
bne round_zero_FACOV
|
||||
bne round_FAC1_zero_FACOV
|
||||
inc FAC1_mantissa+0
|
||||
bne round_zero_FACOV
|
||||
bne round_FAC1_zero_FACOV
|
||||
|
||||
// If we are here, it means mantissa is 0; put it to minimum allowed and increment exponent
|
||||
|
||||
lda #$80
|
||||
sta FAC1_mantissa+0
|
||||
inc FAC1_exponent
|
||||
bne round_zero_FACOV
|
||||
bne round_FAC1_zero_FACOV
|
||||
|
||||
// If we are here, it means the exponent wrapped around to $00; put it back to $FF
|
||||
|
||||
@@ -49,13 +49,13 @@ ROUND:
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
round_zero_FACOV:
|
||||
round_FAC1_zero_FACOV:
|
||||
|
||||
lda #$00
|
||||
sta FACOV
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
round_done:
|
||||
round_FAC1_done:
|
||||
|
||||
rts
|
||||
Reference in new issue
Block a user