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:
- A fundamental introduction to x86 assembly programming
- Guide to x86 Assembly, and the same with AT&T syntax
- Say hello to x86_64 Assembly
- GNU Assembler Examples
- Where the top of the stack is on x86
- Stack frame layout on x86-64
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)