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

Kris Heidenstrom kris at abbey.co.nz
Thu Jan 25 12:10:24 PST 2007


Richard wrote:

> Kris, there is no interrupt wrapper per se. The compiler checks
> what the register usage is for an interrupt function and only save
> and restore what are used. If you have a test case that shows
> otherwise, then it is a bug. So contact me offlist with the source
> code and I will take a look at it.
>
> If an ISR calls another function, then the compiler will save/
> restore all registers as it wouldn't know what get used in the
> end, but this doesn't sound like your issue.

Sorry, I was not clear. I should have said... my interrupt handler
calls a function. That's all it does. (The function is also called 
from
elsewhere.) So the interrupt handler code itself doesn't destroy
any registers, it is only the called function that does. That's why I
listed the descriptions of the "preserved registers" and "volatile
registers" from the help.

The wrapper doesn't need to preserve the preserved registers,
because the called function will preserve any of them that it uses.
In fact the wrapper doesn't preserve R4~7 for this reason, but
it _does_ preserve R8,9, which are "preserved registers" just like
R4~7.

In my case the called function doesn't use R8,9 at all, but if it did,
it would preserve them (according to the help), because they are
"preserved registers", so the wrapper doesn't need to preserve
them, it just needs to preserve the "volatile registers", R10~15,
as also stated in the help: "If you write a handler in assembly and
if it calls normal C functions, then the assembly handler must
save and restore the volatile registers, since normal C functions
do not preserve them".

My guess is that when the compiler sees that the interrupt handler
is calling a function, it flags a list of registers as "needing to be
preserved by the wrapper", and this list wrongly includes R8,9
as well as (rightly) R10~15.

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