AsAssembly · Lesson 8 of 10
Calling C Functions from ASM
You don't have to do everything in raw assembly. Linking against libc gives you printf, malloc, file I/O, and the entire C standard library — while your hot paths stay in assembly.
◆ Note
For variadic C functions like `printf`, you must set `rax = number of XMM registers used for floating-point arguments`. If you're not passing floats, `xor eax, eax` is always correct. Forgetting this causes silent crashes or garbage output when printf tries to read FP arguments that don't exist.
For variadic C functions like `printf`, you must set `rax = number of XMM registers used for floating-point arguments`. If you're not passing floats, `xor eax, eax` is always correct. Forgetting this causes silent crashes or garbage output when printf tries to read FP arguments that don't exist.