Yahoo Groups archive

AVR-Chat

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

Message

Claiming global registers in WinAVR / assembly

2007-07-18 by organix80

Hi folks,

I am using AVRStudio with WinAVR, with a mixed C / inline assembly
project. For a specific application, I want to write a very tight and
fast interrupt function in (inline) assembly. 

I am using the 'naked' interrupt attribute and assembly with manually
stack control. The interrupt function must use a existing (global)
variable, calculate something and store it again.

The problem is that the WinAVR compiler uses SRAM locations for this
global variable. This causes a larger compiled code, that uses SRAM
and (Z) pointer instructions. When I should write a 100% assembly
program, it is easy to manually assign dedicated registers that store
this global value, but how to do this in C?

Is it possible to claim registers that not should be used by the C
compiler? so they could be used as a global variable in assembly
functions.

Since the C keyword 'register' is not obligatorily for the compiler,
this seems not to be the right solution.

Has anyone any suggestions?

Thanks in advance.

Laurens

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.