Question: The following code gives an example of a C program that calls a func void adder(int a, int *b) *b = a + *b;} void


The following code gives an example of a C program that calls a func void adder(int a, int *b) *b = a + *b;} void main (void) int x = 3, y = 4; adder(x, &y); This 68000 program creates the following output from a compiler. The pa of the instructions that are not obvious. *1 void adder (int a, int *b) Parameter a is at 8 (FP) Parameter b is at 10 (FP) adder LINK FP, #0 +2 { *3 *b = a + *b; *2 { *3 *b = a + *b; NOVEA.L 10 (FP), A4 MOVE (A4), D1 ADD MOVE } 8(FP), D1 D1, (A4) *4 *6 void main(void) Variable x is at -2 (FP) Variable y is at -4 (FP) main LINK FP,#-4 +7 { *8 int x = 3, y = 4; MOVE #3,-2 (FP) MOVE #4,-4 (FP) *9 adder (x, &y); PEA 4 (FP) MOVE #3,- (A7) JSR adder * 10 * 11 } UNLK FP RTS Draw the state of the stack immediately after function adder is called in function main (ie, the return address is on the top of the stack but no code in adder has yet been executed), Carefully label all items on the stack and give their location with respect to the current value of the frame pointer. Draw a sequence of diagrams (ie, memory maps) showing what happens to the stack as function adder is executed. Explain the action of each instruction that modifies the state of the stack. Show how parameters are passed to and from the function and how stack-based values are accessed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
