# SECTION II - BINARY CODED DECIMAL NUMBER SYSTEM IN 8051

SECTION II - BINARY CODED DECIMAL NUMBER SYSTEM IN 8051:

BCD Binary Coded Decimal number is used to represent the digital 0 to 9 for number, not binary or hex numbers. Binary representation of 0 to 9 is called BCD. In computer language there are two terms used for BCD numbers. One is unpacked BCD number and the other is packed BCD numbers.

Binary Coded Decimal Numbers [BCD] Code:

DIGITBINARY CODED DECIMAL NUMBER [BCD]
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001
• Unpacked Binary Coded Decimal [BCD] Number:

The lower 4 bits of the number represent the BCD number. The higher bits are zero '0'. e.g "0000 0001", "0000 0010", "0000 0011", "0000 0100", "0000 0101", "0000 0110", "0000 0111", "0000 1000", and "0000 1001" are unpacked binary coded decimal number for 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. So only 1 byte of memory is required for unpacked BCD numbers or an 8 bit register to contain it.

• Packed Binary Coded Decimal [BCD] Number:

In packed BCD numbers, both the lower and higher 4 bits are used. A single byte has two BCD numbers, one in the lower nibble 4 bits, and one in the upper 4 bits. e.g "0101 1010", is a packed BCD for 5AH. One byte of memory is required to store the packed BCD operands. The packed BCD is twice more efficient as compared to unpacked BCD data.

When adding two BCD numbers, the result must be a BCD number. If after adding two BCD numbers, the result is not BCD number, then it must be corrected by adding the number 6.If the lower bit is need to be corrected then 06 must be added in the lower bits, and if upper bits need to be corrected then 60 must be added to the upper bits. After adding these two digits below, the result is no longer BCD

MOV A, #15H