Q 1 --- a | b | a and b | not (a and b) ---+---+---------+-------------- 0 | 0 | 0 | 1 0 | 1 | 0 | 1 1 | 0 | 0 | 1 1 | 1 | 1 | 0 a | not a | b | not b | (not a) or (not b) ---+-------+---+-------+------------------- 0 | 1 | 0 | 1 | 1 0 | 1 | 1 | 0 | 1 1 | 0 | 0 | 1 | 1 1 | 0 | 1 | 0 | 0 (This is one of DeMorgan's rules/theorems.) Q 2 --- You could have interpreted this question two ways (due to the ambiguous initial wording). The first way was just to round to four digits: 11.00111 rounds to 11.01 10.01101 rounds to 10.10 10.00100 rounds to 10.00 (half way between two representable numbers, 10.00 because of 0 in the final lsb) Or, you could have interpreted the question to mean put the result back into IEEE representation (so get rid of the hidden/most significant bit) So you'd really be rounding to 5 places. 11.00111 rounds to 11.011 10.01101 rounds to 10.100 10.00100 rounds to 10.001 Q 3 --- S E F (shortened) 0 10001000 111011 x 1 10000011 110100 ----------------------- multiply mantissas 1.111011 1.110100 -------- 12 2 2 1 carry row 000000 0 111101100 000 11110110000 111101100000 1111011000000 ------------- 11011110111100 then put binary point 12 places from rightmost bit 11.0111101111000 normalize: 1.10111101111000 * 2^1 round to 6 places after hidden bit: (use round towards nearest!) v 10111101111000 100000000 our upper "bound" (if closer to this go up when rounding) 01111000 000000000 our lower "bound" (if closer to this go down when rounding) 01111000 is closer to 000000000, so round down: F field is 101111 (NOTE: rounding up would have caused 110000) add true exponents: 10001000 => 136 base 10 - 127 => 9 10000011 => 131 base 10 - 127 => 4 9 + 4 = 13 13 + (normalization) 1 = 14 15 + 127 (rebias) = 141 => 10001101 base 2 Final SEF: 1 10001101 101111 (sign bit is one, of course) Q 4 --- (8 - 0) x 11 + (10 - 0) = 98 98 x 4 bytes/word = 392 bytes from beginning of array address is 1392 Q 5 --- ############################################################# # # Convert a 8*6 array of integers stored as colomn-major to # raw-major # ############################################################# .data base_addr: word source_addr: word dest_addr: word row: word 0 #row number counter col: word 0 #column number counter source: word 0:48 dest: word 0:48 .text la source_addr, source la base_addr, dest init: move row, 0 #copy_col copies each column into it's corresponding new position copy_col: mul tmp1, row, 32 mul tmp2, col, 4 add dest_addr, base_addr, tmp1 add dest_addr, dest_addr, tmp2 #Equation: newpos = row * 32 + col move M[dest_addr], M[source_addr] add source_addr, source_addr, 4 add row, row, 1 blt row, 6, copy_col add col, col, 1 blt col, 8, init #copy next column done Q 6 --- X = 0xff00a00b = 1111 1111 0000 0000 1010 0000 0000 1011 Y = 0x8001ff00 = 1000 0000 0000 0001 1111 1111 0000 0000 (a) and Z, X, Y X = 1111 1111 0000 0000 1010 0000 0000 1011 Y = 1000 0000 0000 0001 1111 1111 0000 0000 ----------------------------------- Z = 1000 0000 0000 0000 1010 0000 0000 0000 Hexadecimal: Z = 0x8000a000 (b) or Z, Y, X Y = 1000 0000 0000 0001 1111 1111 0000 0000 X = 1111 1111 0000 0000 1010 0000 0000 1011 ------------------------------------------- Z = 1111 1111 0000 0001 1111 1111 0000 1011 Hexadecimal: Z = 0xff01ff0b (c) nor, Z, X, X X = 1111 1111 0000 0000 1010 0000 0000 1011 X = 1111 1111 0000 0000 1010 0000 0000 1011 ------------------------------------------- Z = 0000 0000 1111 1111 0101 1111 1111 0100 Hexadecimal: Z = 0x00ff5ff4 (d) sra Z, Y, 3 shift right arithmetic performs sign extension Y = 1000 0000 0000 0001 1111 1111 0000 0000 ------------------------------------------- Z = 1111 0000 0000 0000 0011 1111 1110 0000 Hexadecimal: Z = 0xf0003fe0 (e) rol Z, X, 5 rotation left wraps bits around X = 1111 1111 0000 0000 1010 0000 0000 1011 ------------------------------------------- Z = 1110 0000 0001 0100 0000 0001 0111 1111 In dexadcimal, Z = 0xe014017f (f) sll Z, Y, 8 shift left logical pads the right with zeros Y = 1000 0000 0000 0001 1111 1111 0000 0000 ------------------------------------------- Z = 0000 0001 1111 1111 0000 0000 0000 0000 Hexadecimal: Z = 0x01ff0000