Recap: Clean Exit
Part of the Fundamentals section of Coddy's Assembly journey. Lesson 34 of 45.
You have learned about syscalls, the exit syscall, and exit codes. Now you will put everything together to write your first complete working program.
A complete program needs:
| Component | What it does |
|---|---|
section .text | Where your code goes |
global _start | Tells the linker where the program starts |
_start: | The label where execution begins |
| Exit syscall | Ends the program cleanly |
What makes a valid program:
Your program must have all of the above. The exit syscall uses mov rax, 60, sets rdi to an exit code, and calls syscall.
Why this matters:
You have moved from writing individual instructions to writing complete programs. Every program you write from now on will follow this same structure.
Challenge
Write a complete assembly program that exits with exit code 0 (success). Use the standard structure: section .text, global _start, _start:, and the exit syscall.
Try it yourself
; TODO: Write a complete program that exits with exit code 0
; Use section .text, global _start, _start:, and the exit syscall
All lessons in Fundamentals
1The Machine
What is CPUMemoryRegisters vs MemoryHow instructions workTwo-File PatternThe x86-64 ArchitecturePractice on your own: Assembly playground