Consider the following C code implementing function, f. This function is called
ID: 3862259 • Letter: C
Question
Consider the following C code implementing function, f. This function is called with arguments 8 and 6 (in C code: f(8,6)). Upon entry to the function before the first instruction of the prologue is executed, assume that the value of R7 is 0x3023, R5 is 0xFF31, and R6 is 0xFF29 (e.g. the first argument to f is stored at this location).
Using these initial assumptions, show the stack just after the RET instruction is executed for f. Also, draw an arrow indicating the position of R5 and R6 when the RET instruction is executed.
If you don’t know the value held in a memory location, leave it empty. You do not need to show the LC-3 code for this function. All you must do is interpret its updates to the runtime stack.
int f(int x, int y)
{
int i = 0;
int k = 3;
if (x < y)
return x+k;
else
return y-k;
}
Explanation / Answer
The above registers are of which controller?We need to know the size of each register .Little information left unclear
If we execute the above code with f(8,6),
The present registers R5 ---> 0xFF31, R6 ---> 0xFF29, R7 is 0x3023
After the run of return instructions we need to put up the memory locations, for finding that we need to know the register length so as to understand the exact length they occupy.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.