• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Function calls need to pass parameters and save return addresses. Managing this manually is error-prone. Can we use a dedicated memory structure (stack) with implicit addressing?

Core Idea

Stack Addressing uses the top of the stack as the operand location. Instructions like PUSH and POP operate on the stack top, with the stack pointer (SP) implicitly specifying the address — no explicit address needed in the instruction.

How It Works

  1. Stack pointer (SP) register points to top of stack
  2. PUSH instruction: decrement SP, write data to address in SP
  3. POP instruction: read data from address in SP, increment SP
  4. Example: PUSH AX — pushes AX onto stack; POP BX — pops top of stack into BX
  5. Stack grows downward (typically) or upward, depending on architecture
stack Instr Instruction (PUSH AX) Opcode only! SP Stack Pointer SP: 3000h Instr->SP implicitly uses Stack Stack Memory 3000h: [AX data] 3002h: [old top] SP->Stack writes to

Key Properties

  • No address in instruction (implicit addressing) — instructions are short
  • Used for function calls (saving return address), local variables, expression evaluation
  • Stack pointer automatically updated — easy to use
  • LIFO order: last pushed = first popped

Connections

Edge Cases & Gotchas

  • Stack overflow: pushing too much data exceeds stack size
  • Stack underflow: popping when stack is empty
  • Stack grows toward other memory — must manage stack size carefully