Toggle Menu

Assembly Tutorial

This will be a basic assembly tutorial focusing on how to assemble the JIT function x86 instructions.

Until the fortunate arrival of that glorious day, I recommend these excellent tutorials:

Notes

Passing arguments

In 64-bit x86 code, you pass the first few parameters in registers.

Exactly which registers you use depends on the CPU arch and how the OS uses it.

On x86-64 Linux the first six parameters go into:

rdi, rsi, rdx, rcx, r8, r9

On Windows x64, the first four parameters go into:

rcx, rdx, r8, r9

On 32-bit x86 systems parameters are passed on the stack.

Function call ABIs

x86-32 Windows uses various ABIs for function calls. Win32 uses “stdcall” as the default, function arguments are passed on the stack in reverse order.

x86-32 Linux can use “stdcall”.

x86-64 Linux uses “System V ABI” for function calls. Pass arguments in registers.

Assembler Tools

Debuggers

  • gdb (Linux)
  • hopper (Mac)