[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] interrupt optimization
From: |
Paulo Marques |
Subject: |
Re: [avr-gcc-list] interrupt optimization |
Date: |
Thu, 02 Feb 2006 12:37:53 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050716) |
David VanHorn wrote:
What's the way to go in this situation? I thought of using a naked ISR and
adding the necessary push by inline asm but what if I later change my code
and the compiler use different registers? I'm afraid to end up with broken
code.
[...]
Second, it dosen't matter what the compiler is doing, an ASM coded int
needs to save SREG, and any regs you modify during the int, and that's all.
Not really. This is a very common problem and the compiler could be
smarter about it.
Basically the function should be compiled as:
push just the registers needed to decrement "sampling"
decrement sampling
if not zero goto exit:
push the extra registers needed in the function
call the function
pop the extra registers
exit:
pop just the registers needed to decrement "sampling"
The problem is that the compiler pushes all the registers regardless of
the code path. This is understandable, but it _could_ be better.
One thing that might work (but I never tried it) is to code the sampling
decrement in assembly in a "naked" interrupt handler and mark the other
function as "interrupt" so that it pushes everything.
Then, to call the function, just do in assembly:
in __tmp_reg__, SREG
push __tmp_reg__
call _not_inline_function_
The __tmp_reg__ (SREG) push is made to match the IRET instruction from
the now "interrupt" function.
This is still a little inneficient as some registers will be pushed
twice, but is only inneficient when the function is actually called and
not in all interrupt calls.
I hope this helps,
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
Pointy-Haired Boss: I don't see anything that could stand in our way.
Dilbert: Sanity? Reality? The laws of physics?
RE: [avr-gcc-list] interrupt optimization, Nigel Winterbottom, 2006/02/01
Re: [avr-gcc-list] interrupt optimization, Joerg Wunsch, 2006/02/01
Re: [avr-gcc-list] interrupt optimization, David Brown, 2006/02/02