core Estimated learning time: 12 h

EC-10.2 From C to Assembly and Back

You can read the assembly a compiler produced for a small function, find the loop, the conditional and the call in it, draw the stack frame, and explain why an optimising compiler is allowed to change what you wrote.

Before:S5-2. Computer Architecture and MicroprocessorsUnlocks:S5-3. Digital Signal Processing

Reading compiler output is the cheapest way to make the hardware and software boundary concrete, and it is a skill that keeps paying: it is how performance questions get settled, how a startup failure on a new board gets diagnosed, and how the idea of undefined behaviour stops being an abstraction. No assembly is written here, only read.

Work through these

  • Reading the assembly your compiler produced

    Every toolchain can be asked to show the assembly rather than the finished binary. Comparing a five-line function with its output is the fastest way to learn what the machine is actually asked to do.

    NPTEL: Computer Architecture and Organization (IIT Kharagpur) · Course
  • A loop, a conditional and a function call in machine terms

    A loop is a comparison and a jump backwards, a conditional is a comparison and a jump forwards, and a call saves a return address before jumping. Three patterns account for most of what you will read.

    NPTEL: Computer Architecture and Organization (IIT Kharagpur) · Course
  • The stack frame, laid out

    Each active call owns a region of the stack holding its return address, saved registers and local variables. Drawing the frame for a nested call is what makes recursion and stack overflow concrete rather than mysterious.

    NPTEL: ARM Based Development (IIT Madras) · Course
  • Pointers and arrays as addresses and offsets

    An array index becomes an address plus an offset scaled by the element size, and a pointer is that address held in a register. Seeing the arithmetic explains why the two forms compile to the same instructions.

    NPTEL: Computer Architecture and Organization (IIT Kharagpur) · Course
  • What optimisation does to your source

    A compiler may remove variables, reorder work, unroll a loop or delete a whole calculation whose result is unused. The output need not resemble your source, only produce the same observable behaviour.

    NPTEL: Computer Architecture (IIT Delhi) · Course
  • Undefined behaviour, seen from below

    When a program does something the language does not define, the compiler is entitled to assume it never happens and optimise on that basis. The resulting code often deletes the check you thought would save you.

    NPTEL: Computer Architecture (IIT Delhi) · Course

Sign in to keep your progress.

Free resources

Links last checked 3 Sept 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.