0% found this document useful (0 votes)
41 views21 pages

Computer Codes

Uploaded by

Angaad 0516
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views21 pages

Computer Codes

Uploaded by

Angaad 0516
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Codes

outline
Alphanumeric Codes
◦ ASCII

Gray Codes
Human perception
We naturally live in a base 10 environment
Computer exist in a base 2 environment
So give the computer/digital system the task of doing the conversions
for us.
Binary Codes
“An n-bit binary code is a group of n bits that assume up to 2n distinct
combinations of 1s and 0s, with each combination representing one
element of the set being coded”

For the 10 digits need a 4 bit code. One code is called Binary Coded
Decimal (BCD)
Decimal and BCD
The BCD is simply the 4 bit representation of
the decimal digit.
For multiple digit base 10 numbers, each
symbol is represented by its BCD digit
What happened to 6 digits not used?
BCD operation
Consider the following BCD operation
◦ Decimal: Add 4 + 1
◦ Covert to binary 0 1 0 0
◦ And 0001
◦ Getting 0101
◦ Which is still a BCD representation of a decimal digit
Another
A second example
◦ 3 0011
◦ +3 0011
◦ Getting 6 or 0110
◦ And in range and a BCD digit representation
And now
Consider 5 + 5
5 0101
+5 0101
giving 1 0 1 0 which is binary 10 but not a BCD digit!
What to do?
Try adding 6??
Adding 6
Had 1010 and want to add 6 or 0110
◦ so 1010
◦ plus 6 0110
◦ Giving 10000

Or a carry out to the next binary digit, or if the binary in BCD, the next
BCD digit.
Another carry example
Add 7 + 6
◦ have 7 0111
◦ plus 6 0110
◦ Giving 1 1 0 1 and again out of range
◦ Adding 6 0 1 1 0
◦ Giving 1 0 0 1 1 so a 1 carries out to the next BCD digit
◦ FINAL BCD answer 0001 0011 or 1310
Multibit BCD
Add the BCD for 417 to 195
Would expect to get 612
◦ BCD setup - start with Least Significant Digit
◦ 0100 0001 0111
◦ 0001 1001 0101
◦ 1100
◦ Adding 6 0110
◦ Gives 1 0010
Continuing multibit
Had a carry to the 2nd BCD digit position
◦ 1
◦ 0100 0001 done
◦ 0001 1001 0010
◦ 1011
◦ Again must add 6 0110
◦ Giving 1 0001
◦ And another carry
Still Continuing multibit
Had a carry to the 3rd BCD digit position
◦ 1
◦ 0 1 0 0 done done
◦ 0001 0001 0010
◦ 0110
◦ And answer is 0110 0001 0010 or the BCD for the base 10 number 612
Alphanumeric Codes
How do you handle alphanumeric data?
Easy answer!
Formulate a binary code to represent characters! 
For the 26 letter of the alphabet would need 5 bit for representation.
But what about the upper case and lower case, and the digits, and
special characters
A code called ASCII
ASCII stands for American Standard Code for Information Interchange
The code uses 7 bits to encode 128 unique characters
Reference the textbook, pg. 27, for a table of the ASCII code
As a note, formally, work to create this code began in 1960. 1 st
standard in 1963. Last updated in 1986.
ASCII Code
Represents the numbers
◦ All start 011 xxxx and the xxxx is the BCD for the digit

Represent the characters of the alphabet


◦ Start with either 100, 101, 110, or 111
◦ A few special characters are in this area

Start with 010 – space and !”#$%&’()*+.-,/


Start with 000 or 001 – control char like ESC
ASCII Example
Encoding of 123
◦ 011 0001 011 0010 011 0011

Encoding of Joanne
◦ 100 1010 110 1111 110 0001
◦ 110 1110 110 1110 110 0101

Note that these are 7 bit codes


Other Character Codes
Once upon a time, a long, long time ago, there existed cards, called
punch cards!
◦ And a code for those cards called Hollerith code. (patented in 1889)
◦ The code told you what character was being represented in a column when
there was a punch out in various rows of that column.

And another code for characters called EBCDIC (Extended Binary Coded
Decimal Interchange Code) (1963, 1964 IBM) - similar to ASCII –
◦ Digits are coded F0 through F9 in EBCDIC
Gray Codes
When you count up or down in binary, the number of bit that change
with each digit change varies.
◦ From 0 to 1 just have a single but
◦ From 1 to 2 have 2 bits, a 1 to 0 transition and a 0 to 1 transition
◦ From 7 to 8 have 3 bits changing back to 0 and 1 bit changing to a 1

For some applications multiple bit changes cause significant problems.


Gray Code
Contrast of bit changes
◦ Val Bin Chg Gray Chg
◦ 0 000 000
◦ 1 001 1 001 1
◦ 2 010 2 011 1
◦ 3 011 1 010 1
◦ 4 100 3 110 1
◦ 5 101 1 111 1
◦ 6 110 2 101 1
◦ 7 111 1 100 1
◦ 0 000 3 000 1
Class 3 assignment
Covered sections 1-5 and 1-6
Problems for hand in
◦ 1-22, 1-23

Problems for practice


◦ 1-25, 1-26

Reading for next class: sections 2-1 and 1st 3 pages of 2-2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy