Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] Claiming global registers in WinAVR / assembly

2007-07-18 by larry barello

This is what I used in a project...  I doubt the "register" keyword does
anything useful.

register uint8_t tick asm("r17");
register uint8_t count asm("r16");
register uint8_t aux_pwm asm("r10");
register uint16_t rtc asm("r12");

It makes no sense allocating registers within a routine.  They should only
be allocated on a global basis in all modules.  GCC is smarter than you
allocating and managing register usage within a subroutine.

In general, I wouldn't recommend using them because they hamper GCCs
excellent optimization techniques.  One needs to understand the register
usage of the compiler before mucking around allocating registers...  That
stuff is generally covered in the FAQ that comes with the clib
documentation. I only used them in one very small project and reviewing that
project (I did it two years ago) I can already see a better way of handling
the requirements without using registers...

People get really hung up on the C vs ASM efficiency issue.  Although there
are times when asm really makes sense, for the VAST majority of projects I
find my productivity (functions completed & working) the limiting factor.  I
*rarely* find that the code size or execution speed to be the problem - and
when I do, then I think about how to structure the C code differently - and
when that doesn't work I finally drop into specialized asm.

With asm as the primary code it is impossible (for any significant program)
to "restructure" for speed or size.  With C it is very easy to abstract &
re-factor code to crunch down size or improve speed.

Programming wisdom to live by: Get it working first, optimize later!  

Cheers!

-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of David VanHorn
Sent: Wednesday, July 18, 2007 6:45 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Claiming global registers in WinAVR / assembly

I'm interested to learn how this works out.  This is one thing that's
been keeping me away from using C.


 
Yahoo! Groups Links

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.