CO Quiz 1 Solution

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

COMSATS University Islamabad (CUI)

Department of Electrical and Computer Engineering


Computer Organization (CPE 343)
Quiz 1 Solution

Marks: 10 Date: 04/10/2019


Instructor: Dr. Sana Shuja Section: BCE
Time: 20 min

Q1.
# $t0 = instruction format
lui $t5, 0x03e0 #t5 = 0000001111100000 (And Mask)
and $t6, $t5, $t0 #t6 = 00000011011000000000000000000000
# (Rs extracted and placed in $t6)
srl $t1, $t6, 21 #t1 = 000000000000000000000000000011011
# number of bits = 6(opcode) + 5 (Rs) = 11 => 32-11 = 21 bits shift

Q2.

addi $v0, $zero, -1 # initialize to avoid counting zero word


loop: lw $v1, 0($a0) # read next word from source
addi $v0, $v0, 1 #Increment count
sw $v1, 0($a1) #Write to destination
addi $a0, $a0, 4 # advance pointer to next source
addi $a1, $a1, 4 #advance pointer to next destination
bne $v1, $zero, loop #Loop if word copied

You might also like