Floating point BCD increment?
Posted: Fri Jan 21, 2022 12:25 pm
I've ended up here while googling stuff related to BCD code on the 6502. I've seen a number of bits of code here for efficient processing of BCD, and that made me dream up a concept related to BCD floating point.
I'm trying to improve the loop performance of the infamously slow Atari BASIC, which used BCD FP math with leading excess-64 exponent and then 5 bytes of mantissa. Details here for the interested, page 8-45: https://archive.org/details/ataribooks-de-re-atari
My question:
Atari's OS has a FADD routine that adds two arbitrary FP numbers. In FOR/NEXT loops this is a significant performance hit. I am wondering if this might be improved by having a floating-point increment, FINC, for the 95% of loops that are step 1.
My thought was this: the general purpose FADD knows about things like non-64 exponents and carrying across digits and so forth. But if you're doing an increment you mostly don't need this - if the number has no decimal shift and the least significant byte is < 99 there isn't going to be a carry, so we can just add one to the LSB and exit? If it is 99, then just call FADD.
Is that right? Or am I (likely) missing something obvious here?
I'm trying to improve the loop performance of the infamously slow Atari BASIC, which used BCD FP math with leading excess-64 exponent and then 5 bytes of mantissa. Details here for the interested, page 8-45: https://archive.org/details/ataribooks-de-re-atari
My question:
Atari's OS has a FADD routine that adds two arbitrary FP numbers. In FOR/NEXT loops this is a significant performance hit. I am wondering if this might be improved by having a floating-point increment, FINC, for the 95% of loops that are step 1.
My thought was this: the general purpose FADD knows about things like non-64 exponents and carrying across digits and so forth. But if you're doing an increment you mostly don't need this - if the number has no decimal shift and the least significant byte is < 99 there isn't going to be a carry, so we can just add one to the LSB and exit? If it is 99, then just call FADD.
Is that right? Or am I (likely) missing something obvious here?