Open main menu

CDOT Wiki β

Changes

Inline Assembly Language

40 bytes added, 15:19, 13 September 2022
Assembler Template
The assembler template is a piece of assembler code that will be pre-processed to fill in register assignments. Registers may be referenced as %0, %1, %2 and so forth, indicating the registers mentioned in the output operands and input operands. For example, if there is one output operand and two input operands, you can refer to the register containing the output operand as <code>%0</code> and the input operands as <code>%1</code> and <code>%2</code>.
Because % is used as a prefix for register numbers(using some assembly language dialects), a double percent-sign must be used to represent a single percent sign in the code. For example, in x86_64 gas assembler, the rax register is written as <code>%rax</code> -- but in a template, it must be written as <code>%%rax</code>.
The template is written as one or more strings enclosed in quotes, with no separator other than whitespace between the strings. Individual statements in the asm code must be separated by semi-colons (;) or explicit newline characters (\n). The sequence \t can be used to indicate a tab character.