CS2011, A Term 1999 Prof. Sergio A. Alvarez HW1 Solutions Total point count for HW1: 50 1) Perform the following base conversions. Show your work. a) 551 d to binary notation. 551/2 = 275, remainder 1 => bit position 0 contains 1 275/2 = 137, remainder 1 => bit position 1 contains 1 137/2 = 68, remainder 1 => bit position 2 contains 1 68/2 = 34, remainder 0 => bit position 3 contains 0 34/2 = 17, remainder 0 => bit position 4 contains 0 17/2 = 8, remainder 1 => bit position 5 contains 1 8/2 = 4, remainder 0 => bit position 6 contains 0 4/2 = 2, remainder 0 => bit position 7 contains 0 2/2 = 1, remainder 0 => bit position 8 contains 0 1/2 = 0, remainder 1 => bit position 9 contains 1 Final answer: 551 d = 1000100111 b (5 pts) --- b) 12A5 h to decimal notation. 12A5 h = 1*16^3 + 2*16^2 + 10*16^1 + 5 = 16 (256 + 2*16 + 10) + 5 = 16*(298) + 5 = 4773 d (5 pts) --- 2) Express the integer -23 d in each of the following notations (8 bits): a) sign-magnitude: -23 d = 1(sign) 0010111(magnitude) = 10010111 b) ones complement: -23 d = -(00010111) = 11101000 (bitwise complement) c) twos complement: -23 d = 11101000 + 00000001 = 11101001 (total for problem 2: 15 points) 5 points for each of the three answers. --- 3) Write -7.1875 d in single precision IEEE floating point standard 754 notation. Express your answer in hex format: +7.1875 d = 2^2 + 2^1 + 2^0 + 2^(-3) + 2^(-4) = 111.0011 b = 1.110011 b * 2^2 leading sign bit is 1, for (-) exponent in excess 127 notation is 2 + 127 = 129 d = 10000001 b mantissa without leading 1 is 110011 (17 0's) IEEE 754 representation is therefore 1 10000001 110011 (17 0's) = 1100 0000 1110 0110 0000 0000 0000 0000 = C0E60000 h (10 pts total) --- 4) Assume that the debug utility initially shows the 8086 register/memory contents to be as follows: AX=0000 BX=0000 CX=0000 DX=0000 SP=FF0C BP=0000 SI=0000 DI=0000 DS=12EB ES=12EB SS=12EB CS=0F76 IP=0105 NV UP EI PL NZ NA PO NC 0F76:0105 8B4C05 MOV CX,[SI+05] a) Give the new contents of the IP register after the next instruction is executed. IP now contains 0105 + (bytelength of current instruction) = 0105 + bytelength of 8B4C05 = 0105 + 3 = 0108 (5 pts) --- b) What are the (hex) contents of registers AX, BX after executing the following instructions ? (Assume the 123 and -57 to be in decimal) mov ax,123 mov bx,-57 mov [0500],ax mov [0506],bx AX contains 007Bh, BX contains FFC7h (5 pts) --- c) Give the full address in segment:offset form and contents (in hex) of each of the four distinct memory locations (bytes) that are changed by executing the instructions in b). address contents 12EB:0500 7B 12EB:0501 00 ... 12EB:0506 C7 12EB:0507 FF (5 pts)