© Nancy E. Reed, 1997 -- ECS 15 -- Fall 1997

Lecture 2 Notes
Digital Systems, Coding Systems, ASCII

Handouts:

Readings

Chapter 2 in your Computers text (Long & Long)

Analog vs. Digital Systems

There are two types of signals that different machines use. They are called analog and digital. Analog signals are continuous - they vary along a spectrum. For example, a watch with hands that move in a circle is an analog machine. Digital systems use discrete signals. An example is a digital watch. The readout changes from 12:01:37 to 12:01:38 without going through intermediate steps.

Another example of analog vs. digital systems can be found in sound recordings. Vinyl records store sounds in analog fashion. The level of the signal encodes the pitch and intensity of the sounds. Compact disks store sounds in digital fashion. The bits are read and converted into a signal to produce the sounds. CDs sound very crisp when you listen to them. Some sound information can be lost in digital recordings, however.

Today's computer systems are digital systems. They store information in discrete bits as we have seen. Each bit is either on or off. The levels of the signals do not vary in between on and off.

Coding Systems

Having established that today's computers use digital techniques, we turn next to what sort of codes are used to capture information. One might envision an analog keyboard, in which different voltages were assigned to each key, and the information stored in analog form. This method might work, but it would certainly lead to errors over time, and it would be dependent on a good deal of tuning to store the large number of different characters used by computers today.

For this reason (among others) we use digital coding techniques to store characters input from a keyboard. This decision forces us to make another decision: how many bits will we use to represent the characters? If we assume that we need at least 52 characters for the English alphabet, 10 for digits, about 30 or so for other symbols, and at least 10-15 for "control characters" such as the enter key, backspace, delete, etc, then we have a minimum of about 100 characters that we should be able to represent. How many bits does that translate into? To answer this question, we have to go back to a consideration of place value notation.

Decimal numbers use place value notation. We take it for granted, but what we are really saying when we write the number 9756 is:

     6 x 10 to the zero power (1) = 6; plus
     5 x 10 to the power 1 (10) = 50; plus
     7 x 10 to the power 2 (100) = 700; plus
     9 x 10 to the power 3 (1000) = 9000.

The concept of place value, then is that, starting with a base number we assign a value of that number raised to the powers 0, 1, 2, 3, ... from right to left, and the final number is the sum of each of those digits with their place value significance.

We could use other base numbers than 10. If we used 2, the number 1010 means

     0 x 2 to the power 0 (1) = 0; plus
     1 x 2 to the power 1 (2) = 2; plus
     0 x 2 to the power 2 (4) = 0; plus
     1 x 2 to the power 3 (8) = 8.

Therefore 1010 (base 2) is equivalent to 10 (base 10). Notice that, in base 2, we only have two different numbers available (0 and 1), whereas in base 10 we have 10 different numbers available (0 - 9, but not 10).

It is also possible to use other base numbers. One of the important ones used in computers is base 16. To represent 16 different numbers, we cannot use only decimal values (0-9), since we need more different characters. Instead, we will use 0, 1, ... 9, A, B, B, D, E, and F, giving us 16 different symbols. Using these "numbers" the number 24E means

     "E" x 16 to the power 0 (1) = 14; plus
     4   x 16 to the power 1 (16) = 64; plus
     2   x 16 to the power 2 (256) = 512.

In decimal notation, this number would be represented as 590.

ASCII Characters and their Code Representation

Returning to the question that started us thinking about place value: if we need to represent at least 100 characters, and we are going to use binary (base 2) numbers, we have to have at least 7 bits. The number 1111111 (base 2) means

     1 x 2 to 0 (1) = 1; (sum so far = 1) plus
     1 x 2 to 1 (2) = 2; (sum so far = 3) plus
     1 x 2 to 2 (4) = 4; (sum so far = 7) plus
     1 x 2 to 3 (8) = 8; (sum so far = 15) plus
     1 x 2 to 4 (16) = 16 (sum so far = 31) plus
     1 x 2 to 5 (32) = 32 (sum so far = 63) plus
     1 x 2 to 6 (64) = 64 (sum so far = 127).

Since we need at least 7 bits to represent this minimal set of characters, computer designers decided to use 8 bits (even numbers work better) in defining a byte. They also agreed on a standard code and even got it approved by the American National Standards Institute (ANSI). This code was given the name American Standard Code for Information Interchange, or ASCII, which is the most widely used character set in computers today. (There are many others, but you do not need to know much about them for now.) ASCII is a 7-bit code, but it is always represented using a complete 8-bit byte. (The 8th bit was used for parity checking in the same way that the 9th track on magnetic tapes is used for parity checking; this practice is no longer considered as important as it once was, and many communication protocols do not use parity checks any more.) The complete set of ASCII codes in decimal, octal, and hexadecimal is shown below (and is in your lab manual). For now, however, let's see how the first 32 numbers of this series are represented in decimal, binary and hexadecimal notation:

     decimal    binary     hexadecimal
     0          0          0
     1          1          1
     2          10         2
     3          11         3
     4          100        4
     5          101        5
     6          110        6
     7          111        7
     8          1000       8
     9          1001       9
     10         1010       A
     11         1011       B
     12         1100       C
     13         1101       D
     14         1110       E
     15         1111       F
     16         10000      10
     17         10001      11
     18         10010      12
     ...
     31         11111      1F
     32         100000     20
     ...
     126        1111110    7E
     127        1111111    7F

Hexadecimal notation is valuable as a means for representing ASCII characters, since they can be described with only two digits (base 16). You may never have to use this notation, but if you see it, at least you will understand where it comes from.

The ASCII code includes 32 control characters, 52 alphabetic characters, 10 numeric codes, and 33 other symbols including a space. Since these characters only use 7 bits, there are another 128 numbers available in a byte that are not defined in ASCII. These numbers all have a "1" in the first bit of the byte. Personal computers use these characters for an additional set of graphic symbols, and sometimes we see these characters when we inadvertently try to print a file that contains non-ASCII characters. You are likely to see smiling faces, hearts, spades and clubs, and a number of other symbols. When you do, you know that you have tried to display non-ASCII, and that usually means there is something wrong somewhere.

ASCII Chart in DECIMAL (Base 10)

| 0 NUL| 1 SOH| 2 STX| 3 ETX| 4 EOT| 5 ENQ| 6 ACK| 7 BEL| | 8 BS | 9 HT | 10 NL | 11 VT | 12 NP | 13 CR | 14 SO | 15 SI | | 16 DLE| 17 DC1| 18 DC2| 19 DC3| 20 DC4| 21 NAK| 22 SYN| 23 ETB| | 24 CAN| 25 EM | 26 SUB| 27 ESC| 28 FS | 29 GS | 30 RS | 31 US | | 32 SP | 33 ! | 34 " | 35 # | 36 $ | 37 % | 38 & | 39 ' | | 40 ( | 41 ) | 42 * | 43 + | 44 , | 45 - | 46 . | 47 / | | 48 0 | 49 1 | 50 2 | 51 3 | 52 4 | 53 5 | 54 6 | 55 7 | | 56 8 | 57 9 | 58 : | 59 ; | 60 < | 61 = | 62 > | 63 ? | | 64 @ | 65 A | 66 B | 67 C | 68 D | 69 E | 70 F | 71 G | | 72 H | 73 I | 74 J | 75 K | 76 L | 77 M | 78 N | 79 O | | 80 P | 81 Q | 82 R | 83 S | 84 T | 85 U | 86 V | 87 W | | 88 X | 89 Y | 90 Z | 91 [ | 92 \ | 93 ] | 94 ^ | 95 _ | | 96 ` | 97 a | 98 b | 99 c |100 d |101 e |102 f |103 g | |104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o | |112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w | |120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 DEL|

ASCII Chart in OCTAL (Base 8)

|000 NUL|001 SOH|002 STX|003 ETX|004 EOT|005 ENQ|006 ACK|007 BEL| |010 BS |011 HT |012 NL |013 VT |014 NP |015 CR |016 SO |017 SI | |020 DLE|021 DC1|022 DC2|023 DC3|024 DC4|025 NAK|026 SYN|027 ETB| |030 CAN|031 EM |032 SUB|033 ESC|034 FS |035 GS |036 RS |037 US | |040 SP |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' | |050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / | |060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 | |070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? | |100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G | |110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O | |120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W | |130 X |131 Y |132 Z |133 [ |134 \ |135 ] |136 ^ |137 _ | |140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g | |150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o | |160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w | |170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 DEL|

ASCII Chart in HEXADECIMAL (Base 16)

| 00 NUL| 01 SOH| 02 STX| 03 ETX| 04 EOT| 05 ENQ| 06 ACK| 07 BEL| | 08 BS | 09 HT | 0A NL | 0B VT | 0C NP | 0D CR | 0E SO | 0F SI | | 10 DLE| 11 DC1| 12 DC2| 13 DC3| 14 DC4| 15 NAK| 16 SYN| 17 ETB| | 18 CAN| 19 EM | 1A SUB| 1B ESC| 1C FS | 1D GS | 1E RS | 1F US | | 20 SP | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | | 28 ( | 29 ) | 2A * | 2B + | 2C , | 2D - | 2E . | 2F / | | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | | 38 8 | 39 9 | 3A : | 3B ; | 3C < | 3D = | 3E > | 3F ? | | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | | 48 H | 49 I | 4A J | 4B K | 4C L | 4D M | 4E N | 4F O | | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | | 58 X | 59 Y | 5A Z | 5B [ | 5C \ | 5D ] | 5E ^ | 5F _ | | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | | 68 h | 69 i | 6A j | 6B k | 6C l | 6D m | 6E n | 6F o | | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | | 78 x | 79 y | 7A z | 7B { | 7C | | 7D } | 7E ~ | 7F DEL|

Video Available

A video on coding systems by Prof. Walters is available in 1101 Hart Hall that may be of interest to you. It is titled Coding Systems for Characters and it can be found under the ECS015 Videos (video lecture #4).

Go to the index of lectures for ECS15 - Fall 1997 .

Go to the homepage for ECS15 - Fall 1997 .

© Nancy E. Reed, 1997 -- nereed@ucdavis.edu