virtual machine (x86)

Guide to x86 assembly

threaded code interpreter

eax top of data stack (cached)
esp next of data statck

ecx scratch
edx scratch

ebx top of return stack
esi program counter
edi jump address / scratch

ebp task pointer (multi-tasking)

x86 calling convention

esp, ebp, esi, edi, ebx callee saved
eax, ecx, edx caller saved

stack discipline

cdecl (c api) caller cleans up
stdcall (windows api) callee cleans up

memory layout

4 KB assembly primitives (2.5 KB used)
64 KB free disk space
4 KB dictionary headers
10 KB threaded code

real executable size is 18 KB
22 KB on disk (sections aligned at 4K)

1 MB stack (windows)
288 KB stack (linux)