Skip to main content

ISA and Disassembly Lab

Retrieval Prompts

  1. State the four phases of the fetch-decode-execute cycle.
  2. Name the x86_64 System V argument registers in order, and the return register.
  3. Define caller-saved vs callee-saved and give one example of each on x86_64.
  4. State the difference between RISC and CISC at the decode stage.
  5. Describe how ret finds its target.

Compare and Distinguish

Separate these pairs clearly:

  • ISA (architecture) vs microarchitecture
  • caller-saved vs callee-saved registers
  • direct call vs indirect call
  • signed vs unsigned comparison (which flags? which opcodes?)
  • cmov vs a conditional jump

Common Mistake Check

For each statement, identify the error:

  1. "x86 is CISC, so every x86 instruction is slow."
  2. "At -O0 the compiler's output shows what the compiler really does."
  3. "ret jumps to the instruction after the most recent call in the source file."
  4. "Registers are faster than L1 cache because they are cached closer to the core."
  5. "Function pointers are free to call because a pointer is just an address."

Mini Application

Do all four tasks for each scenario:

  1. write a C function that fits in 3-10 lines
  2. compile it in Compiler Explorer (-O2 -std=c11) for both x86_64 and RISC-V
  3. annotate each instruction with its purpose (prologue, argument move, loop back-edge, epilogue, etc.)
  4. explain why the two ISAs produced different numbers of instructions

Scenarios:

  1. int abs_val(int x);
  2. long sum_array(const long *a, int n);
  3. int count_zeros(const int *a, int n);
  4. struct node { int v; struct node *next; }; int length(struct node *h);

Disassembling a Binary

Given a C source file example.c, run:

gcc -O2 -g -o example example.c
objdump -d -M intel --source example | less

Identify in the output:

  • the main function's prologue and epilogue
  • each call instruction and its target
  • the body of any loops

Write a one-paragraph narration for each function.

Evidence Check

This page is complete only if you can read a 20-line disassembly listing, in a language you have not seen before, and correctly identify the loop body, the branch predicate, and the function prologue.