Yahoo Groups archive

AVR-Chat

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

Message

Re: Mixing C and assembly with special requirements.

2012-03-26 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, fireweaver <firewevr@...> wrote:
> Can I somehow tell the C compiler that comes with AVR
> Studio that these certain five registers are reserved
> for the exclusive use of the decoder and therefore avoid
>  using them in any way?
In general, no.  It is possible to "reserve" any of the registers r2 to r7 but doing so requires great care in constructing your application so that *no other code* uses the reserved registers.  In particular, this means that the register reservation must be specified in every module comprising your application and, further, that you either avoid using any of the AVR-libc routines or confirm that the ones that you do use do not use your chosen reserved registers.  Note, too, that you must perform this confirmation exercise for *every* new release of AVR libc because register allocation may change with each release.

This question has been posed many times on the AVR Freaks forum.  The strategy is generally discouraged because of the potential problems.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

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.