Module 0276: Subroutines using the Toy processor

Tak Auyeung, Ph.D.

April 26, 2017

1 About this module

2 Calling and returning

First, let us example the following C program:

1void f() 
2{ 
3} intmain()f();label{line:invoke} 
4  return 0; 
5}

This program does not do much, but illustrates a single subroutine call. At this point, we are only concerned about the control structure. In other words, we only want to know what happens when f is invoked from main, and what happens at the end of the function f when execution gets back to main to execute the return statement in main.

The invocation on line ?? needs to do the following: