Author Topic: AVR variables and registers  (Read 3046 times)

bioroids

AVR variables and registers
« on: August 17, 2007, 09:01:52 PM »
Hi!

I'm simulating some C code on AVR Studio 4 (still on the PWM phaser stuff). I noticed every variable is residing in a SRAM address, no matter if it is local, global or static. Is there a way I can indicate to the compiler to put a variable into a register instead of RAM? I think that should make the program a lot faster.

Also, is there an equivalent to HIGH() and LOW() functions on this C? Like, to extract the high or low byte of a word, without using the >> and << operators?

I'm running out of juice on the Attiny13 and I still havent implemented the Tap tempo I wanted! 1K memory is just too small!

Regards!

Miguel
Eramos tan pobres!

Dave_B

Re: AVR variables and registers
« Reply #1 on: August 18, 2007, 02:51:46 AM »
There's a post on AVRFreaks that mentions the "register" keyword in the GCC compiler.  Apparently it's not foolproof.

I'm an assembler guy, so I'm just Googling.   :icon_confused:
 
Help build our Wiki!

bioroids

Re: AVR variables and registers
« Reply #2 on: August 19, 2007, 05:09:51 PM »
Thanks for the link Dave!

It seems I managed to reduce my code a 50%, so there's no need to optimize (still  :icon_cool:), or going the ASM way

Regards

Miguel
Eramos tan pobres!