The Elements of Computing Systems: Building a Modern Computer from First Principles by Nisan Noam & Shimon Schocken
Author:Nisan, Noam & Shimon Schocken [Noam, Nisan, & Schocken, Shimon]
Language: eng
Format: epub, pdf
Publisher: The MIT Press
Published: 2005-06-01T05:00:00+00:00
Figure 8.2 Subroutine calling. Elementary commands (like add) and high-level operations (like power) have the same look and feel in terms of argument handling and return values.
Subroutines like power usually use local variables for temporary storage. These local variables must be represented in memory during the subroutine’s lifetime, namely, from the point the subroutine starts executing until a return command is encountered. At this point, the memory space occupied by the subroutine’s local variables can be freed. This scheme is complicated by allowing subroutines to be arbitrarily nested: One subroutine may call another subroutine, which may then call another one, and so on. Further, subroutines should be allowed to call themselves recursively; each recursive call must be executed independently of all the other calls and maintain its own set of local and argument variables. How can we implement this nesting mechanism and the memory management tasks implied by it?
The property that makes this housekeeping task tractable is the hierarchical nature of the call-and-return logic. Although the subroutine calling chain may be arbitrarily deep as well as recursive, at any given point in time only one subroutine executes at the top of the chain, while all the other subroutines down the calling chain are waiting for it to terminate. This Last-In-First-Out (LIFO) processing model lends itself perfectly well to a stack data structure, which is also LIFO. When subroutine xxx calls subroutine yyy, we can push (save) xxx’s world on the stack and branch to execute yyy. When yyy returns, we can pop (reinstate) xxx’s world off the stack, and continue executing xxx as if nothing happened. This execution model is illustrated in figure 8.3.
We use the term frame to refer, conceptually, to the subroutine’s local variables, the arguments on which it operates, its working stack, and the other memory segments that support its operation. In chapter 7, the term stack referred to the working memory that supports operations like pop, push, add, and so on. From now on, when we say stack we mean global stack—the memory area containing the frames of the current subroutine and all the subroutines waiting for it to return. These two stack notions are closely related, since the working stack of the current subroutine is located at the very tip of the global stack.
Download
The Elements of Computing Systems: Building a Modern Computer from First Principles by Nisan Noam & Shimon Schocken.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3935)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3620)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3554)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3387)
TinyML Cookbook by Gian Marco Iodice(3323)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2843)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2604)
Fusion 360 for Makers by Lydia Sloan Cline(2220)
Networking A Beginner's Guide by Bruce Hallberg(2210)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2031)
Computers For Seniors For Dummies by Nancy C. Muir(1997)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1953)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1902)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1861)
MicroPython Projects by Jacob Beningo(1736)
Hands-On Internet of Things with MQTT by Tim Pulver(1708)
