# CZ101, Tutorial 6 (last tutorial), 20 - 25 October, 1997

The problems are mostly review type. PLEASE Do the problems before going to the tutorial class. You need not hadn in the solutions.

1. [30] Given a simple computer (we built in Chapter 5) which has only nine instructions lw, sw, add, sub, and, or, slt, beq, and j, we like to know if we can do many of the other operations (in software) not found in the instruction set.

(a) How can we do bne, using a sequence of instructions in the nine instruction set?

(b) How can we do a shift left 1 bit sll \$2, \$3, 1, and shift right 1 bit srl \$2, \$3, 1?

(c) Can we program it to do multiplication and division with this computer? Answer yes or no, no coding needed.

2. [30] Consider following sequence of instructions given in binary form (generated by xspim, not the CC compiler)
```001000 00000 00010 11111 11111 111111

001100 00010 00011 00000 00000 001111

000101 00010 00000 00000 00000 000011

000000 00000 00011 00011 00001 000010

000010 00000 10000 00000 00000 001111

101011 11101 00011 00000 00000 000000

000000 00011 00010 00010 00000 100010

001111 00000 00100 00111 11110 000000

101011 11101 00100 00000 00000 000100

110001 11101 00000 00000 00000 000100

001111 00000 00100 01000 00010 000000

101011 11101 00100 00000 00000 001000

110001 11101 00010 00000 00000 001000

010001 10000 00010 00000 00100 000011
```

(a) Translate the binary form into symbolic form. For the MIPS instruction encoding scheme, You need the Figure 3.16 (page 132), Figure 4.44 (page 241), or the Table at the back cover of the textbook, or Figure A.18 (page A-51).

(b) Execute the instructions, indicating the new values (in decimal notation) in all registers and memory locations referenced in the program.