CIS5220 Fall 2005 Exam #1, open book, open notes. Grade __________________ 1. Convert the following 8 bit, 2's complement binary numbers to signed decimal (5 pts each). 00010101 ANSWER = 21 11111100 ANSWER = -4 2. Add the following 32-bit unsigned hexadecimal numbers to produce a 32-bit hexadecimal result (5 pts). 9000240F + 7000FFFF ANSWER = 0001240E 3. Convert 1BADFACE from hexadecimal to binary (5 pts). ANSWER = 0001 1011 1010 1101 1111 1010 1100 1110 (spaces optional) 4. Write the following numbers in IEEE754 32-bit floating point format with 1 sign bit, 8 exponent bits in excess 127 format, and 23 bit mantissa with the 1. bit before the decimal not shown. The first problem is completed (5 pts each). 1.0 0 01111111 00000000000000000000000 ANSWERS 0.25 0 01111101 00000000000000000000000 -3.5 1 10000000 11000000000000000000000 5. Convert 1 10000100 10000000000000000000000 to decimal (5 pts). ANSWER = -48 6. Compute the following using signed 4 bit arithmetic (range -8 to 7). Give answers in decimal (5 pts each). ANSWERS 6 + 5 -5 3 x 5 -1 2 - 7 -5 -7 - 1 -8 7. What range of values can be represented by an 8 bit, 2's compliment signed number (5 pts)? ANSWER -128 through 127 8. Write a program for the Little Man Computer to convert lower case text to upper case. The program should start at address 0 and run forever. Each input should be interpreted as an ASCII code. If the code is for a lower case letter, then output the corresponding upper case letter. For all other input values, output the same value (40 pts). ASCII Table Little Man Computer Instruction Set 10 = linefeed 000 = halt 13 = carriage return 1xx = add address xx 32 = space 2xx = subtract address xx 48..57 = '0'..'9' 3xx = store at address xx 65..90 = 'A'..'Z' 5xx = load from address xx 97..122 = 'a'..'z' 6xx = branch to xx 7xx = branch to xx if 0 8xx = branch to xx if 0 or positive 901 = input 902 = output ANSWER (but there are many other possibilities). The code works like this: start: input c if (c < 'a') goto 11 if (c > 'z') goto 11 output c - 32 goto start 11: output c goto start 00 901 Input a character 01 399 Save at 99 02 214 Subtract 'a' 03 611 If less, skip conversion 04 515 Load 'z' + 1 05 299 Subtract input character 06 611 If character > 'z' skip conversion 07 399 Load character, which at this point must be a lower case letter 08 216 Subtract 32, converting to upper case 09 902 Output upper case letter 10 600 Done, go back to start 11 399 Jump here to skip conversion, load character, which is not lower case 12 902 Output as is 13 600 Done, go back to start 14 097 Constant 'a' 15 123 Constant 'z' + 1 16 032 Constant 32 = 'a' - 'A'