Each question weights 4pt, unless specified otherwise. Stack int G 1 Int A[100]:
ID: 3913970 • Letter: E
Question
Each question weights 4pt, unless specified otherwise. Stack int G 1 Int A[100]: int foo (int a,int b) ( int x, int y: return a+b Heap Static data Text Reserved Int main (int x, int y) ( Int a, b.c Int* d new int; c foo(a,b) delete d; 1. (5pt) Consider the following C codes. Which part of the memory section will the following data be stored? Choose the memory section where the following variables would be located. A. Stack B. Heap C. Static Data D. Text The answers have to be either A,B,C or D. The argument x in the main function. Answer: Answer Answer . The array A[100]. The integer pointed by int* d in the main function Answers: The local variable x in function foo The compiled C codes Answer:A 2. Consider the following binary number in 8-bit two's complement format. 10010110 What is its equivalent value in decimal? Answer Hints: it is a negative number.) 3. Translate the following MIPS assembly codes to a C statement? Assume that variables f,g.h are are in registers to.t1, and 12. subi t0, 12,-1 add t0, t0, t1 Answer: (Use the variables f, g, and h and a constant number in the answer.)Explanation / Answer
The Argument x in the main function is stored in Stack
The array A[100] is stored in static data section
The integer pointed by int* d in the main function is stored in heap area
The Local Variable x in function foo is stored in stack
The Compiled code is in text or code section
2)
10010110 (MSB is 1 hence number is -ve.So convert to 1's complement add 1 resultant binary is the final result but with -ve sign )
01101001+1 = 01101010 = -106
3)
f in t0
g in t1
h in t2
subi t0,t2,-1 is subtract immediate value -1 from t2 and store in t0 i.e.
f=h-1
add t0,t0,t1 is added t0 and t1 and store the result in t0 i.e
f=f+g
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.