Re: GCC inline assembly




appreciated.
Thanks,
Mr Linux Guy


http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s4

5. Extended Asm.

In basic inline assembly, we had only instructions. In extended
assembly, we can also specify the operands. It allows us to specify the
input registers, output registers and a list of clobbered registers. It
is not mandatory to specify the registers to use, we can leave that
head ache to GCC and that probably fit into GCC's optimization scheme
better. Anyway the basic format is:

asm ( assembler template
: output operands /* optional */
: input operands /* optional */
: list of clobbered registers /* optional */
);

The assembler template consists of assembly instructions. Each operand
is described by an operand-constraint string followed by the C
expression in parentheses. A colon separates the assembler template
from the first output operand and another separates the last output
operand from the first input, if any. Commas separate the operands
within each group. The total number of operands is limited to ten or to
the maximum number of operands in any instruction pattern in the
machine description, whichever is greater.

If there are no output operands but there are input operands, you must
place two consecutive colons surrounding the place where the output
operands would go.

Example:

asm ("cld\n\t"
"rep\n\t"
"stosl"
: /* no output registers */
: "c" (count), "a" (fill_value), "D" (dest)
: "%ecx", "%edi"
);

see above link

regards
claudio daffra

.



Relevant Pages

  • Re: Question regarding "HLA" and its validity.
    ... > no particular directionality at all but that of context)...if you're ... At least, in an assembler, you consistently get one directionality - I don't ... actual machine encoding, which creates great confusion ... really care about the order of the operands, but that I *HATED* it if the ...
    (alt.lang.asm)
  • Re: AT&T or Intel syntax ?
    ... but relative ease of writing an assembler for the AT&T syntax ... of operands) is pretty much a fact while debates over which is the ... It is no harder to write an assembler with the "Intel" order than the ...
    (comp.lang.asm.x86)
  • Re: RosAsm Syntax
    ... An assembler has no ... > eax = eax / ecx ... > If you put the size information into the operands ... > different instructions. ...
    (alt.lang.asm)
  • Re: RosAsm Syntax
    ... >assembler has no problem to accept ... > eax = eax / ecx ... >If you put the size information into the operands (as most ... >three different names for the different instructions. ...
    (alt.lang.asm)
  • Re: RosAsm Syntax
    ... assembler has no problem to accept ... eax = eax / ecx ... If you put the size information into the operands (as most ... three different names for the different instructions. ...
    (alt.lang.asm)