3

Click here to load reader

Final alco paper

Embed Size (px)

Citation preview

Page 1: Final alco paper

Air University Multan CampusDepartment of Computer Science & Engineering

Assembly Language & Computer Organization Final Exam

Time Allowed: 3 hoursTotal Marks: 100

Question 1: Suppose that $t0, $t1, and $t2 have already been assigned values (it doesn t matter which’ ones). Write MIPS assembly-language instructions to accomplish the following Pseudo-code segments.

[10+10=20]

(a)if ($t0 == $t1) $t2 = $t0 + $t1;$t0 = 3;

(b)if ($t0 >= $t1)$t2 = $t2 - $t1;else$t2 = $t2 + $t1;$t0 = 55;

Question 2: Assume the following: [15].datak: .word 2array: .word 87,22,88,777,23,89,845

Write MIPS assembly-language instructions to accomplish the following pseudo-code segment. k and array in the pseudo code refer to the above variables stored in memory. You must use those labels in your code. And, your code should work even if we were to change the values stored in k and array.

if (array[k] >= 0):array[0] = 10;else:array[1] = 50;

Question 3: What are the advantages of instruction pipelining? Explain with the help of diagram for a 5 stages instruction pipelining having cycles IF, ID, ALU, MEM and WB. How many latches would be required for the pipelining and what is the role of latches? What can be problems of such instruction pipelining? [2+8+3+2 = 15]

Question 4: Represent 19.75 decimal in the IEEE 754 single-precision floating point format. Please show your work. Give your answer in BINARY and HEXADECIMAL. [10]

Question 5: A cache memory has 256 cache lines (blocks in cache) with each cache line holding 16 bytes. The cache memory is direct mapped. Consider the 24–bit address 0x123A04? [10]

a) What is the data capacity of the cache, in bytes? b) How many bits for offset, index and tag are specified?c) What is the offset (byte number) in the cache line of the byte with address 0x123A04? d) Into what cache line (at which index) is the byte with main memory address 0x123A04 placed? e) When the byte with main memory address 0x123A04 is placed in its proper cache line, what it the value stored

as the cache tag for that line?

Page 2: Final alco paper

Question 6: Below is a solution to a Program. Please answer the questions marked by #Q1-7: There are 7 of them. [20].datastring: .space 9.textli $a0, 0xCAB123EAla $a1, stringjal translatej endprogramtranslate:addi $t9, $zero, 8addi $t8, $zero, 0lui $t7, 0xF000

#Q1: What is $t7 now?translate_loop:and $t1, $a0, $t7

#Q2: The first time through the loop, what is $t1 now?srl $t1, $t1, 28

#Q3: The first time through the loop, what is $t1 now?sll $a0, $a0, 4

#Q4: The first time through the loop, what is $a0 now?slti $t2, $t1, 0xA

#Q5: The first time through the loop, what is $t2 now?beq $t2, $zero, label

#Q6: The first time through the loop, is the next instruction executed?addi $t0, $t1, 0x30j translate_storelabel:addi $t0, $t1, 0x37translate_store:sb $t0, 0($a1)

#Q7: The first time through the loop, what value is stored in memory?addi $a1, $a1, 1addi $t8, $t8, 1bne $t8, $t9, translate_loopsb $zero, 0($a1)jr $raendprogram:

Question 7:Draw a MIPS machine with datapaths and controls supporting R-type, I-type and J-type instructions. Your diagram should base on the following split memory (harvard) model. Clearly label all the datapaths, control instructions and units. Datapath and controls without any label will be marked zero. [10]

Page 3: Final alco paper