HC9S12

The following pages are code examples for the Freescale 9S12 microcontroller. The C compiler I use is ICC12. These pages are without copyright or guarantee

32x32 bit divide

The ICC12 library 32-bit by 32-bit divide requires more than 2500 cycles.  It is your typical shift-subtract algorithm that does not make use of the efficiencies of the divide routines in the HC12 instruction set.  The following function executes in 314 cycles or less.  Random tests have run successfully since May 2010.  Note that the arguments of uldiv must point to separate memory locations (ie: uldiv(&a, &b, &a) will cause an error).

32x32 bit multiply

The ICC12 library doesn't supply a 64 bit result for it's long multiply.   This routine is an extension of the existing 32x32 library function and requires the user to define a uint64 type.  For a 9S12 running at 24MHz the function executes in 5.5usec.

Syndicate content