CS201 MID TERM SOLVED MCQs || PAST PAPERS || GROUP-1 || INTRODUCTION TO PROGRAMMING || VuTech Visit Website For More Solutions www.vutechofficial.blogspot.com …
a) Write the instructions for the 0-address machine to evaluate the
following expression.
z = x2 + y2 + 2xy
Note: x, y and z represent memory locations.
Solution:
0-address instructions
PUSH x
PUSH x
MUL
PUSH y
PUSH y
MUL
ADD
PUSH x
PUSH y
MUL
PUSH 2
MUL
ADD
POP z
b)Calculate the execution time for 0-address machine using the above given expression by considering the following parameters:
Average CPI
Processor Frequency (f)
6
2 GHz
Solution:
Execution Time = IC x CPI x T
Where,
IC =
Instruction Count
CPI =
Average number of system clock periods to execute an instruction
T =
Clock Period
Put all value
ET = 14 x 6 x 2
ET = 168
KINDLY, DON’T COPY PASTE
Visit Website For More Solutions
www.vutechofficial.blogspot.com
Question No. 2
Reverse assemble the following SRC machine language instructions:
B2064000h
Solution:
B2064000h
We convert the Hexadecimal into Binary, i.e
1011 0010 0000
0110 0100
000 0000
0000
First 5 bits of the binary pattern represent the opcode 22. This opcode 22
belongs to or instruction which is a D instruction of SRC. The format of
modified D instruction is
31
27
26
22
21
17
16
12
11
0
Op-code
Ra
rb
rc
unused
In D instruction, the first 5 bits represent opcode, and next 15 bits
represent the one destination and two source operands of 5-bit each. We
split the given bit pattern according to the type-D instruction format
as
Next, we specify the instruction field for each the section as
following:
10110
01000
00011
00100
00000
or
R8
R3
R4
unused
Hence, the SRC instruction will be R8, R3, R4.
1A0C0022h
Solution:
1A0C0022h
We convert the hexadecimal into binary pattern, i.e
0001 1010 0000
1100 0000 0000
0010 0010
The first 5 bits of the binary pattern represent the opcode 3. This opcode
3 belongs to st instruction which is a C instruction of SRC. The format of C
instruction is:
31
27
26
22
21
17
16
0
Op-code
ra
rb
C2
Next, we specify the instruction field for each the section as
following:
00011
01000
00110
00000000000100010
st
R8
R3
34
Hence, the SRC instruction will be:- st R8,34 (R6)
KINDLY, DON’T COPY PASTE SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES SEND WHATSAPP OR E-MAIL FOR ANY QUERY 0325-6644800 kamranhameedvu@gmail.com Visit Website For More Solutions www.vutechofficial.blogspot.com
We provide Virtual University of Pakistan Study Materials such as Solution of Assignments, GDBs, Mid Term Solved Papers, Final Term Solved Papers, Mid Term Solved MCQs, and Final Term Solved MCQs. We also provide regular Semester Quizzes, Updated Handouts, and Short Questions and Answers. We help you with your research and many other educational-related topics, as far as we know. Furthermore, Share your problem with us and Please feel free to ask any related questions.