Note: the test utilities and utilities
for creating floating point
numbers
are in C
Macros:
define all core multibyte functions (1 to N byte size!) to make
building function easy; such as:
-Arithmetic, Logical, Shifts, Compares,
Load (Direct and Constant), Store, Bit Operations, Looping, Increment,
Decrement, Jumps
Macros are also used to invoke all function calls (for readability and
mainly to allow modification of calling methods on various PICs)
32bit math: 32bit integer
functions based on macro headers including Multiply, Divide,
Conversions to/from 8, 16, 24 and 32bit signed/unsigned values
I/O: 32bit BCD: convert up to
32bit
numbers to BCD and output results in ASCII, ATOI convert ASCII to 32bit
Floating point core:
Conversions (IEEE to/from 40bit temporary real) Load/Store ( to/from
IEEE or 40bit temporary real) Arithmetic, Increment, Decrement,
Conversions (to/from 8, 16, 24, 32bit
integers signed/unsigned)
Floating point functions: Poly,
Sqrt, Sin, Cos, Tan, Asin, Acos, Atan, Log, Exp, Pow, Test
(Zero/Nonzero), Split(Real,Integer), Floor, Ceil, LDEXP, FREXP, FMOD,
INVERT(1/X)
I started working on this project back
in 1990. I started with a macro library to make using the PIC easier to
use. I felt that having a generic base of multi-byte functions would
allow making math libraries mush easier to do. I had the floating point
core written in 1991. The project was revisited over the years to
include most of the common C floating point math functions. I had
planned to have the library as part of an interpreter with the higher
level functions and data kept in NVRAM. This has much to do with why
there is no banking code in this project (It would be easy to have this
code and a small interpreter fit inside of 2K code if many of the
functions were moved to NVRAM)
I believe that prior to this project
that PIC assembler support for floating point
functions, and good macro support in general, has been seriously
lacking.
Keep in mind the limited numeric resolution resulting from the number
formats themselves when doing computations! Take a small number, say delta, and add
another number that is larger in magnitude by 2**(bits of precision) -
the delta contribution is lost.. A good example of this problem occurs
when passing two angles near 90 degrees that differ by a small ammont -
if you are depending on measuring small changes in these angles your
results will have large unexpected errors - so take time to
understand this limit and rework your computations as required. No
amount of design given to a mathematical functions can compensate from
being badly used. (But please feel free to fix any bugs you may find in
my code 8-)