
In-line Assembly Code
Motorola
Mixing C and Assembly Language
For More Information On This Product,
Go to: www.freescale.com
5-7
Example 5-15). In most of cases, the operand is used as both an input and an output
operand (see Example 5-16 and Example 5-17). In these cases the operand should be
described as both. Since output operands should be listed first, the operand id number is
determined when the input operand is declared. The id number will be used as the operand
constraint of the input operand.
Section lists the operand constraints and their related modifiers.
5.2.3 Explicit Register Saving
It is possible to manually perform register allocation, in fact this may simplify the process
of converting an existing body of DSP56000/DSP56001 assembly language subroutines to
in-line assembly code. The programmer need only identify each register explicitly
referenced in the assembly code and list them in the
reg_save
argument region (see
Section 5.2). This guarantees that the content of each register is preserved across
_ _asm()
calls. Use of registers
r0
and
r6
is prohibited in the assembly code because they are
reserved for the C compiler during run-time where
r0
is the frame pointer and
r6
is the
stack pointer. Registers Mn are used by the compiler as temporary registers and Nn are not
used by the C compiler at all. As a result, these registers do not need to be saved unless the
programmer uses them in assembly code. If they are used in assembly code, they should
only be used as local variables.
Explicit register saving is done through specifying the registers to be saved. A string is
used to specify each register. The valid register names are listed in Table 5-2.
Table 5-1. Operand Constraints/Modifiers Associations
Operand Constraint
Modifier
A
-Address Register (
rx
)
%
j
-Rn’s paired offset register
D
-Destination Register (
a
,
b
)
%
e
%
h
%
k
-Upper word (
a1
,
b1
)
-Lower word (
a0
,
b0
)
-Extension (
a2
,
b2
)
R
-Multiplier Register (
x0
,
y0
)
%
g
%
i
-Select other register portion
-Strip 0/1 from register name
S
-Source Register (
x0
,
x1
,
y0
,
y1
)
%
g
%
i
-Select other register portion
-Strip 0/1 from register name
i
-Constant (#number)
%
p
%
q
-16 bit immediate value
- 24 bit immediate value
m
-Memory Location
%
f
-Memory space identifier
number
-Any one of above
%(corresponding modifier
F
Freescale Semiconductor, Inc.
n
.