Computer Codes Info Notes 1 Computer Codes n

  • Slides: 22
Download presentation
Computer Codes Info Notes 1

Computer Codes Info Notes 1

Computer Codes n n n A computer is a digital system that stores and

Computer Codes n n n A computer is a digital system that stores and processes different types of data in the form of 0 s and 1 s. The different types of data handled by a computer system include numbers, alphabets and some special characters. Therefore, there is a need to change the data entered by the users into a form that the computer system can understand process. Info Notes 2

Computer Codes n n n Different types of codes have been developed and used

Computer Codes n n n Different types of codes have been developed and used to represent the data entered by the users in the binary format. The binary system represents each type of data in terms of binary digits, 0 s and 1 s. Since these codes convert the data into the binary form, the computer codes are also referred as binary codes. Info Notes 3

4 -Bit Binary Coded Decimal (BCD) Systems n n n The BCD system is

4 -Bit Binary Coded Decimal (BCD) Systems n n n The BCD system is employed by computer systems to encode the decimal number into its equivalent binary number. This is generally accomplished by encoding each digit of the decimal number into its equivalent binary sequence. The main advantage of BCD system is that it is a fast and efficient system to convert the decimal numbers into binary numbers as compared to the pure binary system. Info Notes 4

4 -Bit Binary Coded Decimal (BCD) Systems n The 4 -bit BCD system is

4 -Bit Binary Coded Decimal (BCD) Systems n The 4 -bit BCD system is usually employed by the computer systems to represent and process numerical data only. In the 4 -bit BCD system, each digit of the decimal number is encoded to its corresponding 4 -bit binary sequence. The two most popular 4 -bit BCD systems are: • Weighted 4 -bit BCD code • Excess-3 (XS-3) BCD code Info Notes 5

Weighted 4 -Bit BCD Code n n n The weighted 4 -bit BCD code

Weighted 4 -Bit BCD Code n n n The weighted 4 -bit BCD code is more commonly known as 8421 weighted code. It is called weighted code because it encodes the decimal system into binary system by using the concept of positional weighting into consideration. In this code, each decimal digit is encoded into its 4 bit binary number in which the bits from left to right have the weights 8, 4, 2, and 1, respectively. Info Notes 6

Weighted 4 -Bit BCD Code Decimal digits Weighted 4 -bit BCD code 0 0000

Weighted 4 -Bit BCD Code Decimal digits Weighted 4 -bit BCD code 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 Info Notes n Apart from 8421, some other weighted BCD codes are 4221, 2421 and 5211. 7

Weighted 4 -Bit BCD Code n n Examples 6. 1 -6. 6, p 100.

Weighted 4 -Bit BCD Code n n Examples 6. 1 -6. 6, p 100. 6. 1: Represent the decimal number 5327 in 8421 BCD code. The corresponding 4 -bit 8421 BCD representation of decimal digit 5 The corresponding 4 -bit 8421 BCD representation of decimal digit 3 The corresponding 4 -bit 8421 BCD representation of decimal digit 2 The corresponding 4 -bit 8421 BCD representation of decimal digit 7 Therefore, the 8421 BCD representation of decimal number 5327 is 010100100111. Info Notes is is 0101 0010 0111 8

Excess-3 BCD Code n n n The Excess-3 (XS-3) BCD code does not use

Excess-3 BCD Code n n n The Excess-3 (XS-3) BCD code does not use the principle of positional weights into consideration while converting the decimal numbers to 4 -bit BCD system. Therefore, we can say that this code is a non-weighted BCD code. The function of XS-3 code is to transform the decimal numbers into their corresponding 4 -bit BCD code. In this code, the decimal number is transformed to the 4 bit BCD code by first adding 3 to all the digits of the number and then converting the excess digits, so obtained, into their corresponding 8421 BCD code. Therefore, we can say that the XS-3 code is strongly related with 8421 BCD code. Infoin. Notes its functioning. 9

Excess-3 BCD Code Decimal digits Excess-3 BCD code 0 0011 1 0100 2 0101

Excess-3 BCD Code Decimal digits Excess-3 BCD code 0 0011 1 0100 2 0101 3 0110 4 0111 5 1000 6 1001 7 1010 8 1011 9 1100 Info Notes 10

Excess-3 BCD Code n n Examples 6. 7 -6. 9, p 102. 6. 7:

Excess-3 BCD Code n n Examples 6. 7 -6. 9, p 102. 6. 7: Convert the decimal number 85 to XS-3 BCD code. Add 3 to each digit of the given decimal number as: 8+3=11 5+3=8 The corresponding 4 -bit 8421 BCD representation of the decimal digit 11 is 1011. The corresponding 4 -bit 8421 BCD representation of the decimal digit 8 is 1000. Therefore, the XS-3 BCD representation of the decimal number 85 is 1011 1000. Info Notes 11

