Module 10: Going Below C
Registers, assembly, hardware
Lessons
| ID | Title | Duration |
|---|---|---|
| 10-1 | How Your Code Runs on Hardware | 30 min |
| 10-2 | Reading and Writing Assembly | 35 min |
| 10-3 | Calling Conventions and the ABI | 25 min |
| 10-4 | volatile, Memory Barriers, and the Compiler | 25 min |
| 10-5 | Performance: Profiling and Cache Awareness | 25 min |
Project
| 10-proj | Project: Coroutine Library | 90 min |
Key Concepts
PDF Status
- PDF ch11 (Going Below C) — Complete (written 2026-04-08).
- Key Concepts: inline assembly (asm volatile, constraints/clobbers, rdtsc example), volatile semantics, System V AMD64 ABI full table, cache hierarchy table (L1/L2/L3/DRAM), reading compiler output (inlining/unrolling/SIMD/spills).
- Going Deeper: ABI contract violations (callee-saved clobber → deferred corruption, struct hidden pointer), volatile vs CPU reordering (correct for MMIO/setjmp/sig_atomic_t; wrong for threads), MESI protocol + false sharing step-by-step + aligned padding fix, compiler output as diagnostic (5 questions to ask).
- Real-World Connection: Linux kernel
arch/x86/include/asm/atomic.h—atomic_add/atomic_cmpxchginline asm,LOCK_PREFIXSMP/UP conditional, four reasons kernel uses inline asm over C11 stdatomic. - Exercises 11.1–11.4 + fully annotated solutions + test files (includes
dot.sABI-conforming assembly).