Question: Consider a main program. Assume that the programmer declares the following variables: x, y, z , and result . At execution, variables are stored in
- 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 300H and each variable takes 2 bytes. Integers are represented in 2s complement on 2 bytes. The variables x, y, and z are initialized to 5, 3 and 15 (in decimal), respectively. Consider that the system is byte addressable, and one instruction takes 2 bytes. (Operating System)
Consider that a function is called in the main program at the address 3ABH.
The function has the definition: int func(int x, int y, int z). The function is located at the address E12H.
int func(int x, int y, int z) {
int a;
a = (x +y) z;
return a; }
- 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 when the function is called and executed. Indicate addresses and data in HEX.
- Explain the process of parameter passing in this case.
- Where is variable a allocated? Explain.
- What are the values of the program counter before, during and after the function execution? Explain.
- What is the value of result variable after the function executes? Give the answer in HEX.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
