% Author: Ian! D. Allen - idallen@idallen.ca - www.idallen.com % Date: Fall 2011 - September to December 2011 - Updated 2011-10-19 07:18 EDT % Title: Week 07 Notes for CST8281 - Fall 2011 - [Course Home Page] - [Course Outline] - [All Weeks] - [Plain Text] Lecture Notes for This Week =========================== From the Class Notes link on the Course Home Page ------------------------------------------------- - [Course Home Page] - [All Weeks] - [120_CharacterEncoding.html] - Character Encoding / Line Ends - know these Seven Famous ASCII Characters: 0D 0A 20 30 41 61 7F - do not memorize any EBCDIC - [130_big_picture.txt] - The Big Picture on Bit Patterns - [140_attack.txt] - Remote Attack Script uses hexadecimal obfuscation - [145_textbook_secrets.txt] - Alcatel-Lucent Traning Manual containing secret messages in hexadecimal - [200_DEBUGbasics.html] - [200_DEBUGhelp.txt] ### Assignments - [Assignment #06] - midterm corrections. From Blackboard Course Documents -------------------------------- These documents have restricted distribution and cannot be put on the [Course Home Page]. - [02.ppt] - Data Representation - Character encoding: ASCII, Unicode, Line Endings - [06.ppt][02.ppt] - Memory - see memory speeds on slide 7 - ignore slides 12-34, 37 - see memory types, memory hierarchy (speeds), cache, virtual memory - omit the rest of this slide set - [03.ppt][02.ppt] - Boolean Algebra and Digital Logic - ignore Digital Logic and slides 19-73, 75-76 - Boolean Algebra From the Internet ----------------- - - - - - - a joint ISO and IEC series of standards for 8-bit character encodings - - The ISO 8859 Alphabet Soup - - - - Bitwise Operators in Java - - From the Classroom Whiteboard/Chalkboard ---------------------------------------- - Your in-class notes go here. ### Character Encoding - Character codes: ASCII, extended ASCII, EBCDIC, Unicode, UTF-8 - ASCII Control Characters (unprintable) - line ends for text files on Unix/Mac/Windows - reading character tables - compare ASCII & EBCDIC for sort order and common printable characters - ASCII puts ‘A’ before ‘a’; EBCDIC does the reverse - tabs vs. spaces - know the Seven Famous ASCII Characters - 0D 0A 20 30 41 61 7F - do not memorize any EBCDIC - how to print the decimal value of 00001111(2) on the screen in ASCII? - decimal value is 15: send 31h and 35h (“1” and “5”) - Problems with all the 8-bit extended-ASCII character sets - can’t have Latin1 French and Latin2 Polish in the same text file: why? - UTF-8 advantages and disadvantages - same as ASCII, no endian-ness, multi-byte, full Unicode, may require more bytes than Unicode due to encoding scheme - Fonts vs. Character codes - codes only say what letter, not what it looks like - Why can’t French (Latin1) and Polish (Latin2) exist in the same text file? - same problem for all the 8-bit extended-ASCII character sets - How many ASCII characters are there? - What is the difference between ‘A’ and ‘a’? ‘M’ and ‘m’? ‘Z’ and ‘z’? - How many ASCII control characters (unprintable) are there? - what are their hex values? ### Boolean Algebra / Bitwise Operators - Shifting numbers right and left - shifiting effect on two’s complement numbers: does it work? - Arithmetic Right Shift vs. Logical Right Shift - duplicate the top (carry) bit for Arithmetic Right Shift - F4240h = 1,000,000(10) - so F42400h = 1,000,000 * 16 = 16,000,000 - so F424h = 1,000,000/16 = 1000000 * 0.0625 = 100 * 625 = 62,500 - 03641100(8) = 1,000,000(10) - so 036411000 = 1,000,000 * 8 = 8,000,000 - 1010(2) = 10 decimal - so 101000(2) = 10 * 2 * 2 = 40 decimal - Bitwise Operators AND, OR, XOR, NOT (in Java: `& | ^ ~`) - don’t confuse bitwise with logical: `&` with `&&`, `|` with `||`, or `~` with `!` - if x=1, y=2 then x&y = 0 (no bits in common) - if x=6, y=12 then x&y = 4 (one bit in common) - XOR is *Exclusive OR* - A or B but *not* both - true OR true is true - true XOR true is false - if a=6,b=3 what is `a&b`? what is `a|b`? what is `a^b`? what is `~a`? - if a=5,b=10 what is `a&b`? what is `a|b`? what is `a^b`? what is `~a`? - **Note**: All integer types in Java are signed (except char)! - see - Java has a special unsigned (“logical”) right shift operator: `>>>` - need to use bit masking for unsigned arithmetic - Conversions between upper/lower in ASCII using bitwise OR and AND: - `'A' | ' ' = 'a'` (OR turns on the 20h bit, making it lower-case) - `'a' & ~' ' = 'A'` (AND turns off the 20h bit, making it upper-case) - ASCII parity bit, used to detect errors in data transmission - is ‘A’ even or odd parity? convert it to even parity, then to odd - is CR even or odd parity? convert it to even parity, then to odd - Simplifying complex logic using Boolen Algebra - identities - deMorgan 1. simplify: `if ((x < y) && (y < z))` `||` `((x < y) && (y >=z ))` - simplifies to just `if (x < y)` because: - let `a = (x=z)` - rewrite `ab+ab' = a(b+b') = a(1) = a = (x 120` and `amount > 0` 1. simplify: print unless **stale** - *unless stale* means **if NOT** *stale* - `print if NOT` `(date > 120 && amt > 0)` - using deMorgan: `print if` `(date <= 120 || amt <= 0)` 2. simplify: `print unless` `(stale and amt < 0)` - `print if NOT` `(stale && amt < 0)` - `print if` `( !stale || amt >= 0)` - `print if` `( date <= 120 || amt <= 0 || amt >= 0)` - `print if` `( date <= 120 || TRUE )` - therefore: always print (probably an error in the specifications!) 3. Show that `(xy + x'z + yz')' = y'(x+z')` - `(x'+y')(x+z')(y'+z) -`- deMorgan - `(x'x + x'z' + xy' + y'z')(y'+z) -`- expand first two expressions - `( 0 + x'z' + xy' + y'z')(y'+z) -`- identities - `x'y'z' + x'z'z + xy'y' + xy'z + y'y'z' + y'z'z -`- expand again - `x'y'z' + 0 + xy' + xy'z + y'z' + 0 -`- identities - `x'y'z' + y'z' + xy' + xy'z -`- regroup similar terms - `y'z' + xy' -`- absorption rule - `y'(x+z') -`- QED Midterm Test #1 - 15% ====================== - Midterm Test One Results: 100 96.7 96.7 93.3 93.3 93.3 90 90 86.7 83.3 83.3 79.2 76.7 76.7 76.7 76.7 76.7 76.7 76.7 73.3 73.3 73.3 73.3 73.3 70 66.7 66.7 66.7 66.7 66.7 62.7 60 60 60 56.7 56.7 56.1 53.3 53.3 46.7 46.7 46.7 46.7 43.3 42.9 40 33.3 33 30 30 29.7 29.7 26.7 23.3 20 20 13.3 - See [Assignment #06] - midterm corrections. Self-Mark 03 ============ - COUNT=36 AVERAGE 2.2 Q1=2.7 Q2=2.6 Q3=2.5 Q4=2.7 Q5=2.1 Q6=2.4 Q7=2.2 Q8=2.6 Q9=2.6 Q10=2.5 Q11=2.3 Q12=2.4 Q13=2.2 Q14=2.4 Q15=2.7 Q16=2.4 Q17=2.2 Q18=2.2 Q19=2.5 Q20=2.6 Q21=2.2 Q22=2.0 Q23=2.1 Q24=2.5 Q25=2.1 Q26=2.4 Q27=2.2 Q28=2.2 Q29=2.1 Q30=2.0 Q31=2.0 Q32=2.3 Q33=2.3 Q34=2.3 Q35=2.1 Q36=1.9 Q37=1.7 Q38=2.2 Q39=2.2 Q40=2.2 Q41=1.6 Q42=2.5 Q43=2.2 Q44=2.2 Q45=2.1 Q46=1.9 Q47=2.2 Q48=1.8 Q49=1.9 Q50=1.9 Q51=1.8 Q52=2.3 Self-Mark 04 ============ - COUNT=40 AVERAGE 2.3 Q1=2.5 Q2=2.5 Q3=2.5 Q4=2.6 Q5=2.6 Q6=2.5 Q7=2.5 Q8=2.6 Q9=2.5 Q10=2.4 Q11=2.6 Q12=2.5 Q13=2.5 Q14=2.6 Q15=2.4 Q16=2.2 Q17=2.4 Q18=2.5 Q19=2.3 Q20=2.4 Q21=2.5 Q22=2.4 Q23=2.2 Q24=2.2 Q25=1.9 Q26=2.0 Q27=2.1 Q28=2.3 Q29=2.4 Q30=2.4 Q31=2.3 Q32=2.3 Q33=2.4 Q34=2.4 Q35=2.4 Q36=2.4 Q37=2.4 Q38=2.0 Q39=2.1 Q40=2.1 Q41=1.8 Q42=1.4 Q43=1.8 Q44=1.9 Q45=1.9 Q46=1.8 Q47=1.7 Q48=1.9 -- | 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/ [Plain Text] - plain text version of this page in [Pandoc Markdown] format [Course Home Page]: .. [Course Outline]: course_outline.pdf [All Weeks]: indexcgi.cgi [Plain Text]: week07notes.txt [120_CharacterEncoding.html]: 120_CharacterEncoding.html [130_big_picture.txt]: 130_big_picture.txt [140_attack.txt]: 140_attack.txt [145_textbook_secrets.txt]: 145_textbook_secrets.txt [200_DEBUGbasics.html]: 200_DEBUGbasics.html [200_DEBUGhelp.txt]: 200_DEBUGhelp.txt [Assignment #06]: assignment06.txt [02.ppt]: http://blackboard.algonquincollege.com/ [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/