You are on page 1of 10

MATSYODARI SHIKSHAN SANSTHA’s

College of Engineering & Technology Campus for

Engineering, Polytechnic & MBA

(Polytechnic)

Computer science & Engineering


Department
2021-2022

Micro Project
On

“ Convert Hexadecimal Number to Equivalent BCD

Subject :-- Microprocessor

Submitted to
Subject Incharge:- Mr Gaurav Thakur HOD:- Mrs Rohini Thombre Collage Incharge:- Mr
Daune

1
Submitted by

Roll No Enrolement No Name Of Student


15 2015460085 Gaurav Khardekar
25 2115460034 Rohit Banswal
10 2015460036 Lokhande Akash

2
INDEX

Title Page No

Abstract 4

Introduction 5

Objective 7

Implementation 10

Design 13

Conclusion 25

References 26

3
Abstract

• Input: 11F.

• Output: 0001 0001 1111.

• Explanation: Binary of 1 – 0001. Binary of F – 1111. Thus, Equivalent BCD is 0001 0001 1111.

• Input: A D.

• Output: 1010 1101.

• Explanation: Binary of A – 1010. Binary of D – 1101. Thus, Equivalent BCD is 1010 1101.

Introduction

We  have a 4 digit  Hex  number  whose equivalent binary number is


to be found i.e. FFFF H. Initially we compare FFFF H with decimal
10000 ( 2710 H in Hex ). If number is greater than 10,000 we add it
to DH register. Also, we subtract decimal 10,000 from FFFF H, each
time comparison is made. Then we compare the number obtained in
AX by 1000 decimal. Each time we subtract 1000 decimal from AX
and add 1000 decimal to BX. Then we compare number obtained in
AX by 100 decimals. Each time we subtract 100 decimal from AX and

4
add 100 decimal to BX to obtain BCD equivalent. Then we compare
number obtained in AX with 10 decimal. Each time we subtract 10
decimal from AX and we add 10 decimal to BX. Finally we add the
result in BX with remainder in AX. The final result is present in

register DH with contains the 5th bit if present and register AX.

Objective

To convert from HEX to BCD, you have to first convert the HEX to Decimal, then convert the Decimal
digits to BCD digits, by converting each Decimal digit to 4 binary digits.

Example : convert Hex 1A2B3C to BCD.


Convert HEX 1A2B3C to Decimal to get 1715004.
We have to take this as 01715004 (add a 0 to the start) to get even number of digits.
Now each digit and convert to binary

Decimal 01715004 = BCD 0000 0001 0111 0001 0101 0000 0000 0100.
So Hex 1A2B3C = 0000 0001 0111 0001 0101 0000 0000 0100 BCD.

5
Implementation

• Hexadecimal
• The following is a JavaScript implementation of the above algorithm
for converting any number to a hexadecimal in String representation. Its purpose is

• Character encoding
vendors of the era had their own character codes, often 6 bit, but usually had the ability to read tapes
produced on IBM equipment. BCD was the precursor

• Byte (redirect from The Evolution of the Byte)
conveniently represented by a single hexadecimal digit. The term octet is used to unambiguously
specify a size of eight bits. It is used extensively in

• BASIC interpreter (section Tokenization at the keyboard)


encountered, for instance, in the line number in GOTO 100, the tokenized BCD value
has to be converted to an integer, an operation that can take as long as 3500 microseconds

6
7
8
Design

9
Conclusion

Adjusts it to BCD code. Since the entire calculation is implemented in successive shifts,
ABCDE is obtained after shifting one bit (E is from low displacement and its value is
either 0 or 1). At this time, it should be judged whether the value is greater than or equal
to 10. If so, the value is increased by 6 to adjust it to within 10, and the carry is shifted to
the upper 4-bit BCD code. Here, the pre-movement adjustment is used to first
determine whether ABCD is greater than or equal to 5 (half of 10), and if it is greater
than 5, add 3 (half of 6) and then shift

References
Microcontroller firmware with hexadecimal code. You sometimes need to display the content
of registers, which requires a hexadecimal-to-BCD (binary-coded-decimal)-code conversion.
The for this conversion is an add-three algorithm. Fortunately, you can adapt this technique
for use with an8-bit microcontroller assembler. You can, however, easily adapt this any
assemblers because the approach uses a set of standard instructions.

10

You might also like