Lecture5-ia32-stack - Announcements Exercise 2 due Sep 8...

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

View Full Document Right Arrow Icon
1 CS 3214 Computer Systems Godmar Back Lecture 5 Announcements • Exercise 2 due Sep 8 – Recommend you do this concurrently with project 1, not after • Project 1 due Sep 7 • Should have teamed up now Make sure you’re on piazza Make sure you re on piazza CS 3214 Fall 2011 The following slides are taken with permission from Complete Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective (CS:APP) Randal E. Bryant and David R. O'Hallaron http://csapp.cs.cmu.edu/public/lectures.html PROGRAMS AND DATA Part 4 CS 3214 Fall 2011 Historical Note During my 1959 summer holiday in Paterswolde I had given my first thoughts to the question how to implement recursion: in the early months of 1960 we discovered how, in combination with that, to do justice to the scope rules of Algol 60. The definition of Algol makes extensive use of recursive productions. A run-time system for a language like Algol allowing unrestricted procedure calls has to contain some kind of a stack mechanism. If a subroutine/procedure/ method calls itself recursively it is necessary to store return addresses and local See [ A Brief History Of The Stack ]. One of the great concepts in Computer Science variables in such a way that they are not overwritten when the next call of the subroutine is executed. Correspondingly what has been stored must be made available on return from the previous deeper level. Also, stacks are put to use when dealing with the block structure of Algol 60, where local variables in one block have to be stored while we are working within another one . Finally, because Algol is defined using recursion, we can easily translate the productions into a compiler using recursive procedures. E.W. Dijkstra, ”A programmer’s early memories” in A history of computing in the twentieth century: a collection of essays / edited by N. Metropolis, New York, Academic Press, 1980. CS 3214 Fall 2011 Stack-Based Languages • Languages that Support Recursion – e.g., C, Pascal, Java – Compiler-generated code must be “ Reentrant • Multiple simultaneous instantiations of single procedure – Need some place to store state of each instantiation • Arguments • Local variables Return pointe • Return pointer • Stack Discipline – State for given procedure needed for limited time • From when called to when return – Callee returns before caller does • Stack Allocated in Frames – state for single procedure instantiation CS 3214 Fall 2011 IA32 Stack • Region of memory managed with stack discipline • Grows toward lower addresses Increasing Addresses Stack “Bottom” • Register %esp indicates lowest stack address – address of top element Stack Pointer %esp Stack Grows Down Stack “Top” CS 3214 Fall 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 IA32 Stack Pushing • Pushing pushl Src – Fetch operand at Src – Decrement %esp by 4 – Write operand at Increasing Addresses Stack “Bottom” address given by %esp Stack Grows Down Stack “Top” Stack Pointer %esp -4 CS 3214 Fall 2011 IA32 Stack Popping • Popping popl Dest – Read operand at
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/31/2011 for the course CS 3214 taught by Professor Staff during the Fall '11 term at Virginia Tech.

Page1 / 9

Lecture5-ia32-stack - Announcements Exercise 2 due Sep 8...

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

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