ITCS 321 Test ONE NOV 2018 KEY AAA
ITCS 321 Test ONE NOV 2018 KEY AAA
ITCS 321 Test ONE NOV 2018 KEY AAA
QUESTION # 1 2 3 4 TOTAL
MAX POINTS 14 16 16 18 63
POINTS EARNED
***************************************************************************************
UNIVERSITY OF BAHRAIN COLLEGE OF INFORMATION TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE
ITCS 321: COMPUTER ORGAIZATION AND ASSEMBLY LANGUAGE
FIRST TEST FIRST SEMESTER 2018/2019 DATE: NOV 13, 2018
***************************************************************************************
QUESTION ONE
Part A: { 08 pts }
The 8-bit value 10111010 represents unsigned decimal value 186 and signed decimal value -70.
1) Using 36 bits to represent signed values, the largest decimal value is +235 - 1 and the smallest
3) If a computer has clock period = 0.2 ns, then its clock rate = 1/(0.2x10-9)= 5 GH.
Part A: { 10 pts }
1) Briefly explain two differences between RISC and CISC computers.
In RISC: all instructions have fixed size; In CISC: instructions have variable size
In RISC: arithmetic operations are register to register; In CISC: arithmetic
operations are with any operands.
In RISC: few instruction formats; In CISC: large number of instruction formats
2) Assume the CPU has just read a 32-bit MIPS instruction from the memory address 0x00400008. Then,
the address of the next instruction to be read by the CPU is 0x00400008+4=0x0040000c
3) Assuming the following data segment, and assuming that the first variable X is given the address
0x10010000, then the addresses for variables Y and Z will be 0x10010002 and 0x10010008
.data
X: .byte 1, 5
Y: .half 2, 3, 9
Z: .word 4
4) Given the array definitions arr: .byte 1, 2, -3, 4; After executing the following code, the
content of the three registers $t1, $t2, and $t3 will be:
la $t0, arr
lb $t1, 2($t0)
lh $t2, 2($t0)
lw $t3, 0($t0)
5) Assume that the instruction bne $t0, $t1, NEXT is at address 0x00400020 in the text segment, and
the label NEXT is at address 0x00400010. Then, the address stored in the assembled instruction for the
label NEXT is (0x00400010-(0x00400020+4))/4 = 0xfffb
Part A: { 04 pts }
1) The pseudo-instruction neg $s2, $s1 is used to store in $s2 the 2’s complement of $t1.
Write ONE MIPS instruction to implement it.
subu $s2, $0, $s1
2) Write no more than TWO MIPS instructions to implement the following pseudo instruction
ble $s2, $s1, Next.
slt $at, $s1, $s2
beq $at, $0, Next
Part B: { 12 pts }
1) Assume that variables a, b, c, and d are stored in registers $s1, $s2, $s3, and $s4,
respectively. Write the needed MIPS instructions to implement the following if statement:
if ( (a == b) && (b < c ) ) then d = d +5;
2) Assume that variables a, b, c, and d are stored in registers $s1, $s2, $s3, and $s4,
respectively. Write the needed MIPS instructions to implement the following if statement:
if ( (a ==b) || (b <= c ) && (c > d) ) then d=d +a;
Part A: { 04 pts }
Given the following contents of memory. What will be in registers $t0 thru $t3 in hexadecimal
after executing each of the following MIPS instructions. The little endian byte ordering is used.
Assume $t8 = 0×10010020.
Address +0 +1 +2 +3 +4 +5 +6 +7
0×10010020 FA 20 10 C0 B0 5F 94 8A
# MIPS program to find the smallest value and its address in a given array
# Date: NOV 13, 2018
.data
arr: .word 75, -19, 20, 88, -5, 45, -29, 99
.text
.globl main
main:
la $a0, arr
addi $a1, $a0, 28
move $v0, $a0
lw $v1, 0($v0)
move $t0, $a0
next: addi $t0, $t0, 4
lw $t1, 0($t0)
bge $t1, $v1, skip
move $v0, $t0
move $v1, $t1
skip: bne $t0, $a1, next
li $v0, 10 # syscall 10 = exit the program
syscall