ASCII Nonnumeric Types 1 The American Standard Code

  • Slides: 10
Download presentation
ASCII Non-numeric Types 1 The American Standard Code for Information Interchange maps a set

ASCII Non-numeric Types 1 The American Standard Code for Information Interchange maps a set of 128 characters into the set of integers from 0 to 127, requiring 7 bits for each numeric code: 95 of the characters are "printable" and are mapped into the codes 32 to 126: The remainder are special control codes (e. g. , WRU, tab, line feed, etc. ). Since the fundamental unit of data storage was quickly standardized as an 8 -bit byte, the high bit was generally either set to 0 or used as a parity-check bit. CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

Some ASCII Features Non-numeric Types 2 The decimal digits '0' through '9' are assigned

Some ASCII Features Non-numeric Types 2 The decimal digits '0' through '9' are assigned sequential codes. Therefore, the numeric value of a digit can be obtained by subtraction: '7' – '0' = 7 The upper-case characters 'A' through 'Z' are also assigned sequential codes, as are the lower-case characters 'a' through 'z'. This aids in sorting of character strings, but note that upper-case characters have lowervalued codes than do upper-case characters. There are no new operations, but since ASCII codes are numeric values, it is often possible to perform arithmetic on them to achieve useful results… CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

ASCII Table Non-numeric Types 3 It's easy to find ASCII tables online (including some

ASCII Table Non-numeric Types 3 It's easy to find ASCII tables online (including some that are clearer than this one): 0 1 2 3 4 5 6 7 8 9 NUL SOH STX EOT ENQ ACK BEL BS HT DLE DC 1 DC 2 DC 3 DC 4 NAK SYN ETB CAN EM SP ! " # $ % & ' ( ) 0 1 2 3 4 5 6 7 8 9 @ A B C D E F G H I P Q R S T U V W X Y ` a b c d e f g h i p q r s t u v w x y CS@VT August 2009 Computer Organization I A B C LF VT FF SUB ESC FS * + , : ; < J K L Z [ j k l z { | D CR GS = M ] m } E F SO SI RS US. / > ? N O ^ _ n o ~ DEL © 2006 -09 Mc. Quain, Feng & Ribbens

Extended ASCII Non-numeric Types 4 For good or ill, the ASCII codes are 7

Extended ASCII Non-numeric Types 4 For good or ill, the ASCII codes are 7 -bit codes, and that leads to temptation. There exist 8 -bit character encodings that extend the ASCII codes to provide for 256 different characters (e. g. , ISO_8859 -1: 1987). Unfortunately, none of these has achieved the status of a practical Standard in use. CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

Unicode Non-numeric Types 5 Whether viewed as a 7 -bit code or extended to

Unicode Non-numeric Types 5 Whether viewed as a 7 -bit code or extended to an 8 -bit code, ASCII provides for only 256 different characters. Unicode is an ongoing scheme to eliminate this shortcoming and provide for a standard way to deal with an unlimited number of characters, using binary encodings ranging from 8 to 32 bits. A full explanation is beyond the mandate for this course; you can find a very good discussion at: http: //www. joelonsoftware. com/articles/Unicode. html For our purposes, it is sufficient to understand how the ASCII representation affects the way one programs for character data. CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

In closing… Non-numeric Types 6 ____. -'& '-. / :  o ( o

In closing… Non-numeric Types 6 ____. -'& '-. / : o ( o ; (_ ) : ; __ / `-. _____. -' /`"""` / , /|/// _ (_|///\__) |_______| __)_ |_ (_____|_____) CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

Boolean Logical Values Non-numeric Types 7 We must represent two values, TRUE and FALSE,

Boolean Logical Values Non-numeric Types 7 We must represent two values, TRUE and FALSE, so a single bit suffices. We will represent TRUE by 1 and FALSE by 0. Thus, a sequence of bits can be viewed as a sequence of logical values. Note: this is not the view typically taken in high-level languages! CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

Boolean Logical Operations Non-numeric Types 8 Given two Boolean logical values, there a number

Boolean Logical Operations Non-numeric Types 8 Given two Boolean logical values, there a number of operations we can perform: A NOT A -------0 1 1 0 A B A XOR B ------0 0 1 1 1 0 CS@VT August 2009 A B A AND B ------0 0 1 1 1 A B A OR B ------0 0 1 1 1 0 1 1 A B A NOR B ------0 0 1 0 1 0 0 1 1 0 Computer Organization I A B A NAND B -------0 0 1 1 1 0 A B A XNOR B -------0 0 1 0 1 0 0 1 1 1 © 2006 -09 Mc. Quain, Feng & Ribbens

Applications of Boolean Logical Operations Non-numeric Types 9 AND can be used to clear

Applications of Boolean Logical Operations Non-numeric Types 9 AND can be used to clear (set to 0) selected bits in a value (bit-mask): X: 1110 0101 X AND Y: 1110 0000 Y: 1111 0000 OR can be used to set (set to 1) selected bits in a value: X: 1110 0101 X OR Y: 1110 1111 Y: 0000 1111 Of course, NOT flips the bits. We'll see uses of the others as we proceed… CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens

Operator Precedence Rules Non-numeric Types 10 Research this!! Take a look at Herstein and

Operator Precedence Rules Non-numeric Types 10 Research this!! Take a look at Herstein and Jacobsen and see what they have to say on the subject WRT Boolean algebras. X: 1110 0101 X AND Y: 1110 0000 Y: 1111 0000 CS@VT August 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens