Out-of-line Assembly Code
Motorola
Mixing C and Assembly Language
For More Information On This Product,
Go to: www.freescale.com
5-25
Let’s assume that the coefficients of the above example is desired to be in the program
space when burning the PROM. Then the following C segment
#pragma y_load p:$100
int coeff[5] = {0x19999a, 0x200000, 0x266666, 0x2ccccd,
0x333333};
#pragma y_load
produces the following assembly language code:
global
Fcoeff
org
Fcoeff
dc 1677722
dc 2097152
dc 2516582
dc 2936013
dc 3355443
y:,p:$100
The above assembly code will be loaded into the P memory space at p:$100 for the PROM
burning, and it should be copied to the L memory space before the actual program is
executed. Manipulating the assembler’s run-time and load-time counters requires a
thorough understanding of the underlying assumptions about memory layout, which are
made by the compiler (see Chapter 6).
Note:
Incorrect use of this feature may cause compile-time, link-time and even
run-time errors.
5.4 Out-of-line Assembly Code
Out-of-line assembly code is assembly code written in a separate source file that is called
from a C program. Separating the assembly code and C code in this way provides a
powerful and flexible interface to the DSP56000 family architecture. This out-of-line
method may be used to convert existing assembly subroutines, write new subroutines
completely in assembly language or access both data spaces (X and Y). The key advantage
of out-of-line assembly code is that it provides a complete assembly programming
environment for the DSP56000 family whereas the in-line assembly code must follow the
C programming environment rules.
Writing out-of-line assembly code requires a complete understanding of the C Cross
Compiler and the DSP56000 family architecture. For out-of-line assembly code to be
callable from a C program, the following five basic elements should be included in the
assembly source file in sequence.
F
Freescale Semiconductor, Inc.
n
.