Docsity

Recursive C Programming: Writing, Compiling, & Analyzing Self-Calling Function, Slides of Computer Science

Toggle sidebar
bg1
HW 11
1) 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.
2) Compile your program, test it with the LC-3 simulator, and verify that it works
correctly.
3) 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.
4) 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.
Docsity.com

Partial preview of the text

Download Recursive C Programming: Writing, Compiling, & Analyzing Self-Calling Function and more Slides Computer Science in PDF only on Docsity!

HW 11

  1. 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.

  2. Compile your program, test it with the LC-3 simulator, and verify that it works correctly.

  3. 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.

  4. 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.

Docsity.com