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, 21.06.2019 22:00
What do the principles of notice, choice, onward transfer, and access closely apply to? a. privacyb. identificationc. retentiond. classification
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create the illusion of 3d in a 2d game
Answers: 3
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
You can apply several different worksheet themes from which tab?
Answers: 1
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, 17.10.2019 00:20
Questions on the website: 13722359