Lec-4 Codes
Lec-4 Codes
.
Binary Coded Decimal (BCD)
• Binary coded decimal is a way to express each
decimal digit to binary code.
• There are 10 code groups in BCD system.
• It is an easy approach to convert decimal to
binary.
• Applications: Keypad inputs, Digital rad outs.
Table
Decimal Binary
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
8421 CODE
• Each decimal digit is converted to four bits
binary number that’s why it is called 8421
code 23, 22, 21, 20
• 𝟖, 𝟒, 𝟐, 𝟏
Convert Decimal to BCD Example 2
Example 1
3 5 9 8
00110101 10011000
Example 3 Example 4
1 7 0 2 4 6 9
000101110000 0010010001101001
Example 5
9 2 8 3 6
10010010100000110110
BCD to Decimal Conversion
10000110 001101010001
8 6 3 5 1
1001010001110000
9 4 7 0
10000001001001110110
8 1 2 7 6
BCD ADDITION
Each column<9
BCD ADDITION
GRAY CODE
As it is
1 1 1 0 1 Gray
Drop
carry
Gray to Binary
1 0 0 1 0
As it is Drop carry Drop carry
Digital Codes
• Some code are numeric like “BCD” some
codes are alphanumeric (can represent
numbers, letters, symbols and instructions.
ASCII CODE
• ASCII (American Standard Code for
Information Interchange)
• ASCII has 128 characters with 7-bits characters
the MSB is zero in each character.
Graphic Symbols
Graphic Symbols
Graphic Symbols
EXAMPLE