The AVR family has a reasonably complex register and memory architecture, with:
- Multiple address spaces
- Registers that can be accessed directly and via the memory address space
- Register pairs that are used as memory indexes
- Restrictions on which registers can be loaded directly with constant values
- Some IO ports that appear in both the memory and IO address spaces, but with different addresses in each
- Some IO ports that are only accessible via the memory address space
In addition, the gcc compiler has conventions governing which registers it uses for what purpose, for example:
- Which registers it uses for purposes such as storing temporary values and zero
- Which registers it uses for passing and returning arguments
- Which registers it uses as a stack frame pointer
- Which registers are saved by the caller on entry to a subroutine and which ones have to be saved by the callee
When I'm reading the assembler output of gcc I find it helpful to have a table to remind me which registers are being used for what, and why. The information is not exactly well-explained in the AVR documentation and I've not been able to find all the information in once place on the Internet, so I've drawn up the following quick-reference table to remind me of what goes where:
Click on the image for a PDF copy of the table. I hope you find this useful, corrections and suggestions welcome - please leave a comment below!
Carlinhos Brown is a colossus in Brazilian music, known not only for his solo musical career but also for the founding of Timbalada and for reviving the use of the Timbau, one of the instruments I (try to!) play. As part of this year's carnival in Salvador, Kyle McDonald and Lucas Werthein built him a drum suit, with a series of drum triggers linked up to an Arduino and then via wireless to a PC to allow Carlinhos to trigger drum samples by tapping on the pads on the suits. It's a cool project, see the video below and the project page on Lucas's site for the full details.
The very first version of my wireless-controlled LED system was intended to be used on drums, so the EletroAxé project is based on a similar concept. In my case I built a prototype using a vibration sensor mounted on one of the Alfaias that we play in Juba do Leão, the Maracatu group I'm a member of. It worked fine, but then the folks from the Travelling Light Circus came along with their proposal, and the idea of mounting the strips on drums got shelved. However it would be pretty cool to link up something like that suit to the LED system. and as both are arduino-based, it wouldn't be particularly hard either. I have mad visions of this bunch playing at night, all lit up with radio-synchronised LED strips :-)