CS 136 - Week 4
Class 7 - January 27, 2025
In this course, there is 5 sections (or "regions") of memory (RAM):
low
Code
Read-Only Data
Global Data
Heap
Stack
high
Functions and the compiled version of our code lives in code. Sometimes you want read only data/memory (ROM) and that's where it lives. Global Data lives in global variables that are mutable. Heap and stack don't have a set size, and there isn't a boundary between the two - they can dynamically adjust their size. It's BAD if they overlap with each other! Global constants are kept in read-only memory.
Function Calls
- To understand Stack section of memory, we have to revisit how function calls work
- When we call a function:
- The computer stops executing statements within the function that made the call
- The computer jumps to the start of the function that was called
- The computer starts executing statements within the called function
Memory
- Memory is a continuous collection of bytes where each byte (8 bits) has a unique address!
- By convention, memory addresses use hexadecimal (base 16) representation