next up previous contents

[ENGN3213 Home]

Nested Subroutines

A key advantage of the subroutine programming techniques we have looked at is that subroutine calls can be nested or even recursive.

Exercise.

Write an assembly program which has two simple subroutines (like above, one which, say, adds, the other, subtracts) such that one subroutine calls the other. Run the program and notice how the subroutines nest, keeping close track of SP, FP, PC and stack/stack frame contents.



ANU Engineering - ENGN3213