subject

The following code gives an example of a C program that calls a function. 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 panel describes some 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;

NOVEA. L 10 (FP) , A4

MOVE (A4) , D1

ADD 8 (FP) , D1

MOVE D1 , (A4)

*4 }

*5

*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 (i. e., 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 (i. e., 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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
You know the right answer?
The following code gives an example of a C program that calls a function. void adder(int a, int *b...
Questions
question
Mathematics, 26.02.2021 07:20
question
Mathematics, 26.02.2021 07:20
question
Mathematics, 26.02.2021 07:20
question
Mathematics, 26.02.2021 07:20
question
Mathematics, 26.02.2021 07:20
Questions on the website: 13722363