Lecture 3: Memory, the Stack, Recursion

Introduction

Memory and addressing modes

Working with arrays

A Program’s Address Space

The Stack (and the Heap)

Stack Frames

How does this work?

Writing Functions

Writing Recursive Functions

  1. Signature
  2. Pseudocode
    unsigned long fact(unsigned long n) {
      if (n < 2) 
        return 1;
      else
        return n * fact(n - 1);
    }
  3. Variable mappings
# n -> %rsi
  1. Skeleton

  2. Body


To be continued…