Sunteți pe pagina 1din 2

Lab Evaluation 1 P1 - KEY

CS F342 Computer Architecture


Semester 1 – 2019-20 12th September 2019
Maximum Marks: 30 Allocated Time: 60 Minutes
Name:_________________________ ID. #:___________________________
A. Sign the attendance. Note: Once you are asked to stop writing / modifying code – save your
B. This sheet is to be submitted for work immediately and turn off you monitors and put your answer
evaluation. sheets upside down. You can access the local server, but should not use
C. If you have partially working code, phones, chat, messenger etc. Maintain absolute silence during the test
make sure that you demonstrate the same before and evaluation.
submitting this.
D. If you do not have a demonstration you Demonstration Grade:
can submit this sheet after writing NO-DEMO
in the adjoining box.

Exercise 1: Decode the following machine code values. Note that you have to mention whether the instruction is of R,
I or J type. Provide the exact assembly instruction that can be used to generate the machine code. [4M]
Input Type (R/I/J) Assembly Instruction including Arguments
00A74822 R SUB $t1, $a1, $a3
A1EA0012 I SB $t2 18($t7)
Exercise 2: Answer the following MCQ (+1 for correct answer and -0.5 for wrong answer) in the table. [10M]

1. Which of the following is the correct representation of (54.75)10 in floating point binary format written in a
hypothetical 9-bit word where the first bit is used for the sign of the number, the second bit for the sign of the
exponent, the next four bits for the mantissa, and the next three bits for the exponent. Assume normalized numbers.
(a) (1.1011011)2 x 2(5)10 (b) (1.0111011)2 x 2(5)10 (c) (1.1011010)2 x 2(5)10 (d) (1.1010011)2 x 2(5)10

2. Consider the IEEE 754, 32-bit format. If the exponent field = 255 and the significand is non zero, then the number
is
(a) subnormal (b) infinity (c) normal (d) NaN

3. Let k = 6 be the field width of the exponent field in a hypothetical floating point representation (normalized). Let E
be the excess exponent and e be the real exponent. Then,
(a) e = E – 15 (b) e = E – 31 (c) e = E – 63 (d) e = E - 7

4. Which of the following statements is wrong regarding subnormal numbers?


(a) the exponent part is zero (b) the significand part is non-zero (c) no implicit 1 in the significand
(d) the largest subnormal is closer to largest normalized number

5. Consider the MIPS 32 instruction lw $rt, offset($rs). Here, the offset is placed in
(a) 16-bit 2’s complement form (b) 16-bit 1’s complement form (c)32-bit 2’s complement form
(d) 32-bit 1’s complement form

6. Assume that the sll (by 1) operation in MIPS was performed on eight bits and the resulting pattern is 0100 1110.
What is the original pattern?
(a) 0100 1111 (b) 0100 0111 (c) 1010 0111 (d) 1010 0110

7. AND is a ____ type of instruction in MIPS.


(a) R (b) I (c) J (d) M

8. Consider the Amdahl’s law. If the enhanced mode takes 3 seconds for executing a portion of the program while it
takes 6 seconds in the original mode, what is the Speedupenhanced?
(a) 2 (b) 3 (c) 6 (d) 18
9. As per Amdahl’s law, if we make 80% of a program run 20% faster, the overall speedup will be
(a) 1.254 (b) 1.352 (c) 1.451 (d) 1.154

10. Given the CPU clock rate is 1 MHz; the program takes 45 million cycles to execute. The CPU time is
(a) 4.5 seconds (b) 450 seconds (c) 45 seconds (d) 0.45 seconds

Q.no. 1 2 3 4 5 6 7 8 9 10

Ans: a d b d a c a a d c

Exercise 3: Complete the assembly code such that it exactly implements the Pseudo code given below. [16M]
Given the value of Sigma, Gamma and the cosine of angle between the glass and water, calculate the height of
the capillary rise in the tube (to the nearest integer). ( H = (2 * σ * cosx) / ( γ * R ), assume σ = 5.670373, γ =
9.807)
C code:

#include<stdio.h>
#define SIGMA 5.670373
#define GAMMA 9.807
int main()
{
double R;
scanf("%lf",&R);
float cosx;
scanf("%f",&cosx);
double H = SIGMA;
H = 2 * (H * cosx);
R = R * GAMMA;
H = H / R;
H += 0.5;
int h = H;
printf("%.19lf\t%d",H,h);
return 0;
}

.data mul.d $f6, $f6, $f4


SIGMA: .double 5.670373 add.d $f6, $f6, $f6 # calculate
GAMMA: .double 9.807 2 * H * cosx

.text la $a1, GAMMA


l.d $f8, ($a1) #load GAMMA
main:
mul.d $f2, $f2, $f8
li $v0,7 #scan R in double form div.d $f6, $f6, $f2
syscall
mov.d $f2, $f0 li.d $f10, 0.5
add.d $f6, $f6, $f10 #add 0.5 to
li $v0,6 #scan cosx in float form answer
syscall
cvt.w.d $f6, $f6
cvt.d.s $f4, $f0 #convert cosx mfc1 $a0, $f6 #convert to
to double form nearest integer

la $t0, SIGMA li $v0, 1


l.d $f6, ($t0) #load SIGMA syscall

li $v0, 10
syscall

S-ar putea să vă placă și