1) How relocatable is the code in memory if direct addressing is used?

2) How many bits are needed to represent a direct address on a 32-bit machine?

3) From your programming experience, what range of Integer values would cover 90% of the constant Integer values used in your programs?

4) How many binary bits would you need to represent this range of values?

5) What determines how many bits are needed to represent a register in a machine language instruction?

6) Which of the following programming language constructs would be good candidates for using PC-relative addressing?

a) conditional branch used when implementing loops

b) calling a subprogram

c) accessing a global variable

d) accessing a local variable

7) Assume that an automobile assembly process takes 4 hours.

If the stages take 1 hour each, then what is the time between completions of automobiles?

Type of Instruction Assembly Language Register Transfer Language

Description

Memory Access

(Load and Store)

lw $4, Mem
sw $4, Mem Mem$4
lw $4, 16($3)
sw $4, Mem  
Move move $4, $2 $4 $2
li $4, 100 $4 100
Load Address la $5, mem $4 load address of mem
Arithmetic Instruction

(reg. operands only)

add $4, $2, $3 $4 $2 + $3
mul $10, $12, $8 $10 $12 * $8 (32-bit product)
sub $4, $2, $3 $4 $2 - $3
Arithmetic with Immediates

(last operand must be an integer)

addi $4, $2, 100 $4 $2 + 100
mul $4, $2, 100 $4 $2 * 100 (32-bit product)
Conditional Branch bgt $4, $2, LABEL Branch to LABEL if $4 > $2
Unconditional Branch j LABEL Always Branch to LABEL

Fibonacci Sequence: 0 1 1 2 3 5 8 13 21
Position in Sequence: 0 1 2 3 4 5 6 7 8

A high-level language program to calculate the nth fibonacci number would be:

8) Complete the MIPS program to calculate the nth fibonacci number.

.data

n: .word 8

result: .word 0

.text

.globl main

main: li $2, 0

li $3, 1

lw $5, n # load "n" into $5