ISA and Disassembly Lab
Retrieval Prompts
- State the four phases of the fetch-decode-execute cycle.
- Name the x86_64 System V argument registers in order, and the return register.
- Define caller-saved vs callee-saved and give one example of each on x86_64.
- State the difference between RISC and CISC at the decode stage.
- Describe how
retfinds 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?)
cmovvs a conditional jump
Common Mistake Check
For each statement, identify the error:
- "x86 is CISC, so every x86 instruction is slow."
- "At
-O0the compiler's output shows what the compiler really does." - "
retjumps to the instruction after the most recentcallin the source file." - "Registers are faster than L1 cache because they are cached closer to the core."
- "Function pointers are free to call because a pointer is just an address."
Mini Application
Do all four tasks for each scenario:
- write a C function that fits in 3-10 lines
- compile it in Compiler Explorer (
-O2 -std=c11) for both x86_64 and RISC-V - annotate each instruction with its purpose (prologue, argument move, loop back-edge, epilogue, etc.)
- explain why the two ISAs produced different numbers of instructions
Scenarios:
int abs_val(int x);long sum_array(const long *a, int n);int count_zeros(const int *a, int n);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
mainfunction's prologue and epilogue - each
callinstruction 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.