Answered step by step
Verified Expert Solution
Link Copied!

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 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.

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;

}

  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 when the function is called and executed. Indicate addresses and data in HEX.
  2. Explain the process of parameter passing in this case.
  3. Where is variable a allocated? Explain.
  4. What are the values of the program counter before, during and after the function execution? Explain.
  5. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions