CS/COE 447: Spring 2010 Homework 2 YOUR NAME: It's fine to discuss the questions in general with other people, but your solutions should be your own individual work. Please show all work. **Q1[5 points]: Convert the following base 10 number into 32-bit two's complement binary numbers. 5984, 12, 32 **Q2[5 points]: Convert the following base 10 numbers into a 32-bit two's complement binary numbers. -2349, -7, -2047 **Q3[5 points]: What decimal numbers do the following two's complement binary numbers represent? 1111 1111 1111 1111 1011 1110 0110 1111? 1111 1111 1111 1111 1111 1111 1111 1111? 1111 1111 1111 1111 1111 1111 1111 1100? **Q4[5 points]: Add the following unsigned binary numbers (show the carry and overflow bits) 0111 1000 0100 + 1001 1100 1101 ---------------- **Q5[5 points]: Subtract the following unsigned binary numbers (who the borrow and underflow bits) 0101 0100 0101 - 1101 1011 1011 ---------------- [Note: TWO QUESTIONS REMOVED 3/2/2010 because we haven't covered binary decimals yet.] **Q8[5 points] Convert the following binary sign-magnitude numbers into decimal numbers: 1000010101, 11110101010, 1000000001 **Q9[5 points] Convert the following decimal numbers into 9-bit binary numbers in 1's complement form: 11, -133, -21 **Q10[10 points] For each of the following decimal expressions, convert the operands into 2's complement and calculate the 2's complement result. Convert the result back to decimal. 45 + (-52) = ? 34 + 23 = ? -86 + (-33) = ? **Q11[15 points]: Consider the following MIPS code: What values are placed in the registers when this code is executed? (You can check your answers in the simulator, but you should work through this on paper first, without a calculator.) .text li $t0,-20 li $t1,0x0900000f addu $t2,$t0,$t1 add $t3,$t0,$t1 slt $t4,$t0,$t1 sltu $t5,$t0,$t1 li $s0,0x90000000 li $s1,3 mult $s0,$s1 mflo $s2 mfhi $s3 multu $s0,$s1 mflo $s4 mfhi $s5 **Q12[5 points]: Does the addu instruction from the program result in overflow? Please explain your answer. li $t0,-20 li $t1,0x0900000f addu $t2,$t0,$t1 **Q13[5 points]: Does this instruction from the program result in overflow? Please explain your answer (Show what happens). add $t3,$t0,$t1 **Q14[20 points]: "Overflow" means that the result of an operation does not fit in the allotted number of bits "unsigned overflow": the result doesn't fit, viewing the numbers as unsigned numbers "signed overflow": the result doesn't fit, viewing the numbers as signed numbers This question uses 8-bit (1-byte) binary numbers. Perform the indicated operations and fill in the tables. (For example, in the first table, you should fill in the sum in binary, and then say what 00100101, 11110101, and their sum are in decimal, viewing them as signed numbers). decimal, viewing the is there signed numbers as signed overflow? 00100101 +11110101 ---------- decimal, viewing the is there unsigned numbers as unsigned overflow? 00100101 +11110101 ---------- decimal, viewing the is there signed numbers as signed overflow? 10101111 +10000101 ---------- decimal, viewing the is there unsigned numbers as unsigned overflow? 10101111 +10000101 ---------- decimal, viewing the is there signed numbers as signed overflow? 10000000 +00000001 ---------- decimal, viewing the is there unsigned numbers as unsigned overflow? 10000000 +00000001 ---------- decimal, viewing the is there signed numbers as signed overflow? 01100000 +01000010 ---------- decimal, viewing the is there unsigned numbers as unsigned overflow? 01100000 +01000010 ----------