Hello,
Three years ago I used fltpt65 for my calculator project ; I ported it to the ca65 assembler, fixed some bugs and added a few functions. The archive is named fltpt
C65 which implies it makes some use of the 65C02 instructions - but the "readme" file will tell you more :
Attachment:
fltpt_c65.zip [25.58 KiB]
Downloaded 202 times
"readme" file contents :
-------------------------------------------------------------------------------
fltptC65 - A slightly enhanced fltpt65 (original from C. R. Bond)
2017 - Marc Ferrer
INTRODUCTION :
A few years ago I built a 65C02-based RPN programmable calculator. I used C.R. Bond's floating-point package to which I added a few mathematical functions. (also fixed a few bugs, please see below)
The core arithmetic routines are reliable enough that they've allowed my calculator to perform flawlessly tens of billions of calculations during the last 3 years.
(multi-precision constants computations, pi, e ...)
IMPORTANT NOTES :
- Assembles with ca65 assembler.
- Uses 65C02 instructions.
- Provided as is, no warranty.
- There are surely many improvement paths I didn't look for.
ADDED FUNCTIONS :
pow2 ........ Squares the argument
isint ......... Checks if the argument is an integer
cubrt ........ Cubic root computation
p10ow ...... (10 ** argument) computation
fact .......... Factorial computation (range : 0 to 449)
ncr ........... Combinations computation
npr ........... Permutations computation
hr2hms ...... Decimal hour to Hour/Minute/Second conversion
hms2hr ...... Hour/Minute/Second to decimal hour conversion
p2r ........... Polar to rectangular coordinate conversion
r2p ........... Rectangular to polar coordinate conversion
NOTES :
The last 2 functions use extra F.P. registers (ST_X and ST_Y) which
are not part of the original fltpt65 environment !
Anyway you can easily tailor them to your own project.
The last 7 functions use a new w5 F.P. working register. It should
be possible to optimize them in order to avoid that.
FIXED BUGS :
1) Multiplication (mul) :
- Incorrect results when multiplying 2 numbers with
exponents having same absolute values but opposite signs.
- If w1 = 0 or w2 = 0, we got a result with a computed zero mantissa
but the exponent field isn't set to 0.
2) Arc tangent (atan) :
- Trapped in an endless loop if argument = 0.
3) Integer part (int) :
- If argument exponent = +010, the mantissa's 2nd digit is zeroed
instead of the 12th one.
KNOWN BUGS (to me) :
1) Logarithm (ln) :
- Gives wrong results with arguments of magnitude > 10^10.
-------------------------------------------------------------------------------
Last note not included in the readme file : the cycle counts I mentioned in some comments may be inaccurate. (I recently read about a new version of Michal Kowalski's simulator which has fixed that.)
Hoping it'll be of some use,
Marc