Subject:
|
Re: __attribute__ ((rcx_interrrupt)) : how to use ?
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Mon, 31 Jan 2000 21:17:24 GMT
|
Viewed:
|
2440 times
|
| |
| |
In lugnet.robotics.rcx.legos, Martin Cornelius writes:
> hi there, i=B4m still not really sure when and why to use __attribute__
> ((rcx_interrrupt))
>
> my current assumptions:
>
> 1 - it should be used for functions that are called AS interrupt
> handlers, to make sure registers are pushed onto the stack, and restored
> correctly when function returns.
Right. The calling conventions of the H8 say that r0-r3 are scratch registers
(aka caller saves). However, interrupt handlers must preserve ALL of the
registers. So the rcx_interrupt attribute makes that happen.
> 2 - Is it faster to use __attribute__ ((rcx_interrrupt)) instead of
> HANDLER_WRAPPER, and if so, why ?
The compiler will only save the registers it needs to save. Plus
HANDLER_WRAPPER involves another subroutine call.
> 3 - What about functions that are called FROM IRQ-handlers, like
> lnp_integrity_byte(), or dsound_handler(). Under which conditions do
> they have to be declared with the __attribute__ ? -- dsound_handler()
> has it, lnp_integrity_byte() does not.
I think if you go with HANDLER_WRAPPER you can call any function without
worrying about how it preserves registers. If you're using rcx_interrupt you
probably have to use it on any function called in an interrupt context, since
each one will have to preserve the scratch registers they use (because the top
level function may not save them).
I haven't checked that, though.
> 4 - If a function may be called normally or as IRQ-handler, does it harm
> to specify the __attribute__ ?
Extra rcx_interrupt attributes should be harmless, but may slow execution
slightly.
--Ben
|
|
Message has 1 Reply:
Message is in Reply To:
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|