Excess-3 BCD Code n n Apart from XS-3 code, the other non-weighted BCD code

Excess-3 BCD Code n n Apart from XS-3 code, the other non-weighted BCD code is 4 -bit Gray code. 4 -bit BCD systems are inadequate for representing and handling non-numeric data. For this purpose, 6 bit BCD and 8 -BCD systems have been developed. Info Notes 12

8 -Bit BCD Systems n n n The 6 -bit BCD systems can handle

8 -Bit BCD Systems n n n The 6 -bit BCD systems can handle numeric as well as non-numeric data but with few special characters. The 8 -bit BCD systems were developed to overcome the limitations of 6 -bit BCD systems, which can handle numeric as well as nonnumeric data with almost all the special characters such as +, -, *, /, @, $, etc. Therefore, the various codes under the category of 8 bit BCD systems are also known as alphanumeric codes. Info Notes 13

8 -Bit BCD Systems n The three most popular 8 -bit BCD codes are:

8 -Bit BCD Systems n The three most popular 8 -bit BCD codes are: • Extended Binary Coded Decimal Interchange • • Code (EBCDIC) American Standard Code for Information Interchange (ASCII) Gray Code Info Notes 14

EBCDIC Code n n n The EBCDIC code is an 8 -bit alphanumeric code

EBCDIC Code n n n The EBCDIC code is an 8 -bit alphanumeric code that was developed by IBM to represent alphabets, decimal digits and special characters, including control characters. The EBCDIC codes are generally the decimal and the hexadecimal representation of different characters. This code is rarely used by non IBM-compatible computer systems. Info Notes 15

ASCII Code n n The ASCII code is pronounced as ASKEE and is used

ASCII Code n n The ASCII code is pronounced as ASKEE and is used for the same purpose for which the EBCDIC code is used. However, this code is more popular than EBCDIC code as unlike the EBCDIC code this code can be implemented by most of the non-IBM computer systems. Initially, this code was developed as a 7 -bit BCD code to handle 128 characters but later it was modified to an 8 -bit code. Info Notes 16

Gray Code n Gray code is another important code that is also used to

Gray Code n Gray code is another important code that is also used to convert the decimal number into 8 -bit binary sequence. However, this conversion is carried in a manner that the contiguous digits of the decimal number differ from each other by one bit only. Info Notes 17

Gray Code Decimal Number 8 -Bit Gray Code 0 0000 1 00000001 2 00000011

Gray Code Decimal Number 8 -Bit Gray Code 0 0000 1 00000001 2 00000011 3 00000010 4 00000110 5 00000111 6 00001111 7 00001011 8 00001001 9 00001101 Info Notes 18

Gray Code n • • We can convert the Gray coded number to its

Gray Code n • • We can convert the Gray coded number to its binary equivalent by remembering the following two major rules: The Most Significant Bit (MSB) of the Gray coded number and the equivalent binary number is always the same. The next-to-most significant bit of the binary number can be determined by adding the MSB of the binary number to the next-to-most significant bit of the gray coded number. Info Notes 19

Gray Code • • • Examples 6. 10 -6. 11, p 106. 6. 10:

Gray Code • • • Examples 6. 10 -6. 11, p 106. 6. 10: Convert the Gray coded number 11010011 to its binary equivalent. The following table lists the steps showing the conversion of the Gray coded number into its binary equivalent: Gray Coded Digit Hence, the binary equivalent of Gray coded number 11010011 is 10011101 Info Notes Binary Addition Operation 1 Binary Digit 1 1 1+1 0 0 0+0 0 1 1+0 1 0 0+1 1 1 1+1 0 1 1+1 1 20

Gray Code n • • We can also convert a number represented in the

Gray Code n • • We can also convert a number represented in the binary form to Gray code representation. For carrying out this conversion, we need to remember the following two rules: The Most Significant Bit (MSB) of the binary number and the gray coded number is always the same. The next MSD of the gray coded number can be obtained by adding the subsequent pair of bits of the binary number starting from the left. Info Notes 21

Gray Code • Examples 6. 12 -6. 13, • • Binary Digit p 107.

Gray Code • Examples 6. 12 -6. 13, • • Binary Digit p 107. 6. 12: Convert the binary number 10100011 to its equivalent Gray coded number. Hence, the Gray coded equivalent of the binary number 10100011 is 11110010. Info Notes Binary Addition Operation 1 Gray Coded Digit 1 0 1+0 1 1 0+1 1 0 1+0 1 0 0+0 0 1 0+1 1 1 1+1 0 22