QuantumC

Inline Assembly

Back to Home

QuantumC provides inline assembly similar to GCC’s inline asm, but with a simplified syntax.

Signature

void inline(string asm, ...args);

The first argument is an assembly string, for example:

R"(
mov rax, 1
mov rdi, 1
mov rsi, $0r
mov rdx, 13
syscall
)"

Operands are referenced using placeholders with the following syntax:

$<num>[=]<r|m|i|g>

Where:

Output operands always come before input operands.

All arguments after the assembly string, except the final one, are operands referenced by the placeholders. The final argument is the clobber string, which tells the compiler which registers or resources are modified by the assembly.

The following clobber strings are equivalent:

"~{rax}~{rdi}~{rsi}~{rdx}~{memory}"
"~{rax,rdi,rsi,rdx,memory}"