 |
Simple Inline Assembler Instructions |
The simplest form the asm
keyword is:
asm ("instructions");
where instructions contains one or more assembler instructions
separated by semicolons or newlines.
In TIGCC, all register names must be preceded by a percent sign, to avoid
confusion with C variables named like one of the CPU registers. For example:
asm ("move.l 0xC8,%a0; move.l (%a0,1656),%a0; jsr (%a0)");
Hexadecimal constants must be written according to C syntax
(like 0xC8
), not using the notation $C8
which is
common in various assemblers.
Note that something like
asm ("move.l 0xC8,a0");
will be interpreted quite differently: a0
will be regarded as a C language
variable, not a register! Read the documentation about the GNU Assembler
for more information about the exact syntax and directives which it accepts;
since inline assembler instructions are copied directly into the output of the
compiler, exactly the same features are available.
Newlines as separators are also accepted in instructions, so the following code is valid as well:
asm (" move.l 0xC8,%a0
move.l (%a0,1656),%a0
jsr (%a0)");
See Multi-line Strings for more information.