To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 770
769  |  771
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:
  Re: __attribute__ ((rcx_interrrupt)) : how to use ?
 
(...) Well, i got the definitive answer from Markus 8-). It was in german, so i'll try to translate it: the effect of __attribute__ ((rcx_interrrupt)) depends on the calling context: - in leaf functions (that do not call other functions), it makes (...) (25 years ago, 1-Feb-00, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  __attribute__ ((rcx_interrrupt)) : how to use ?
 
hi there, i´m 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 (...) (25 years ago, 31-Jan-00, to lugnet.robotics.rcx.legos)

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
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR