You are on page 1of 1

EE 471 – Computer Design and Organization

HW #1 – Due 1/10
1.) Pseudo-instructions (instructions that are not actually part of the MIPS
instruction set) often appear in MIPS programs. This can be for the
convenience of programmer or to make them more readable by humans.
Translate the following pseudo-instructions into the minimal sequence of
actual MIPS instructions that perform the desired function. You may
need to use the $at register to store a temporary value.
[Taken from Hennessy and Patterson, 3rd edition]

move $t1, $t2 $t1 = $t2


ble $t3, $t5, L if($t3 <= $t5) go to label L
li $t1, 16-bit value $t1 = 16-bit value
addi $t0, $t2, 32-bit value $t0 = $t2 +32-bit value

Hint: how might we represent a 32-bit value using only 16-bit values?
2.) Convert the following assembly program into machine code:

begin: addi $t0, $zero, 0


addi $t1, $zero, 1
loop: slt $t2, $a0, $t1
bne $t2, $zero, finish
add $t0, $t0, $t1
addi $t1, $t1, 2
j loop
finish:add $v0, $t0, $zero

Assume the program begins at memory location 51210.


3.) Convert the following machine code to assembly (don’t forget to create
labels for branch or jump targets):

Address Instruction
512 00011001000000000000000000000010
516 10101101000001000000000000000000
520 10001101000001000000000000000100
524 00111000101010000001111101110011
528 00000000100001000010100000100000

You might also like