[Icc-430] V7.05 BETA0 - error in handling of longs in div32u/mod32u?

Kris Heidenstrom kris at abbey.co.nz
Tue Jan 23 20:43:10 PST 2007


Richard wrote


> V7.05
[...]
>     - Interface to the 32 bit internal functions for longs and 
> floating
>       point now use R12/R13 in addition to R14/R15 for argument 
> passing,
>       resulting in smaller and faster code.
[...]

There seems to be a problem with division of longs. I'm not
100% sure of the details, but what I think has happened is this.

The canned code block for div32u (also used by mod32u) has
not been updated to use R12,13 and is still assuming that one
parameter will be passed on the stack. At the end of the canned
code block, the code copies the return address from (SP+0) to
(SP+4), then adds 4 to SP, then returns. This would be right if
there was a 32-bit parameter on the stack, but this parameter is
now passed in registers. As a result, some data further up the
stack is clobbered, and the MCU may or may not return to
somewhere meaningful, depending on the stack usage of the
function that invokes div32u/mod32u. I'm not sure whether
the canned code for div32u/mod32u comes from a library, or is
hard-coded into the compiler, but in either case, I think it needs
to be updated to be compatible with this new calling convention.

Regards

Kris
--
Kris Heidenstrom         Embedded systems designer / programmer
kris at abbey.co.nz         Abbey Systems Ltd - Telemetry Specialists
Wellington NEW ZEALAND   Voice +64-4-385-6611  Fax +64-4-385-6848




More information about the Icc-430 mailing list