
Inline Assembly
3-25
The appropriate constraint for this argument would be
rn
. In example 4
in
Section 3.9.5, “Examples of
asm
Directive”
, the input parameter is
constrained to be either a register or an immediate. Sometimes it is
necessary for two arguments to be in the same register. This requirement
can be described by constraints. The first argument should be described
with whatever constraint is appropriate, and the second argument’s
constraint must be the index of the first argument. For example, the first
argument of the
add
instruction is an output/input argument. You must
list this argument as an
output variable
and an
input
expression
. The constraint of this argument when it appears as an
input expression
should be the index of the argument when it
appears as an
output variable
. In example 3 in
Section 3.9.5,
“Examples of
asm
Directive”
, the output argument and the first argument
illustrate this technique.
3.9.4 Explicitly Clobbered Registers
The syntax for an
explicitly clobbered register
is:
“
register name
”
This entry tells the compiler that the assembly code generated will
clobber the specified register. Thus the generated assembly code may
use the specified register for scratch purposes.
3.9.5 Examples of
asm
Directive
The examples in the subsections below illustrate the usage of the
asm
directive.
3.9.5.1 Example 1
asm(“norm.e %0, %1”:
“=r” (ret) :
“r” (a));
The example shown above has one output argument,
ret
, and one input
expression,
a
. If the variable
ret
is in r0 and the variable
a
is in r4, this
directive produces:
norm.e r0, r4