You are on page 1of 3

Home Work 8

Deadline: December 22, at 23:59

1 Predicates for Decoding ISA Instructions (10 Pt)


lw(c) ≡ opc(c) = 100011
bltz(c) ≡ opc(c) = 051 ∧rt(c) = 05
add(c) = rtype(c) ∧ f un(c) = 105

Decode in the same way:

sw(c), lui(c), bgtz(c), slt(c), jal(c)

2 Decoding particular ISA Instructions (20 Pt)


Determine for each the following instructions

• instruction type

• instruction

1
• value of the relevant fields (in decimal notation)
• assembler syntax
• pseudo code (semantics), if necessary invent it
• 000000 00001 11111 10101 00000 100001
• 000000 01010 10101 11000 00000 100111
• 001110 10000 10111 1111111111111111
• 000000 10110 00001 00000 101010
• 001000 00010 00000 1111111111111111 do not work hard on this

3 Translate into ISA (20 Pt)


attention! fields are in assembly not in the order of ISA. Carefully consult the
tables.
• lw $2 $1 27
• addi $2 $2 1
• sw $2 $1 27
• sw $0 $1 27

4 Translate into pseudo code (20 PT)


Annotate/comment the instructions from the previous problem with pseudo code

5 Understanding Simple Assembler Programs (10


Pt)
lui $1 0b1010101010101010
ori $1 $1 0b0101010101010101
• annotate with pseudo code
• what is the effect of the small program ?

2
6 Understanding a Loop (20 Pt)
initially let gpr(1) = n ≥ 0 (in assembly language notation, i.e. c0.gpr(19 =
1 − 32)
Treat line numbers as comments for your orientation

1: add $2 $1 $0
2: beq $1 $0 4
3: addi $1 $1 -1
4: add $2 $2 $1
5: beq $3 $3 -3
6: ....

• annotate with pseudo code

• what is gpr(2) once the program has reached line 6?

You might also like