floating point division works now
This commit is contained in:
1 parent
922c881a23
commit
a76b3e21b0
4 files changed
+10
-16
No files matched your search
@@ -203,9 +203,9 @@ Floating point mathematical routines - not official, but well known and broadly
|
||||
| `$BA8C` | `mov_MEM_FAC2` | DONE | |
|
||||
| `$BA90` | `get_FAC2_via_INDEX` | NOT DONE | |
|
||||
| `$BAE2` | `mul10_FAC1` | DONE | |
|
||||
| `$BAFE` | `div10_FAC1_p` | PARTIAL | needs `div_FAC2_FAC1` |
|
||||
| `$BB0F` | `div_MEM_FAC1` | PARTIAL | needs `div_FAC2_FAC1` |
|
||||
| `$BB12` | `div_FAC2_FAC1` | PARTIAL | not tested yet |
|
||||
| `$BAFE` | `div10_FAC1_p` | DONE | |
|
||||
| `$BB0F` | `div_MEM_FAC1` | DONE | |
|
||||
| `$BB12` | `div_FAC2_FAC1` | DONE | |
|
||||
| `$BBA2` | `mov_MEM_FAC1` | DONE | |
|
||||
| `$BBA6` | `get_FAC2_via_INDEX` | NOT DONE | |
|
||||
| `$BBC7` | `mov_r_FAC1_TMP2` | PARTIAL | not fully tested yet |
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ muldiv_RESHO_set_0:
|
||||
|
||||
rts
|
||||
|
||||
|
||||
muldiv_RESHO_01_add_A:
|
||||
|
||||
clc
|
||||
|
||||
Reference in new issue
Block a user