Yahoo Groups archive

Lpc2000

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

Message

Re: {To TomW} GCC-Bug in IRQs

2006-03-26 by roger_lynx

--- In lpc2000@yahoogroups.com, Sten <list@...> wrote:
>
> Robert Adsett wrote:
> > At 07:49 PM 3/25/2006 +0100, Sten wrote:
> > 
> >>I've tried this. But entry/exit is still not correct.
> >>Here's the result:
> >>
> >>void uart_irqHandler0(void) __attribute__((interrupt));
> >>
> >>00000204 <uart_irqHandler0>:
> >> 204:   e24ee004        sub     lr, lr, #4      ; 0x4
> >> 208:   e92d500f        stmdb   sp!, {r0, r1, r2, r3, ip, lr}
> >> 20c:   e3a0120e        mov     r1, #-536870912 ; 0xe0000000
> >> 210:   e2811903        add     r1, r1, #49152  ; 0xc000
> >> 214:   e3a00000        mov     r0, #0  ; 0x0
> >> 218:   ebfffffe        bl      d0 <uart_irqHandler_common>
> >> 21c:   e8bd500f        ldmia   sp!, {r0, r1, r2, r3, ip, lr}
> >> 220:   e25ef004        subs    pc, lr, #4      ; 0x4
> >>
> >>Question:
> >>Which gcc version do you use? Which command line parameters do use?
> >>How do you differentiate between IRQ and FIQ (only r0..r7 need to be 
> >>saved) if use
> >>__attribute__((interrupt)) only?
> > 
> > 
> > 
> > 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.
> > 
> > Robert
> > 
> 
> Thanks Robert.
> 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.


Yes. IRQ "undressed" and inline assembly for prologue/epilogue.

I was curious about the performance hit myself, but rather
than doing it academic-like way (in days), I measured it (in 10 minutes). 
The test is lousy,since the execution of logic analyzer markers skews
the measurement, but comparing:


1. stmia sp, {r0-r11} // 12 regs took 435 ns
2. stmia sp, {r0-r3}  // 4 regs took 305 ns
3. stmia sp, {r0}     // 1 reg took 255 ns


on LPC 2148, pclk=clck=60 MHz
LA's sampling rate; f=200 MHz.


we get some idea; with systematic error factored in,
it doesn't make such a big difference to save 12 or 4 regs.


Roger

> 
>   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.