Module 10: Going Below C

Registers, assembly, hardware

Lessons

IDTitleDuration
10-1How Your Code Runs on Hardware30 min
10-2Reading and Writing Assembly35 min
10-3Calling Conventions and the ABI25 min
10-4volatile, Memory Barriers, and the Compiler25 min
10-5Performance: Profiling and Cache Awareness25 min

Project

| 10-proj | Project: Coroutine Library | 90 min |

Key Concepts

assembly, cache

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.hatomic_add/atomic_cmpxchg inline asm, LOCK_PREFIX SMP/UP conditional, four reasons kernel uses inline asm over C11 stdatomic.
    • Exercises 11.1–11.4 + fully annotated solutions + test files (includes dot.s ABI-conforming assembly).