=========================================== Assignment #03 - Conversions and Characters =========================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com 1. Convert these unsigned 12-bit hex numbers into decimal: D8A 948 C8B ACE 276 35A 839 BDF ANSWERS: 3466 2376 3211 2766 630 858 2105 3039 e.g. D8A as an unsigned number is just powers of sixteen in hex: A * 16**0 = 10 * 1 = 10 8 * 16**1 = 8 * 16 = 128 D * 16**2 = 13 * 256 = 3328 SUM = 3466 decimal 2. Convert the same hex numbers into decimal assuming 12-bit twos-complement: ANSWERS: -630 -1720 -885 -1330 630 858 -1991 -1057 e.g. D8A is negative in 12-bits, so bit flip to 275, add 1 giving 276 hex: 6 * 16**0 = 6 * 1 = 6 7 * 16**1 = 7 * 16 = 112 2 * 16**2 = 2 * 256 = 512 SUM = 630, so answer is -630 decimal 3. Convert the same hex numbers into decimal assuming 12-bit sign-magnitude: ANSWERS: -1418 -328 -1163 -718 630 858 -57 -991 e.g. D8A is negative in 12 bits, so look at remaining 11 bits 58A as magnitude: A * 16**0 = 10 * 1 = 10 8 * 16**1 = 8 * 16 = 128 5 * 16**2 = 5 * 256 = 1280 SUM = 1418, so answer is -1418 decimal 4. Convert the same hex numbers into decimal assuming 12-bit ones-complement: ANSWERS: -629 -1719 -884 -1329 630 858 -1990 -1056 e.g. D8A is negative in 12-bits, so bit flip to 275: 5 * 16**0 = 6 * 1 = 5 7 * 16**1 = 7 * 16 = 112 2 * 16**2 = 2 * 256 = 512 SUM = 629, so answer is -629 decimal 5. Try to do the following ASCII conversion exercises without using a previously created ASCII table - build a small table yourself from your memory of a few key ASCII character points. You won't have an ASCII table during the tests; you will need to remember a few key values and extrapolate from those. ASCII Letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A lower case: add 20h digit: 30h plus value of digit blank: 20h CR: 0Dh LF: 0Ah Convert the following two lines of text into an ASCII encoded sequence (shown in hexadecimal) assuming DOS/Windows line-endings for each line: DAT2343 Computer Systems Architecture ANSWER: 44 41 54 32 33 34 33 0D 0A 43 6F 6D 70 75 74 65 72 20 53 79 73 74 65 6D 73 20 41 72 63 68 69 74 65 63 74 75 72 65 0D 0A 6. Decode the hex sequence below into one or more lines of ASCII text. (Use the mini ASCII table you created from memory, above.) 4A 75 73 74 20 37 0D 44 61 7A 20 0D ANSWER: Just 7 Daz 7. What operating system is the likely source for the text in the question above, and how can you tell? ANSWERS: The unique 0D line endings are used by Apple Macintosh systems. 8. Convert the following 2 lines of text into an EBCDIC encoded sequence (shown in hexadecimal) using 8 character fixed-length records. (Remember: No line-end characters are used in fixed-length records.) You may use an existing EBCDIC table to look up the values. You will not be required to memorize any EBCDIC table values for any tests. EBCDIC Letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z C1 C2 C3 C4 C5 C6 C7 C8 C9 D1 D2 D3 D4 D5 D6 D7 D8 D9 E2 E3 E4 E5 E6 E7 E8 E9 lower case: subtract 40h digits: F0 + digit value blank: 40h 1 YEAR 52 weeks ANSWER: F1 40 E7 C5 C1 D9 40 40 F5 52 40 A6 85 85 92 A2 9. Decode the EBCDIC sequence, below, into one or more lines of text. You may use an existing EBCDIC table to look up the values. You will not be required to memorize any EBCDIC table values for any tests. C9 95 40 F1 F4 F9 F2 40 40 C3 96 93 A4 94 82 A4 A2 40 A2 81 89 93 85 84 40 40 40 E3 88 85 40 A2 85 81 40 40 ANSWER: In 1492 Columbus sailed The sea 10. What is the most likely record length for the data in the above question? ANSWER: likely 9, based on the word spacing 11. Encode the decimal values +274.625 and -12 as 32-bit IEEE-754 floating point fields and show your answers in hexadecimal. ANSWERS: 0x43895000 0xC1400000 12. Assuming the following eight-byte hex dump contains two Big-Endian, 32-bit, IEEE-754 encoded values: C2 2D C0 00 3F 60 00 00 decode both values shown in this dump as separate decimal values. ANSWERS: -43.4375 0.875 13. The IEEE 754 floating-point number 81234567h is negative. Without converting, give the hexadecimal for the same number, only positive. ANSWER: Turn off the top (sign) bit: 01234567h 14. The IEEE 754 floating-point number 7EDCBA98h is positive. Without converting, give the hexadecimal for the same number, only negative. ANSWER: Turn on the top (sign) bit: FEDCBA98h 15. Without converting, select all the IEEE 754 negative numbers: 1837A654h 7A6A3B65h 87B5CDE2h 90A5B5EFh A0000037h D1B8765Ah F0000000h ANSWER: Choose sign bits on: 87B5CDE2h 90A5B5EFh A0000037h D1B8765Ah F0000000h