avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Using a register throughout a program


From: Peter N Lewis
Subject: Re: [avr-gcc-list] Using a register throughout a program
Date: Wed, 19 Sep 2001 08:54:17 +0800

Everything's working alright, but looking at the generated assembler
source, I noticed that my variable 'outcount' is stored in the AVR's SRAM
and loaded each time the signal handler gets called. I would have preferred
to store it in a register, because it's used fairly often.

This should be a FAQ.

the short answer seems to be "there is no easy way".. A more complicated answer appeared recently:

At 11:57 +0800 6/9/01, Lai Kang Tin wrote:
I think you may try to change config/avr/avr.h in gcc source directory,
there are some defines for the usage of register allocation, change
what register(s) you wanted to FIXed purpose, but it seemded that you
must not change some of them such as R24 R25, X,Y,Z,...
Then recompile the GCC.

But in this case, I question the wisdom. What speed is your processor running at and what speed is your serial running at?

Assuming 4MHz processor and 115,200 baud (pretty close to the worst case I can imagine), your interrupt will get executed at roughly 11kHz, or once ever 350 cycles. Is the extra couple cycles to load and store the variable (and extra couple cycles of interrupt latency) really worth worrying about?

Enjoy,
   Peter.

--
Sungroper Solar Car Association <http://www.sungroper.asn.au/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]