• inline constraint
  • elect to place an output in the same register as an input if it doesn't need the input value any more
  • Equivalence constraints
    • use the same register for output and for input
  • =(assigned to)
  • r(register)
  • m(memory)
  • o(like m, but offsettable)
  • i(immediate value)
  • g
    • equivalent to rim
  • I
    • immediate values in a certain range
    • For example, a lot of RISC machines allow either a register or a short immediate value.
  • &
    • an output operand is written to before the inputs are read, so this output must not be the same register as any input. Without this, gcc may place an output and an input in the same register even if not required by a "0" constraint.
  • ?
    • in one alternative says that an alternative is discouraged
  • ,
    • separates a list of alternative constraints
asm("add %1,%0" : "=r,rm" (output) : "%g,ri" (input1), "0,0" (input2));

This says that if the output is a register, input1 may be anything, but if the output is memory, the input may only be a register or an immediate value. And input2 must be in the same place as the output, although you can swap things and place input1 there instead.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License