Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] {To TomW} GCC-Bug in IRQs

2006-03-25 by Sten

Robert Adsett wrote:
> At 08:17 PM 3/25/2006 +0100, Sten wrote:
> 
>>Robert Adsett wrote:
>>
>>>Rather than go through all this hand-wringing why not just write an
>>>assembly stub?  You'd know it was correct and you'd be done already.  At
>>>most it would cost you an extra call from the stub to your C
>>>function.  Heck if it was small enough it might make sense to do the whole
>>>thing in asm.  For that matter you could steal one of my stubs.
>>
>>At the moment I declare my IRQ functions as "naked" and write my own 
>>prologue/epilogue with inline
>>assembler. But it is less efficient because I don't know which registers 
>>are really used, so I have
>>to save all non-banked registers (r0..12 for IRQ and r0..r7 for FIQ) which 
>>is a wast of performance.
> 
> 
> 
> If you write a stub that problem disappears. The procedure call standard 
> ensures that the proper registers are saved when you call out of the stub. 
> You only have to save something like 6 registers for IRQ, the called 
> routine preserves any of the others it uses..
> 
> Also are you sure you actually really care about the extra saves?  Beware 
> of premature optimization.  Didn't Knuth call it the root of all evil? 
> :)  If your response time is sufficient and your are not overloading the 
> CPU forget about the wasted cycles, you are spending time doing something 
> that simply does not matter.
> 
> I do a stub not for efficiency but because experience has taught me to 
> never trust any compiler to produce correct interrupt code.  Correct does 
> sometimes mean efficient but it can also mean the more obvious things.
> 
> Robert

Ok, what exactly did you mean by a "stub"? You write a piece of assembler code for a particular IRQ
and then branch to your (normal) C service function, don't you?
I'm thinking of writing a generic IRQ handler instead of a direct branch to VIC-vector register from
vector table, I'm using at the moment. This IRQ handler (in clean assembler) could have correct
entry and exit code and is branching to the service function from VIC-vector. The overhead would be
very less. In this case I can also add some extra code to serve spurious interrupts in any way I
like. (STOP! I DONT WANT TO START A NEW ENDLESS THREAD HERE!)

  Sten

-- 
/************************************************
 Do you need a tiny and efficient real time
 operating system (RTOS) with a preemtive
 multitasking for LPC2000 or AT91SAM7?

   http://nanortos.net-attack.de/

 Or some open-source tools and code for LPC2000?

   http://www.net-attack.de/

************************************************/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.