====================================================== Assignment #05 - Shifts, Dumps, Characters, and Memory ====================================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Friday October 22, 2010 Upload due date in the Blackboard Assignment Area: Upload "assignment05.txt" before 19:00 (7pm) on Thursday October 28, 2010 Answers will be posted shortly after the due date/time and discussed in class, if there are any questions about the answers. Submission method: Upload via the "Assignments" assignment05 upload. Use the file name given above. Upload only one single file of plain text, not HTML, not MSWord. No fonts, no word-processing. Plain text only. Did I mention that the format is plain text (e.g. using Notepad)? Answers will be posted after the due date/time so that you can check your answers before coming to class and ask questions about the answers in class. Please check your answers (and my answers!). I go over each assignment in class if there are questions about the answers. No questions means no review - I'll presume you know the material. Questions similar to ones on these assignments will appear on your tests and exams. Not all assignments will be marked. See the Week 1 Notes for details. ============================================================================== Edit this file and answer the following questions, showing the method or formula you used to get the answer. Upload the file containing the methods, formulas, questions and answers before the due date. Some of the answers below will require reading the links published in the weekly course notes. ============================================================================== 0. What is the date of your second midterm test? *** Numeric Section *** 1. Show that Christmas == Halloween by converting DEC 25 (Christmas) to OCT 31 (Halloween), i.e. show that DECimal 25 is equal to OCTal 31 2. In a 16-bit word, unsigned, what is the decimal value of the top bit? (What is the decimal value of an unsigned binary 16-bit number that has only the highest bit set?) 3. True/False: The most negative two's complement number has only the sign bit turned on and all the other bits are zeroes. 4. True/False: Two's complement -1 is always "all bits on". 5. True/False: Decimal 0.00012 x 10**41 fits in IEEE 754 single precision floating point. 6. True/False: Decimal 100.0 x 10**37 fits in IEEE 754 single precision floating point. 7. What is the byte ordering of Intel-based computers? 8. The following hexadecimal memory dump contains two big-endian three-byte two's-complement integers, starting at address 215. What decimal values do these two big-endian three-byte integers have? ADDRESS: ---------- BIG-ENDIAN MEMORY BYTES ------------ 200: 65 6E 76 20 5F 4C 45 56 45 4C 20 24 5F 74 65 6D 210: 70 0A 65 6E 64 00 01 0A FF FD F5 28 20 24 3F 70 220: 72 6F 6D 70 74 20 29 20 74 68 65 6E 0A 09 69 66 230: 20 28 20 22 24 70 72 6F 6D 70 74 22 20 21 3D 20 240: 22 22 20 29 20 74 68 65 6E 0A 09 09 69 66 20 28 9. What happens mathematically to the value of a binary number if you "shift" the bits to the right one place by deleting the rightmost binary digit, e.g. 1100 --> 0110 10. What happens to the range of values possible in a word if you increase the word length by one bit, e.g. from eight bits to nine bits or from 100 bits to 101 bits? 11. What happens to the value of a binary number if you "shift" the bits to the left two places by adding two zeros after the rightmost binary digit, e.g. 11001(2) --> 1100100(2) 12. What happens to the value of an octal number if you "shift" the number to the left one place by adding one octal zero after the rightmost octal digit, e.g. 0177(8) --> 01770(8) 13. What happens to the value of a hexadecimal number if you "shift" the number to the left one place by adding one hex zero after the rightmost hex digit, e.g. 0xABF --> 0xABF0 14. What is the difference between a Logical Right Shift and an Arithmetic Right Shift? 15. Of what use is an Arithmetic Right Shift? 16. Is it still true that shifting a binary number left one bit multiplies it by two, if the number is a negative two's complement number? 17. Is it still true that shifting a binary number right one bit divides it by two, if the number is a negative two's complement number? *** Character Section *** 18. The nine-character upper-case ASCII text string "ABCDEFGHI" is stored in memory starting at address location zero. a) Give the nine hexadecimal bytes stored in memory at location zero: b) Interpret just four bytes starting at address location 1 (not zero) as two 16-bit two's complement integers in big-endian form and give their two decimal values: c) Interpret just six bytes starting at address location zero as two 24-bit two's complement integers in little-endian form and give their two decimal values: d) Interpret just four bytes starting at address location 2 as two 16-bit two's complement integers in big-endian form, and add one to each of these big-endian integers in memory. Give the resulting changed nine-character ASCII text string in memory (Hint: only two of the ASCII characters change): 19. Under what operating system was the following ASCII text file created? How do you know? 4B 68 6D 74 77 0A 51 6E 62 6C 72 5B 20 0A 20. What type of operating system produced the following ASCII text (in hex)? How do you know? 43 40 53 31 32 33 32 0D 0A 21. Under what operating system was the following text file created? How do you know? 4D 6A 6F 76 79 0D 53 6F 64 6C 74 5D 22 0D 22. What advantage does UTF-8 have over Unicode for English text? 23. True/False: Plain English text, encoded as ASCII, is identical to the same Plain English text encoded as UTF-8. 24. Encode the following four ASCII characters in hexadecimal using 8-bit Even Parity: a) A b) a c) B d) b 25. Encode the following four ASCII characters in hexadecimal using 8-bit Odd Parity: a) A b) a c) B d) b 26. The following ASCII byte is received from a system that generates 8-bit Even Parity: 0xA4 Is there an error in the byte? How do you know? 27. The following ASCII byte is received from a system that generates 8-bit Odd Parity: 0xA7 Is there an error in the byte? How do you know? 28. You look into memory and see the hexadecimal value 40h. Based on what you know in this course so far, what different things might this 40h represent? *** Memory Section *** 29. What do the acronyms RAM, ROM, and EEPROM stand for? RAM = ROM = EEPROM = 30. Is the BIOS in your computer stored in RAM or ROM? 31. Put these in increasing order of access time (faster on top to slower) and indicate beside each type of device approximately what its access time is: Fixed Hard Disk Optical Disk Level 1 Cache Registers Level 2 Cache Magnetic Tape Main Memory 32. Define "a cache hit": 33. Define "a cache miss": 34. List and briefly describe the three Principles of Locality: 35. With reference to cache size, why is a small loop of code often faster than a large loop? 36. What is the basic feature that Virtual Memory enables? 37. What is the difference between a Physical Address and a Virtual Address? 38. What is a "page fault"? 39. How much slower (orders of magnitude) is a page fault compared to an ordinary memory access that does not cause a page fault? 40. With reference to virtual memory, why is a small program often faster than a large program? 41. What is virtual memory "thrashing"? 42. With reference to Chapter 6 Slides 46-47, describe what happens when the CPU generates the 13-bit Virtual Address 1800h: 43. With reference to Chapter 6 Slides 46-47, describe what happens when the CPU generates the 13-bit Virtual Address 1C00h: 44. The code that the operating system uses to service Page Faults cannot itself reside in Virtual Memory - it must always remain in actual Physical Memory. Why can't it be in Virtual Memory? -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/