You are on page 1of 2

Microcontroller and its application

Question paper 2013


BCD is Binary Coded Decimal, the same as binary up to the value of ten. Four bits can be used to
describe sixteen possible values from 0 to 15, or 0 to E. BCD uses only the first ten, 0 to 9.
BCD is used for values important to humans, since we generally count in decimal. This means that when
we count, we carry when we reach ten - from 9 to 10, from 99 to 100, and so forth.

When counting from 0 to 16, or from 0 to E, you carry at E to 10, and from EE to 100, and so forth. This
is called hexidecimal. So if you see the hex value A9, it is the same as 169 in decimal. Hexidecimal
characters are used in computers to represent all the possible values that four bits can have, since it
uses all possibilities. BCD wastes the four bit values that are possible, above those used for just counting
from one to ten. But this is sometimes necessary to convert from one to the other for human reasons. If
a computer holds a four bit value in its memory, and then it is told to start increasing the value, it will
pass through all the hexidecimal values, too.
WHAT ARE PACKED AND UNPACKED BINARY CODED DECIMAL (BCD) NUMBERS

In the case of unpacked BCD numbers, each four-bit BCD group corresponding to a decimal digit
is stored in a separate register inside the machine. In such a case, if the registers are eight bits or
wider, the register space is wasted.

In the case of packed BCD numbers, two BCD digits are stored in a single eight-bit register. The process
of combining two BCD digits so that they are stored in one eight-bit register involves shifting the number
in the upper register to the left 4 times and then adding the numbers in the upper and lower registers.

The process is illustrated by showing the storage of decimal digits 5 and 7:

Decimal digit 5 is initially stored in the eight-bit register as: 0000 0101.

Decimal digit 7 is initially stored in the eight-bit register as: 0000 0111.

After shifting to the left 4 times, the digit 5 register reads: 0101 0000.

The addition of the contents of the digit 5 and digit 7 registers now reads: 0101 0111.

Example
How many bits would be required to encode decimal numbers 0 to 9999 in straight binary and
BCD codes? What would be the BCD equivalent of decimal 27 in 16-bit representation?

Solution

Total number of decimals to be represented=10 000=104 =213 29.

Therefore, the number of bits required for straight binary encoding=14.

The number of bits required for BCD encoding=16.

The BCD equivalent of 27 in 16-bit representation=0000000000100111.

You might also like