The smallest program in Assembly
Load the exit syscall's number and make the call: five lines.
; The smallest program: set up the exit syscall and make it.
global _start
section .text
_start:
mov rax, 60 ; syscall number for exit
xor rdi, rdi ; status 0, the cheap way
syscall
How it works
global _startexports the entry point the linker expects.mov rax, 60selects sys_exit;rdicarries the status.xor rdi, rdizeroes a register in the cheapest encoding.
Keywords and builtins used here
globalmovraxrdisectionsyscallxor
The run, in numbers
- Lines
- 8
- Characters to type
- 205
- Tokens
- 17
- Three-star pace
- 65 tpm
At the three-star pace of 65 tokens a minute, this run takes about 16 seconds.
Step 1 of 3 in First programs, step 1 of 31 in Language basics.