Chapter 7. Subroutines, Procedures, and Functions

Chapters 1 through 6 have discussed fundamental aspects of computer architecture by illustrating Itanium instructions for handling integer data (load, store, arithmetic, logical, compare, branch), predication, and loop control. Except for the logical functions, most integer operations have floating-point counterparts (discussed in Chapter 8).

This chapter focuses on the extraordinarily important topics of subroutines, procedures, and functions. Program segmentation makes possible the reuse of previously developed (and thoroughly tested!) code and standard or vendor-supplied libraries. Separating large programming projects into functional areas also provides the opportunity to utilize teams of programmers working independently on parts that will come together properly into a whole.

If an unconditional GOTO is the ballistic projectile of programming, think of subroutines and procedures as boomerangs. A subroutine (or procedure) usually returns to the instruction immediately following the "call" or "jump to subroutine" instruction. Subroutine calls can be nested, even recursively. Some provision for remembering a sequence of return addresses and perhaps other context information is therefore needed; stacks provide the most general method.

We shall expand the discussion of stacks begun in Chapter 4 and introduce a special stack consisting of a large pool of Itanium processor registers. The development of simple subroutines incorporated into the main source file furthers the discussion of program segmentation while concurrently illustrating the use of stacks.

The bulk of this chapter further develops subroutines, with emphasis on functions that return values. This body of material includes the conventions for register usage, the methods for passing arguments (i.e., data and parameters) between calling and called routines, and examples of support routines supplied with an operating system. While we do not delve into the details of operating systems, it is important to understand the purpose of precise rules for the communications among program modules.



ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net