Question: You will provide the data values that appear on the run-time stack during the execution of simple C program. Part of the stack frame for



You will provide the data values that appear on the run-time stack during the execution of simple C program. Part of the stack frame for function main is shown in the memory table in Part A and Part B. R6 is the stack pointer and R5 is the frame pointer. To ensure consistent answers: a) after main's callee setup, R5 is 0xBCDB. Derive the value of R6 from this information b) place n above accum in the stack. Part A: In the memory table, draw the stack at the point that ISR/ISRR begin:s transferring control to find ngon during the execution of the statement find_ngon(x, n);". Also indicate the values of R5 and R6 at this point of program execution. Part B: In the memory table, draw the stack right before "n 0;" is executed; that is, after find ngon has set up the stack but before it has begun executing. Also indicate the values of R5 and R6 at this point of program execution. Part C: Convert the find_ngon function from C to an LC-3 subroutine with correct use of the run-time stack. Be aware of the requirements on code length (4 instructions each for callee setup and teardown) and execution (every local variable write is reflected in the stack frame) int find_ngon (int perimeter, int side_len) ( int accum, n; n- 0; accumperimeter; while(accum > 0) accum-= side len ; n+t return n; int main) int perim = 15; int side-3 int z; z - find ngon (perim, side) return 0; You will provide the data values that appear on the run-time stack during the execution of simple C program. Part of the stack frame for function main is shown in the memory table in Part A and Part B. R6 is the stack pointer and R5 is the frame pointer. To ensure consistent answers: a) after main's callee setup, R5 is 0xBCDB. Derive the value of R6 from this information b) place n above accum in the stack. Part A: In the memory table, draw the stack at the point that ISR/ISRR begin:s transferring control to find ngon during the execution of the statement find_ngon(x, n);". Also indicate the values of R5 and R6 at this point of program execution. Part B: In the memory table, draw the stack right before "n 0;" is executed; that is, after find ngon has set up the stack but before it has begun executing. Also indicate the values of R5 and R6 at this point of program execution. Part C: Convert the find_ngon function from C to an LC-3 subroutine with correct use of the run-time stack. Be aware of the requirements on code length (4 instructions each for callee setup and teardown) and execution (every local variable write is reflected in the stack frame) int find_ngon (int perimeter, int side_len) ( int accum, n; n- 0; accumperimeter; while(accum > 0) accum-= side len ; n+t return n; int main) int perim = 15; int side-3 int z; z - find ngon (perim, side) return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
