Assembly Language & Computer Architecture
Prev: bit-hacks Next: c-to-assembly
There are 4 stages to turn source code into a binary:
- Preprocessing (
clang -E main.i)
). This expands macros. - Compiling (
clang -S main.s)
). This turns code into assembly. - Assembling (
clang -c main.o
). This turns code into objects. - Linking: (
ld main
). This creates the main executable.
- Machine code with debug symbols (
-g
) allows you to produce a disassembly of the code.
Why look at assembly?
- The compiler made an error - sometimes bugs show up only at higher optimization levels.
- reverse engineering.
Your computer’s instruction set architecture (ISA) has four main concepts:
- Registers
- Instructions
- Data Types
- Memory Addressing
Prev: bit-hacks Next: c-to-assembly