Step Into x64 Assembly · Lesson 11 · Reading Real Code
Reading Compiler Output
What gcc makes of C at -O0 and -O2: frames, spills, lea math, magic division and cmov.
- ~45 minreading and coding
- 4missions
- membersaccess
- x64 Assemblylanguage
Part of Step Into x64 Assembly. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
When you open a Windows binary in a disassembler or debugger, you are reading what MSVC, gcc or clang produced from C or C++. Compilers use a small set of recognizable patterns. Once you know them, a page of disassembly reads like C again.
In this lesson
- Most assembly you read was written by a compiler
- gcc's way of writing memory operands
- -O0: everything goes through memory
- -O2: registers, lea, and no frame
- Common optimized patterns
- Loops at -O2
- This lesson's missions
Missions
- Undo the spills
- Spot the division
- An if without a jump
- Generalize a loop