Preventing Structure Padding - Intel i960 User Manual

Processor compiler
Hide thumbs Also See for i960:
Table of Contents

Advertisement

12
i960 Processor Compiler User's Guide
as a zero constant. If your application happens to be interrupted with
g14
containing a non-zero value, then your C interrupt service routine is called
with
containing a non-zero, but used as a zero constant.
g14
Solution:
When calling any C function from assembly source, always zero
prior
g14
to the function call. Also, be sure to save all global registers prior to
calling your C function, and restore those registers prior to returning from
the interrupted state.

Preventing Structure Padding

You may be using an i960 processor to communicate with another
processor. The communication involves passing structures between the
two processors. The Intel compiler pads the structures, but the compiler
for your other processor does not, causing passed structure members to
contain incorrect values. It is necessary to prevent the Intel compiler from
padding your structures and unions.
Problem:
The Intel compiler uses fairly strict data-type alignment rules, which take
advantage of the i960 processor features supporting memory references.
This increases the performance of programs running on the i960
processor, but makes it more difficult to interface through structs/unions to
other processor types or to read binary data from a file.
Solution:
gcc960's
lets you control the compiler's alignment rules
#pragma align
for aggregate data types on a per-definition basis, and therefore control the
padding added to the end of structures and unions.
In this case,
could be added to your code before the
#pragma align 1
structure definition to remove trailing structure pads and properly match
structure members.
could then be added after the
#pragma align 0
structure definition to return to normal alignment rules, thereby reducing
its impact on the performance of the entire program.
12-12

Advertisement

Table of Contents
loading

Table of Contents