Assembly
test.zig
Shell
Dissecting the syntax:
Assembly Syntax Explained
Some day Zig may have its own assembler. This would allow it to integrate more seamlessly into the language, as well as be compatible with the popular NASM syntax. This documentation section will be updated before 1.0.0 is released, with a conclusive statement about the status of AT&T vs Intel/NASM syntax.
Output constraints are still considered to be unstable in Zig, and so and GCC documentation must be used to understand the semantics.
Note that some breaking changes to output constraints are planned with .
Input constraints are still considered to be unstable in Zig, and so LLVM documentation and must be used to understand the semantics.
Clobbers are the set of registers whose values will not be preserved by the execution of the assembly code. These do not include output or input registers. The special clobber value of means that the assembly causes writes to arbitrary undeclared memory locations - not only the memory pointed to by a declared indirect output.
Failure to declare the full set of clobbers for a given inline assembly expression is unchecked Undefined Behavior.
When an assembly expression occurs in a container level block, this is global assembly.
This kind of assembly has different rules than inline assembly. First, is not valid because all global assembly is unconditionally included. Second, there are no inputs, outputs, or clobbers. All global assembly is concatenated verbatim into one long string and assembled together. There are no template substitution rules regarding as there are in inline assembly expressions.
Shell