Yahoo Groups archive

AVR-Chat

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

Message

Mixing C and assembly with special requirements.

2012-03-26 by fireweaver

I have a question of some concern to me, perhaps you could help.

In overview, it involves mixing assembly language and C code.

In detail:

The CPU that I am using is ATmega328 using AVR Studio 5 as a development
environment.

I an writing a motor control application that involves a quadrature encoder
attached to the motor shaft and a corresponding decoder with the following
characteristics:

[1] The decoder itself is implemented entirely in assembly language.
[2] All the rest of the application will be written in C.
[3] It maintains a running 24-bit count of the encoder's position.
[4] It will be called by a periodic interrupt at 25 kHz sample rate.
[5] THE DECODER RESERVES FIVE OF THE MACHINE REGISTERS FOR ITS EXCLUSIVE 
USE.
     This is the big deal I want to question you about.

What I want to do is this:  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?

erikc

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.