Skip to main content
i++ supports named inline assembly functions on the Linux x86_64 target. The compiler generates assembly and links it with the generated C output.
Assembly is target-specific. The examples on this page are for Linux x86_64; macOS support is being dropped.

Define an assembly function

Use asm, a function signature, a syntax target, and the required text section:
return emits a return instruction. The function returns the value in rax. You can call an assembly function from i++ code like an ordinary function:
Name your assembly parameters in the function signature, then refer to those names inside the block. Keep the assembly function signature consistent with the values you pass from i++.

Target and build pipeline

Use syntax x86_64_linux and section .text for the documented Linux target. The compiler handles assembly generation and linking as part of compilation.
Build the program with:

Constraints

  • Include a text section in each assembly function.
  • Use the return construct instead of writing a raw ret.
  • Do not use raw data directives such as db, dw, or dd; declare data using i++ declarations.
  • Assembly blocks are opaque to compiler analysis. Manage pointers passed into assembly manually.
  • ARM64 and macOS assembly targets are not documented as supported targets.