3-24
C Cross Compiler
In the table above,
n
is the index of the desired argument in
output
variable
or
input expression
. The three formats—
%
,
%
m
, and
%
o
—
control the way an argument is printed in the generated assembly. For
example, a variable of
long
type that the compiler has placed in r1 and
r0 will be printed as
r0
when the
%
format is specified, as
a
when the
%m
format is specified, or as
r1
when the
%o
format is specified.
3.9.3 Variables and Expressions
The syntax for an
output variable
and
input expression
is:
“
constraint
” (
expression
|
variable
)
A
constraint
is used to describe the requirements that an instruction
places on an argument. For example, an instruction that requires an
argument to be in a particular register would put a constraint on that
argument to ensure that the argument is placed in an allowed register.
In example 3 in
Section 3.9.5, “Examples of
asm
Directive”
, the
acc
variable is constrained to be in an accumulator register. The supported
constraints are shown in
Table 3.12
.
Note that a constant argument can be used with an
r
constraint. The
SDK copies the constant to a register and uses the register as the
argument. You can combine constraints, which can be useful for
instructions that allow different types of arguments. For example, the
shla
instruction can accept either a register or an immediate argument.
Table 3.12
Argument Constraints
Constraint
Effect
Availability
=
output variable
All compilers
r
general-purpose register
All compilers
e
address register
ZDCC
h
index register
ZDCC
c
accumulator register
All compilers
n
constant
All compilers
<n>
same as indexed argument
All compilers