created: 06/10/02; small corrections: 11/30/02, 07/05/03

# CHAPTER 26 — Simple Subroutine Linkage

All high level languages have the concept of a subroutine (sometimes called procedure, function, or method). A subroutine is a logical division of the code that may be regarded as a self-contained operation. A subroutine might be executed several times with different data as the program executes.

This chapter looks at a simple implementation in assembly language of this idea. The simple implementation is not adequate for the full power of subroutines (as implemented in high level languages), but is a good starting point. It corresponds to the type of subroutines implemented in the very early days of programming.

#### Chapter Topics:

- Subroutine call.
- Caller and Callee routines.
- `jal` and `jr` instructions
- The
`$ra` register.
- The simple linkage calling convention.
- Register use in subroutines

The following chapters discuss subroutine call methods that are similar to those of modern languages.

### QUESTION 1:

(Review: ) What instructions unconditionally transfer control from one address to another?