next up previous contents index

[ENGN3213 Home]

Subroutine Operation

Basic subroutine operation is illustrated in Figure 109.


  
Figure 109: Subroutine operation.
\begin{figure}
\begin{center}
\epsfig{file=images/sub-1.eps}\end{center}\end{figure}

This corresponds to the code fragment

...
BSR SUB1
...
...
...
SUB1 ... ...
...
RTS
...

Use of the stack for storing the return address permits the nesting of subroutine calls, and recursive programming.

JSR can be used in place of BSR, though BSR always uses PC relative addressing.


next up previous contents index

[ENGN3213 Home]

ANU Engineering - ENGN3213