Inline assembly statements (IBM extension)
When the ASM compiler option is in effect, the compiler provides support for embedded assembly code fragments among C and C++ source statements in LE enabled code.
When the METAL or GENASM option is in effect, the compiler provides support for embedded assembly code fragments among C source statements only.
- The qualifier
volatileinstructs the compiler to perform only minimal optimizations on the assembly block. The compiler cannot move any instructions across the implicit fences surrounding the assembly block.
- The code_format_string is the source text of the
asminstructions and is a string literal similar to a
- The output consists of zero, one or more output operands, separated by commas. Each
operand consists of a
constraint(C_expression)pair. The output operand must be constrained by the
+modifier (described below).
- The input consists of zero, one or more input operands,
separated by commas. Each operand consists of a
- clobbers is a comma-separated list of register names enclosed in double quotes. If an
asminstruction updates registers that are not listed in the input or output of the
asmstatement, the registers must be listed as clobbered registers. The following register names are valid :
- r0 to r15
- General purpose registers
- The modifier can be one of the following operators:
- Indicates that the operand is write-only for this instruction. The previous value is discarded and replaced by output data.
- Indicates that the operand is both read and written by the instruction.
- Indicates that the operand may be modified before the instruction
is finished using the input operands; a register that is used as input
should not be reused here. Note: The & modifier is ignored in z/OS® V1R9.
- The constraint is a string literal that describes the kind of operand that is permitted, one character per constraint. The following constraints are supported:
- Use an address register (general purpose register except
- Use a data register that is an arbitrary general purpose register. This constraint is the same as the r constraint.
- Use a general register, memory, or immediate operand.
- Use an immediate integer or string literal operand.
- Use a memory operand supported by the machine.
- Use an immediate integer.
- Use a memory operand that is offsetable.
- Use a general register.
- Use a string literal operand.
- 0, 1, …8, 9
- A matching constraint. Allocate the same register in output as in the corresponding input.
- I, J, K
- Constant values. Fold the expression in the operand and substitute the value into the
- I — an immediate integer of unsigned 8-bit
- J — an immediate integer of unsigned 12-bit
- K — an immediate integer of signed 16-bit
- Use only the parameter constraints listed in this constraint.
XLis an optional prefix, followed by a colon (:), to introduce any of the following parameter constraints:
- Only valid for Metal C programs. Do not generate a definition for the operand defined in the assembly statement; instead, substitute an assembly instruction to define the operand. Optionally, to specify the data size of the operand defined in the assembly statement, use a colon (:) followed by a positive integer. If you do not specify a data size, the size specified in the ASMDATASIZE option is used.
- The operand requires a register pair. Optionally, to specify the
constraint for the register pair, specify a
:, followed by the register_type, optionally followed by another
:and an optional register_pair_flag. The register_pair_flag can be one of the following:
- The operand needs an odd/even register pair.
- The operand needs an even/odd register pair.
r(general purpose register) is used as the default. If you do not specify a register pair flag,
e(even/odd pair) is used as the default.
- Use the named general purpose register. Use a colon (
:) followed by the general purpose register name (see below for acceptable register names).
XLconstraints can be used for both input and output operands, with the exception of DS, which can only be used for output operands.
The C_expression is a C or C++ expression whose value is used as the operand for the
asminstruction. Output operands must be modifiable lvalues. The C_expression must be consistent with the constraint specified on it. For example, if
iis specified, the operand must be an integer constant number.
For more information about ASM and ANSIALIAS options, see ASM and ANSIALIAS options in the z/OS XL C/C++ User's Guide.