typestar

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

  1. global _start exports the entry point the linker expects.
  2. mov rax, 60 selects sys_exit; rdi carries the status.
  3. xor rdi, rdi zeroes a register in the cheapest encoding.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 3 in First programs, step 1 of 31 in Language basics.

Next →