[Icc-430] Interrupt handler wrapper preserves R8,9

Kris Heidenstrom kris at abbey.co.nz
Tue Jan 23 15:16:57 PST 2007


Jerry Durand wrote:

KH>>I think the descriptions in the help are right and
KH>>up-to-date, and I think the interrupt handler
KH>>wrapper is out-of-date. I wrote my own wrapper
KH>>in assembler, which does not preserve R8 and
KH>>R9, and everything seemed to work OK.
KH>>Am I missing something here?

JD>Not sure if I understand you.  During an interrupt,
JD>you have to save EVERYTHING, since there's no
JD>telling what you were doing when the interrupt
JD>happened.  Also, be really careful about calling
JD> functions from inside an interrupt, many functions
JD>are not re-entrant and if you call them from an
JD>interrupt in the middle of some other routine 
JD>calling them, your program will most probably
JD>do some very strange things.

You don't have to save everything, only the registers
you are going to modify. ICC430 functions preserve
R4~9 (that's why they're called "preserved registers"
in the help) by pushing them at the start and popping
them at the end (if they're used for local variables in
the function), so the interrupt handler wrapper doesn't
need to preserve them, and doing so is wasteful. It
only needs to preserve the registers that will not be
preserved by the called function(s), which are
R10~15 according to the help and according to the
compiler output I've seen.
Thanks for the "reentrancy 101", perhaps I shouldn't
have asked "am I missing something here" :-)
--
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