============================= Answers for Lab 06 (math lab) ============================= - Ian! D. Allen - idallen@idallen.ca - www.idallen.com References: ECOA2e Section 2.6.3, 2.6.4, 3.2.13.2.4, 4.14.6, 4.8.14.9.1, 4.9.3, 4.10, 4.11.14.11.2 and associated Chapter Slides. Class Notes (via course home page): bit_operations.txt, text_errata.txt, etc. 1.Give the range of unprintable ASCII "Control" characters in decimal and hexadecimal. (Section 2.6.3) 0-31, 0x00-0x1F 2.How many bits are needed to represent the unprintable ASCII "Control" characters? [32 numbers needs 5 bits (2**5 == 32)] 3.What is the name and hexadecimal and decimal value of the first printable character (first non-Control character) in the ASCII character set? ["SP" or "Space" (with value 32, or 0x20)] 4.The ASCII code for Z is decimal 90 (0x5A). Derive the code for CTRL-Z in decimal and hex. [mask off the non-ctrl bits: 0x5A & 0x1F = 0x1A = 26] 5.If the ASCII code for Z is decimal 90 (0x5A), what is the code for Y in decimal and hex? [90 - 1 = 89; 0x5A - 1 = 0x59] 6.What ASCII value do you get if you subtract the code for Space from the code for lower-case m? (see Table 2.7 p.79) [0x6D - 0x20 = 0x4D = 'M'] 7.Does the above subtraction transform work for all the lower-case ASCII letters? [yes] 8.Represent the seven-bit ASCII character Z in eight bits using odd parity. (Section 2.6.3) ['Z' = 0x5A = 1011010 --> 11011010 odd parity] 9.Represent the seven-bit ASCII control character CTRL-Z in eight bits using odd parity. ['CTRL-Z' = 0x1A = 0011010 --> 00011010 odd parity] 10.You look into memory and you see the value 0x5A5A. How can you tell if this is two ASCII letters or a numeric data value? [you cannot] 11.How many bytes does it take to store a Unicode character? (Section 2.6.4) [two (16 bits per Unicodecharacter)] 12.True - the first 128 characters of Unicode (0x0000 to 0x007F) are the same as ASCII. (p.80) 13.Construct a Boolean truth table for xyz + (xyz)' [where the prime mark indicates complement]. (p.155) [see (1a) p.759] 14.Construct a Boolean truth table for x(yz'+x'y) [where the prime mark indicates complement]. (p.155) [see (1b) p.759] 15.Give both versions of deMorgan's Law (p.113): [see Table 3.5 p.113] 16.Using deMorgan's Law, write an expression for the Boolean complement of x(y'+z). (p.155 and Section 3.2.2-3.2.4) [see (3) p.759] 17.Using deMorgan's Law, write an expression for the Boolean complement of xy+x'z+yz'. (Section 3.2.2-3.2.4) [(xy + x'z + yz')' = (xy)'(x'z)'(yz')' = (x' + y')(x + z')(y' + z) = (x'x + x'z' + y'x + y'z')(y' + z) = (x'z' + xy' + y'z')(y' + z) = x'y'z' + x'z'z + xy'y' + xy'z + y'z'y' + y'z'z = x'y'z' + xy' + xy'z + y'z' = (x + 1)y'z' + xy' + xy'z = y'z' + xy' + xy'z = y'z' + xy'(z + 1) = y'z' + xy' = y'(x + z')] 18.Avoiding a Common Error: Use a truth table to show that (xy)' is not equal to x'y' and (x+y)' is not equal to x'+y'. (i.e. "not red Jello" is much more specific than "not red and not Jello".) (bottom p.113) x y x' y' xy (xy)' x'y' x+y (x+y)' x'+y' 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 1 0 0 19-20.Express in hexadecimal the value stored in memory by each of the following C bitwise expressions: char x = ~0x1; [ 0xFE (8 bits flip) ] char x = ~0x10; [ 0xEF ] char x = ~0 & 0xAA; [ 0xAA ] int x = ~0x1; [ 0xFFFFFFFE (32 bits flip) ] int x = ~0x10; [ 0xFFFFFFEF ] int x = ~0 & 0xAA; [ 0x000000AA ] char x = 0x11 | 0xAA; [ 0xBB ] 21.Give (hex) a bit mask that will mask off (zero) everything except a MARIE opcode: [ 0xF000 ] 22.Give (hex) a bit mask that will mask off (zero) everything except a MARIE address: [ 0x0FFF ] 23.Give a C language expression that will turn an ASCII Control character "ch" into the corresponding ASCII lower-case letter: [ char lower = ch | 0x60 ] 24.How many address bits do you need to address byte-addressable 2Mx32 memory? [ see 3a p.237 and p.764 ] 25.How many address bits do you need to address word-addressable 2Mx32 memory? [ see 3b p.237 and p.764 ] 26.How many address bits do you need to address byte-addressable 4Mx16 memory? [ 4Mx16 = 2**2 * 2**20 * 2**1 bytes --> 23 address lines ] 27.How many address bits do you need to address word-addressable 4Mx16 memory? [ 4Mx16 = 2**2 * 2**20 words --> 22 address lines ] 28.Question 8, p.238: a) [8] b) [16] c) [2**16] d) [(2**24)-1] 29.Question 9, p.238: a) [see 9a p.238 and p.764] b) [see 9b p.238 and p.764] c) [ 2**18 words with addresses 0 through (2**18)-1 ] 30.Memorize the names and functions of the seven MARIE registers on p.191. Write the full names of the registers here: [ see text ] 31.True - unlike MARIE, modern computers have multiple general-purpose registers. (p.192) 32.True - unlike MARIE, the ISAs of modern computers have hundreds of instructions. (p.193) 33.Memorize the meanings of the nine basic MARIE instructions in Table 4.2. Reproduce that table here: [ see text ]