
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Write a C program. That subroutine (function) will call itself recursively twice (main calls the subroutine which calls itself, and that instance of the subroutine calls itself again. A value should be passed in each subroutine call, that value incremented in each subroutine, and that incremented value returned with each subroutine return.
Compile your program, test it with the LC-3 simulator, and verify that it works correctly.
Now comment the assembly code you received from the compiler, as I did for the examples in class. Identify the main program, the subroutine, the stack and the global variable area.
Show the contents of the stack at pertinent points in the execution of the program, as I did in class. The points should include initialization of the stack, entry to each subroutine, and exit of each subroutine. Identify each stack frame. Identify the passed values and returned values on the stack.