Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions