Download presentation
Presentation is loading. Please wait.
1
Yung-Hsiang Lu Purdue University
Stack Memory 3 Yung-Hsiang Lu Purdue University
2
Stack Memory may store three things:
return location arguments local variables
3
Memory is "address-value" pairs
Memory is organized into rows. Each row has an address and stores a value. The addresses are always distinct. You can think of the addresses in memory as home addresses and the values are the names of the families living at that address Address Value 001 C Language 002 Year 2016 003 5 004 36.97 Taylor Smith Johnson
4
Some Rules about Addresses
Addresses are assigned by operating systems Two different pieces of information have different addresses, guaranteed by operating systems A programmer has no control of the address given by the operating system "Zero" is never a valid address. C programs has a special symbol (NULL) for this address.
5
Value Address Frame of f3 106 z = 3.2 105 y = 7 104 VA 102 103 line 5
void f1(int x) 2 { 3 int a; 4 a = f3(7, 3.2); 5 ... 6 7 } 8 int f3(int y, double z) 9 10 11 return ... Frame of f3 106 z = 3.2 105 y = 7 104 VA 102 103 line 5 Frame of f1 102 a = 101 x = 100 line ?
6
Memory Organization Frame Symbol Address Value f3 z 106 3.2 y 105 7 VA
void f1(int x) 2 { 3 int a; 4 a = f3(7, 3.2); 5 ... 6 7 } 8 int f3(int y, double z) 9 10 11 return ... Frame Symbol Address Value f3 z 106 3.2 y 105 7 VA 104 102 RL 103 line 5 f1 a x 101 100 line ? RL: return location VA: value address
7
Frames and Symbols for Humans Computers Know Only Addresses and Values
8
Memory Organization Frame Symbol Address Value f3 z 106 3.2 y 105 7 VA
For Humans 1 void f1(int x) 2 { 3 int a; 4 a = f3(7, 3.2); 5 ... 6 7 } 8 int f3(int y, double z) 9 10 11 return ... Frame Symbol Address Value f3 z 106 3.2 y 105 7 VA 104 102 RL 103 line 5 f1 a x 101 100 line ? RL: return location VA: value address
9
Stack Memory may store three things:
return locations arguments local variables value addresses
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.