Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 (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.
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 during the time when the function is called and executed. Write addresses and data in HEX.
- What are the values of the program counter before, during and after the function execution?
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started