操作约束修饰符(Constraint Modifier Characters)

操作约束修饰符(Constraint Modifier Characters)

修饰符 #

  1. “=” Means that this operand is written to by this instruction: the previous value is discarded and replaced by new data.
  2. “+” Means that this operand is both read and written by the instruction. “=“和”+“必须是第一个字符的位置。
  3. “&” an earlyclobber operand, which is written before the instruction is finished using the input operands. 只能写在输出约束部分的第二个字符位置上,即只能位于=和 + 之后,它告

诉编译器不得为任何输入操作表达式分配该寄存器。因为编译器会在输入部分赋值前,先对 &符号修饰的寄存器进行赋值,一旦后面的输入操作表达式向该寄存器赋值,将会造成输入和输出数据混乱。

补充说明只有在输入约束中使用过模糊约束(使用q、r或g等约束缩写)时,在输出约束中使用符号&修饰才有意义!如果所有输入操作表达式都明确指派了寄存器,那么输出约束再使用符号 & 就没有任何意义。如果没有使用修饰符 &,那就意味着编译器将先对输入部分进行赋值,当指令部分执行结束后,再对输出部分进行操作。

From #

一个64位操作系统的设计与实现