CS/ECE 3810 Solutions – Homework #2 Fall 2009 1. Exercise 2.10:2.10.1 (4points): To solve, first extract the opcode bits to determine each instruction type. Then, look up the instruction on page B-50: Highest 6 bits Corresponding opcode (a) 1010112= 4310sw (b) 1000112= 3510lw Both these instructions are I-type instructions (see pages B-69 and B-67). Since they are memory access instructions, they will take the form: OPCODE rt, immediate(rs). To find the registers and the immediate, write the bits into this instruction format: Opcode bits rs bits rt bits Immediate bits (a) 1010112= 4310100002= 1610010112= 111000000000000001002= 0410(b) 1000112= 3510010002= 0810010002= 081000000000010000002= 6410The opcodes have already been figured out - all that remains is to look up the registers and put the parts of the instruction together. Using the chart on page B-24, register 8 is $t0, register 11 is $t3, and register 16 is $s0. The solution is: Instruction (a) sw $t3, 4($s0) (b) lw $t0, 64($t0) 2.10.2 (2points): As found above, they are both I-type instructions. 2.10.3 (2points): Convert each 32-bit word four bits at a time: (a) 1010 1110 0000 1011 0000 00000000 0100A E 0 B 0 0 0 4 0xAE0B0004 (b) 1000 1101 0000 1000 0000 00000100 00008 D 0 8 0 0 4 0 0x8D080040 I double-checked my work by typing in the instructions in part 2.10.1 into the Mars MIPS simulator. I then assembled the program and checked the hexadecimal output to make sure it matched part 2.10.3. This helped me discover that I mixed up rs and rt in part (a). I fixed it, and the correct answers are above.
This preview has intentionally blurred sections.
Sign up to view the full version.