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-28 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Don Kinzer" <dkinzer@...> wrote:
> I've posted a simple example available at the link below.
After reviewing the example, it will probably be obvious that the structure offset/size definitions for the assembly language code represent a double maintenance issue - if a structure is changed one must remember to update the offset and size definitions.

In our code base we use a special syntax to define structures that contains special tags that are used by an awk script to automatically generate the structure offset and structure size definitions.  The awk script is run (automatically by make) whenever any of the applicable include files is changed thus ensuring that the offset/size information is always current.  The only remaining issue is code that indexes by a structure's size.  To protect against errors arising from structure size changes (and even differences in structure size on different AVR devices, if applicable), we add preprocessor directives to validate the size and issue a compile error if it is unexpected.  An example of this is in the example code I posted.

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.