Question: Consider a main program. Assume that the programmer declares the following variables: x, y, z , and result . At execution, variables are stored in

  1. Consider a main program. Assume that the programmer declares the following variables: x, y, z, and result. At execution, variables are stored in the memory starting at the address (4EF) H and each variable takes 2 bytes. Integers are represented in 2s complement on 2 bytes. The variables x, y, and z are initialized to -7, -15 and 30 (in decimal), respectively. Consider that the system is byte addressable, and one instruction takes 2 bytes. Consider that a function is called in the main program at the address (54E) H. The function has the definition: int func(int x, int y, int z). The function is located at the address (AB9) H. (Operating system)

int func(int x, int y, int z) {

int a;

a = (x +y) z;

return a;

}

  1. Draw a diagram of the process address space indicating the data (heap), stack and code. Indicate what the content of the data and stack is during the time when the function is called and executed. Write addresses and data in HEX.
  2. What are the values of the program counter before, during and after the function execution?
  3. What is the value of result variable after the function executes? Give the answer in HEX.
  4. What is the role of the stack and what is the role of the heap?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!