{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework02_key - CS/ECE 3810 Solutions Homework#2 Fall 2009...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS/ECE 3810 Solutions – Homework #2 Fall 2009 1. Exercise 2.10: 2.10.1 (4 points ): 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) 101011 2 = 43 10 sw (b) 100011 2 = 35 10 lw 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) 101011 2 = 43 10 10000 2 = 16 10 01011 2 = 11 10 0000000000000100 2 = 0 4 10 (b) 100011 2 = 35 10 01000 2 = 0 8 10 01000 2 = 0 8 10 0000000001000000 2 = 64 10 The 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 (2 points ): As found above, they are both I-type instructions. 2.10.3 (2 points ): Convert each 32-bit word four bits at a time: (a) 1010 1110 0000 1011 0000 0000 0000 0100 A E 0 B 0 0 0 4 0xAE0B0004 (b) 1000 1101 0000 1000 0000 0000 0100 0000 8 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.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon