#Use whatever calling conventions are convenient
Use whatever calling conventions are convenient
System V x86 uses the stack and System V x86-64 uses rdi
, rsi
, rdx
, rcx
, etc. for input parameters, and rax
as the return value, but it is perfectly reasonable to use your own calling convention. __fastcall uses ecx
and edx
as input parameters, and other compilers/OSes use their own conventions. Use the stack and whatever registers as input/output when convenient.
Example: The repetitive byte counter, using a clever calling convention for a 1 byte solution.
Meta: Writing input to registers, Writing output to registers
Other resources: Agner Fog's notes on calling conventions