diff --git a/STATUS.md b/STATUS.md index e8871678..de1ef7a8 100644 --- a/STATUS.md +++ b/STATUS.md @@ -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 | diff --git a/c64/basic/math/bb12.div_FAC2_FAC1.s b/c64/basic/math/bb12.div_FAC2_FAC1.s index 77b1d61f..5bbf09d9 100644 --- a/c64/basic/math/bb12.div_FAC2_FAC1.s +++ b/c64/basic/math/bb12.div_FAC2_FAC1.s @@ -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 diff --git a/c64/basic/math/div_FAC1_denorm.s b/c64/basic/math/div_FAC1_denorm.s index 228eb88f..9e8bc371 100644 --- a/c64/basic/math/div_FAC1_denorm.s +++ b/c64/basic/math/div_FAC1_denorm.s @@ -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 diff --git a/c64/basic/math/muldiv_RESHO_helpers.s b/c64/basic/math/muldiv_RESHO_helpers.s index fef81a7b..7f73037f 100644 --- a/c64/basic/math/muldiv_RESHO_helpers.s +++ b/c64/basic/math/muldiv_RESHO_helpers.s @@ -18,6 +18,7 @@ muldiv_RESHO_set_0: rts + muldiv_RESHO_01_add_A: clc