floating point division works now

This commit is contained in:
FeralChild64 committed 2020-03-21 16:35:55 +01:00
1 parent 922c881a23
commit a76b3e21b0
4 files changed
+10 -16

No files matched your search

+1 -5
View File
@@ -22,8 +22,6 @@
// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics
//
// XXX test this code
div_FAC2_FAC1:
// 'Pamiętaj, cholero - nie dziel przez zero!' - ancient polish proverb
@@ -44,7 +42,7 @@ div_FAC2_FAC1:
// Subtract the exponents
lda #$62 // correction for bias and FAC2 digits
lda #$A0 // correction for bias and FAC2 digits
sta RESHO+0
lda #$00
sta RESHO+1
@@ -67,9 +65,7 @@ div_FAC2_FAC1:
sta FAC1_exponent
// Divide the mantissas
jsr div_FAC1_denorm
jsr muldiv_RESHO_set_0
jsr div_mantissas
+5 -8
View File
@@ -3,11 +3,9 @@
// #LAYOUT# * * #IGNORE
//
// Math package - denormalize FAC1 mantissa and adapt its exponent accordingly
// Math package - denormalize FAC1 mantissa and adapt its exponent accordingly for division
//
// XXX test this
div_FAC1_denorm:
// Set FACOV to 0, no need for increased precision here
@@ -21,12 +19,12 @@ div_FAC1_denorm:
bne div_FAC1_denorm_by_bit // branch if last byte of mantissa is non-zero
lda FAC1_exponent
cmp #$F8
bcs div_FAC1_denorm_by_bit // branch if not suitable to increment exponent by 8
cmp #$08
bcc div_FAC1_denorm_by_bit // branch if not suitable to increment exponent by 8
// Increment exponent
adc #$08 // Carry already clear
sbc #$08 // Carry already sec
sta FAC1_exponent
// Move mantissa bytes
@@ -49,12 +47,11 @@ div_FAC1_denorm_by_bit:
bne div_FAC1_denorm_done // branch if lowest bit of mantissa is already 1
lda FAC1_exponent
cmp #$FF
beq div_FAC1_denorm_done // branch if not suitable to decrement exponent
// Decrement exponent
inc FAC1_exponent
dec FAC1_exponent
// Move mantissa bits
+1
View File
@@ -18,6 +18,7 @@ muldiv_RESHO_set_0:
rts
muldiv_RESHO_01_add_A:
clc