Friday 15 January 2021

Computer Codes: BCD - EBCDIC and ASCII

 

Computer Codes:

 

BCD Code:

 

Binary Coded Decimal (BCD) code is one of the early computer codes. The idea of this coding scheme is to convert each digit of a decimal number into its binary equivalent instead of converting the entire decimal value into a binary number. This makes the conversion process easier.

 

Following figure shows BCD equivalent of each decimal digit. Since 8 and 9 require 4 bits, all decimal digits are represented in BCD by 4 bits.

 

Decimal Digits

BCD Equivalent

0

0000

1

0001

2

0010

3

0011

4

0100

5

0101

6

0110

7

0111

8

1000

9

1001

 

Fig: BCD equivalent of decimal digits

 

 

As we saw earlier that 4210  is equal to 1010102; converting 4210  into BCD, produces the following result:

4210= 01000010 in BCD

 

Note that each decimal digit is independently converted to a 4 bit binary number and hence, the conversion process is very easy.

 

Also note that when four bits are used, altogether 16 (24) combinations are possible. However, in the above figure, you can see that only the first 10 of these combinations are used to represent decimal digits. The remaining six arrangements (1010, 1011, 1100, 1101, 1110 and 1111) have decimal values from 10 to 15. These arrangements are not used in BCD coding. That is, 1010 does not represent 1010 in BCD. Instead,

 

1010= 00010000 in BCD

 

Similarly,

 

1510= 00010101 in BCD

 

4 bit BCD coding system can be used to represent only decimal numbers because 4 bits are insufficient to represent the various characters used by a computer. Hence, instead of using 4 bits, with only 16 possible characters, computer designers commonly used 6 bits to represent characters in BCD code. In 6 bit BCD code, the four BCD numeric place positions are retained but two additional zone positions are added. With 6 bits, it is possible to represent 64(26) different characters. This is sufficient to code the decimal digits (10), alphabetic letters (26), and other special characters (28).

 

 

 

EBCDIC:

 

The major problem with BCD code is that it can represent only 64 different characters. This is not sufficient for providing a decimal numbers (10), lowercase letters (26), uppercase letters (26) and a large number of other special characters (28+).

 

Hence, BCD code was extended from 6 bit code to an 8 bit code. The added 2 bits are used as additional zone bits, expanding the zone to 4 bits. The resulting code is called the Extended Binary Coded Decimal Interchange Code (EBCDIC). In this code, it is possible to represent 256(28) different characters, instead of 64(26). It also allows a large variety of printable characters and several non-printable control characters. The control characters are used to control such activities as printer vertical spacing, movement of cursor on terminal screen, etc.

 

Since EBCDIC is an 8 bit code, it can be easily divided into two 4 bit groups. Each of these 4-bit groups can be represented by one hexadecimal digit. Hence, hexadecimal number system is used as shortcut notation for memory dump by computers that use EBCDIC for internal representation of characters. This results in a 1:4 reduction in volume of memory dump.

 

 

ASCII:

 

Another widely used computer code is the American Standard Code for Information Interchange (ASCII). This code is popular in data communications, is used almost exclusively to represent data internal in microcomputers, and is frequently found in large computers produced by some vendors.

 

American National Standards Institute (ANSI) published ASCII standard in 1963. However, the standard lacked lowercase letters and ANSI revised ASCII in 1967. Today, ASCII is one of the most popular and widely supported character and coding standards.

 

ASCII is of two types - ASCII - 7 and ASCII - 8. ASCII - 7 is a 7- bit code that can represent 128(27) different characters. Computers using 8 bit byte and the 7 bit ASCII either set the 8th bit (leftmost bit) of each byte as 0 or uses it as a parity bit.

 

ASCII - 8 is an extended version of ASCII - 7. It is an 8 bit code that can represent 256(28) different characters. The additional bit is added to the left of the 7th bit (leftmost bit) of ASCII - 7 codes.

 

ASCII - 7 uses only 7 bits whereas all the 8 bits are used in ASCII - 8. Hence the codes of first 128 characters (symbol) are identical in ASCII - 7 and ASCII - 8.  ASCII also uses hexadecimal as its 4:1 shortcut notation for memory dump.

 

 

No comments:

Post a Comment