Revision Questions for Datorarkitektur Course

Chapter 2

You should be able to do most of the questions in Chapter 2. Once you have understood the basic concepts most of the questions are just common sense.

Chapter 3

What does the following program do? Assume that the register $s0 contains the address 0x7ef00:

lw $t0,0($s0)
lw $t1,4($s0)
beq $t1,$zero,exit
add $t0,$t0,$t1
sw $t0,0($s0)
sw $zero , 4($s0)
exit: jr $31

Question 2 Write a subroutine which takes two parameters in registers $a0 which contains the base address of an integer array and $a1 which contains the length of that array. The subroutine should return a count of the number of elements which are equal to zero in register $v0. For example given the array:

the subroutine should return 3. You must restore any non-temporary registers used in the subroutine using the stack.

Describe, with examples, the difference between the following instructions:

in particular explain the role that exceptions play in these instructions.

Chapter 4 and Appendix B.1,B.2

Question 1 Why is it not necessary to have a special subtraction circuit inside a processor?

Question 2 First draw a digram representing the gates needed to implement the following boolean expression:

Remember . represents the logical operation and and + represents the logical operation or. Next draw the truth table. Assuming each logic gate takes 4ns to compute its output when the input signals change compute how long the whole circuit will take to compute the the output from the input. (Hint longest path.)

Floating point: Briefly explain the principles of representing floating point numbers, you don't need to worry about biased exponents.

Floating point division: Describe a simple algorithm for the floating point division of two numbers which assumes that you all ways have enough bits in each field to represent the answer, i.e. you don't have to worry about normalising any of the fields. You should be able to work this out from first principles.

Floating point, problems: What sort of problems should a programmer be aware of when using floating point numbers.

Chapter 5

Suppose you where implementing a very simple processor for control applications which didn't use floating points numbers and only had to do simple arithmetic (no multiplication or division) would a single cycle implementation be inappropriate?

Why are single-cycle implementations not used for modern general purpose processors?

Chapter 6

What is data forwarding and how does it help to avoid pipeline stalls? Give some examples where it is useful.

Rearrange the following code to avoid pipeline stalls. You can assume that the processor has a forwarding mechanism:

lw $t2,0($s2)
lw $t0,0($s0)
sw $t0,4($s0)
lw $t1,0($s1)
sw $t1,4($s1)
add $t0,$t0,$t1
sw $t0,0($s0)
add $t0,$t2,$t1
sw $t0,0($s2)

Chapter 7

One commonly used programming optimisation is to claim larger blocks of memory ahead of time instead of claiming lots of small blocks of memory at different times when needed. Why does this optimisation sometimes give you gains on processors and architectures with caches and virtual memeory?

Justin Pearson