PIC16F874 Math Routines
Microchip has a library
of fixed-point and floating-point math routines. Two of these
are available here.
-
Fxm68.a16 Multiply a 16-bit number
and an
8-bit number together. This yields a 24-bit result.
-
Fxd68.a16 Divide a 16-bit number by
an 8-bit
number. This yields a 16-bit quotient and an 8-bit remainder
Here are the two "include" files which
must
be used in conjunction with the math routines. They define the
target
device and specify the locations of the registers used by the routines.
Below is an example of a program which
uses
the above two routines. It doesn't do anything much with them but
it does illustrate how to include them in your code. The comments
within it clarify a number of points.
Complete
Documentation for the PIC16 Math Routines (1.6 MBytes). This
documentation is from Microchip
and describes all the routines in the library, not just the two
provided
above. This documentation does not include an example of how to
include
the routines in your own source code, which is why I wrote the example
program above. In addition to explaining what registers are used
by the routines, the documentation discusses the algorithms involved
and
includes the complete source code. However, since the file is in
Portable Document Format (PDF), it's probably easier to get the source
code directly from Microchip rather than extracting it from the PDF
file. The source code is provided in .zip format.