L12 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CME/Energy 211 Margot Gerritsen Shela Aboud Emmet Caulfield
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture Overview • Stacks • Stack-frames/calling conventions • Memory Debuggers • Static Analysis
Background image of page 2
Stack •A stack is an area of computer memory where data is added or removed in a last-in-first-out (LIFO) order. • All stacks have the following two operations: push is an insert operation and places data on the top of the stack pop is a delete operation and takes data off the top of the stack •A stack is a means of allocating and accessing memory. push pop
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Uses of Stacks Stacks are used to handle function calls (parameters are passed and values are returned via a stack) Stacks are also a common data abstraction used in programs and can be created through arrays or linked lists
Background image of page 4
Example – Array Stack PLACEHOLDER – Complete Example given in lecture
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Function Calls:HW4 PLACEHOLDER – Complete Example given in lecture
Background image of page 6
Function Calls:HW4 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 DATA DATA DATA DATA Active Frame Stack Origin Stack Pointer main() m_rand() m_new() srandom() return link to m_new() return link to m_rand() return link to main() AVAILABLE STACK SPACE Inactive Frame •Each stack frame corresponds to a call to a subroutine which has not yet terminated with a return. •Stack pointer is used to
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

L12 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online