Inline Assembly Syntax
The inline assembler has the following
syntax:
_asm_<asm-qualifiers>
(
"assembly_instructions_string"
:"output_operand_list"
:"input_opearand_list"
:"clobbered_resource_list"
);| Syntax | Description |
|---|---|
| _asm_ | Indicates the start of the inline assembly block. |
| asm-qualifiers | Optional qualifiers that you can use to specify various attributes of the inline assembly, such as constraints, options, or flags, e.g., _volatile_ |
| "assembly_instructions_string" | Specify the actual assembly code as a string separated by /n. Each
operation can be a valid assembler instruction, or a data definition
assembler directive prefixed by an optional label. There can be no
whitespace before the label, and it must be followed by ":". For example:
Note:
|
| :"output_operand_list" | Defines the output operands of the assembly code. Output operands are
used to pass values from the assembly code back to the C/C++
code. They are specified as a comma-separated list. The
"output_operand_list" typically consists of variables or registers
where the results of the assembly instructions will be
stored. |
| :"input_operand_list" | Defines the input operands of the assembly code. Input operands are used to pass values from the C/C++ code to the assembly code. Like the output operands, the "input_operand_list" is a comma-separated list of variables or registers used as inputs to the assembly instructions. |
| :"clobbered_resource_list" | Specifies clobbered resources, which are registers or memory locations that may be modified by the assembly code but are not explicitly listed as input or output operands. The "clobbered_resource_list" is also a comma-separated list, and it informs the compiler that is should not rely on the values of these resources after the inline assembly block. This is an optional part, and if there are no clobbered resources, it can be left empty. |