Cypress DCT-1D Betriebsanweisung Seite 66

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 82
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 65
66
CHAPTER 6. LAB TASK 4 - CUSTOM INSTRUCTIONS
: o u t p u t o p e r a n d s
: i n p u t o p e r a n d s
: l i s t o f c l o b b e r e d r e g i s t e r s
) ;
The
asm volatile
keyword instructs the compiler to insert exactly this assembler in-
struction at exactly this position into the compiled code.
The first part of the construct is an assembler template string, e.g.
"l.sd 0x0(%0),%1"
.
The output operands is a comma separated list of output operands, the one you
most probably are going to use is
"=r"(var)
meaning that the output from the assembly
instruction is a write only to a register operation and that the the variable
var
in the C
code is assigned the output value.
The input operand list is a comma separated list of input operands. The format you
most probably are going to use is the
"r"(var_in)
. This means that the variable
var_in
is assigned to a register used in the assembly instruction.
The input and output operands are mapped, by order of appearance, to the
"assem-
bler template"
string. E.g.
"l.or %0,%1,%2" : "=r"(res) : "r"(in_a), "r"(in_b)
will
map the
res
to be the destination (%0),
in_a
source one (%1), and
in_b
source two
(%2).
The list of clobbered registers is a comma separated list of registers that have been
modified by the assembly and not assigned by the compiler with the
%
notation. I.e.
if you have written
asm volatile("l.ori r20,r10,r11") r20
has to be listed as a clobbered
register like this
asm volatile("l.ori r20,r10,r11"::"r20")
. This since the compiler must
be informed if we modify some registers in the inline assembly instruction, otherwise
it will happily assume that the value of a register is the same after the inline assembly
block as it was before the s ection in question.
If you want to write a consecutive block of assembler code this is done as shown
in Listing 6.2.
Listing 6.2: Consecutive block of inline assembler.
asm v o l a t i l e ( "l.instr %0 ,%2,%3" "\n\t"
"l.bnflabel_1" "\n\t"
"l.nop0x0" "\n\t"
"l.movhi %1,%4" "\n\t"
"l.j label_2" "\n\t"
"l.nop0x0" "\n\t"
"label_1 :" "\n\t"
"l.movhi %1,%5" "\n\t"
"label_2 :" "\n\t"
: "=r" ( r e s 1 ) , "=r" ( r e s 2 )
: "r" ( ar g 1 ) , "r" ( a r g 2 ) , "i" ( 0 x1 ) , "i" ( 0 x0 ) ) ;
To omit the
"
\
n
\
t"
is not a syntactic error, but if not used the disassembled object
file will look messed up. We can also see from Listing 6.2 that it is poss ible to use
labels in inline assembler constructs.
For a more detailed description of the gcc in-line assembly see [15]
Seitenansicht 65
1 2 ... 61 62 63 64 65 66 67 68 69 70 71 ... 81 82

Kommentare zu diesen Handbüchern

Keine Kommentare