i960 Processor Compiler User's Guide
12-12
12
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
g14 containing a non-zero, but used as a zero constant.
Solution:
When calling any C function from assembly source, always zero
g14 prior
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
#pragma align lets you control the compiler's alignment rules
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,
#pragma align 1 could be added to your code before the
structure definition to remove trailing structure pads and properly match
structure members.
#pragma align 0 could then be added after the
structure definition to return to normal alignment rules, thereby reducing
its impact on the performance of the entire program.