Lecture 17 - Th The University of Texas at Dallas Erik Jonsson School of Engineering and Computer Science Procedures Why are common procedures or

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

View Full Document Right Arrow Icon
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Procedures Why are common procedures or subroutines desirable? oday groups (sometimes large groups) of programmers work 1. Today, groups (sometimes large groups) of programmers work together to produce software (e.g., Windows Vista). 2. Common functions or capabilities are often required by ultiple software subsystems or modules multiple software subsystems or modules. 3. Rather than have each module duplicate redundant functions, common modules are created that can be called when needed y any module or subsystem by any module or subsystem. 4. Such reusable modules are common in a large program. 5. The reuse requirement means that these modules must be refully written © N. B. Dodge 09/09 Lecture #17: Procedures and Use of the Stack 1 carefully written.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Procedures (2) 6. Common module requirements: Each module is defined by its inputs and outputs only (very milar to computer hardware or logic design similar to computer hardware or logic design ). Modules can be debugged using simulated inputs. Modules will work properly so long as they meet the “spec ”. 7. Modern programming usually also involves what is referred to as “hierarchical design: A large program is structured in a number of layers . The executive layer(s) supervise overall operation, while middle layers (“middle managers”) summon the right “worker” modules. These lowest-layer “worker bees” perform actual functions. any of the “worker bees” re procedures © N. B. Dodge 09/09 Lecture #17: Procedures and Use of the Stack 2 Many of the worker bees are procedures .
Background image of page 2
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Procedure Support in SPIM Many programs use procedures to provide the desired functionality required, which are used, or “called,” as needed. riting these modules, or procedures, is a key part of proper design Writing these modules, or procedures, is a key part of proper design and development of many programs. Modern compilers provide sophisticated support for development of rocedures. procedures. SPIM, on the other hand, provides minimal support for procedures. Two special MIPS instructions are provided to call a procedure , and turn to the calling program s we have discussed previously): return to the calling program (as we have discussed previously): jal – Operates just like jump (next instruction executed is at “label”), except that PC + 4 $ra. This instruction calls the procedure . $ra ra] PC; e next instruction executed is the one after the jal © N. B. Dodge 09/09 Lecture #17: Procedures and Use of the Stack 3 jr $ra [$ra] PC; the next instruction executed is the one after the jal instruction. This instruction returns the program to the point of the call .
Background image of page 3

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

View Full DocumentRight Arrow Icon
Erik Jonsson School of Engineering and h U i it
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/16/2009 for the course EE 2310 taught by Professor Dodge during the Spring '09 term at University of Texas at Dallas, Richardson.

Page1 / 22

Lecture 17 - Th The University of Texas at Dallas Erik Jonsson School of Engineering and Computer Science Procedures Why are common procedures or

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

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