You are on page 1of 5

COMPUTER SYSTEM ARCHITECTURE LAB # 09

NATIONAL UNIVERSITY OF SCIENCES


AND
TECHNOLOGY

Lab # 09
Computer System Architecture
(PC) Muhammad Shoaib Talib (281018)
(GC)Abdul Wali (280935)
DE-40 CE” A”

SHOAIB TALIB&ABDUL WALI 1


COMPUTER SYSTEM ARCHITECTURE LAB # 09

Lab 9
Lab Objectives:

The purpose of this lab is to make students able to better understand the machine code and

hardware components embedded in the lowest layer of computer system architecture.

Lab Tasks
Task#01:
Draw the data paths along with the control units after deriving the machine

language codes for the instructions given below. Your diagram should be very well

detailed, clear and intuitive.

1): lw $s0, 20($s2)

2):sw $s7, 20($s8)

Solution:
1): lw $s0, 20($s2)

.text

Immdiate 20
rs=$s2 =R#18
rt=$s0=R#16

OPCODE rs rt Address
35 18 16 20
100011 10010 10000 0000000000010100

SHOAIB TALIB&ABDUL WALI 2


COMPUTER SYSTEM ARCHITECTURE LAB # 09

Data Path:

4):sw $s7, 20($s8)

Suppose we have the instruction sw $s7,20($s8)

Here in the Mips we


Immdiate 20
rs=$s8 =R#30 (Frame pointer)
rt=$s7=R#23

OPCODE rs rt Address
43 30 23 20
101011 11110 10111 0000000000010100

SHOAIB TALIB&ABDUL WALI 3


COMPUTER SYSTEM ARCHITECTURE LAB # 09

DataPath:

Task#02:
What changes would be needed if we want to make the basic architecture capable of executing ‘add
immediate’ instruction as well. Also draw the complete table indicating state of all control lines in this
case.

Solution
Now suppose we have the immediate type instruction

addi $11,$13,30

OPCODE rs rt immediate
0010 00 01 101 0 1011 0000 0000 0001 1110

SHOAIB TALIB&ABDUL WALI 4


COMPUTER SYSTEM ARCHITECTURE LAB # 09

DataPath:

Table:
Instructio RedDs ALUSr MemtoRe MemRea RegWri MemWrit Branc ALUop Aluop
n t c g d e e h 1 2
I type 0 1 0 0 1 0 0 0 0
Explanation: addi is a I-type instruction in which there is a 16-bit field for the immediate
value to be added with the Register rs and the resultant value is stored in the rs register. As
there are two basic operation to be performed
1): Adding the immediate value to the register rs
2): Storing back the result to the Register
So, the Control Unit will generate the Signal to the Corresponding input lines as shown in the
Datapath. Hence the Corresponding inputs will be generated. Control Unit Decide the inputs
based upon the op-code related to each instruction in the MIPS.

SHOAIB TALIB&ABDUL WALI 5

You might also like