MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
SIDDHANT COLLAGE OF EMGINEERING
A/P Sudumbare Tal-Mavel Dest-pune
i
Micro Project
Academic Year (2021-22)
Maharashtra State Board of Technical Education
Program code and name: CO
Subject: Microprocessor
A Micro Project on
BCD to HEX Conversion
Sr. Roll No. Student Name Enrollment Seat No.
No.
1 Yash Botre 2016240019
2 OM Markad 2016240017
Under Guidance of
Mrs. Yogita Rode mam…
Maharashtra State Board of Technical Education
Certificate
This is to certify that Mr. Yash Botre ……. Roll No….. Of fourth
Semester of Diploma in Computer Engineering of Institute, Siddhant
college of Engineering (Code: 1624) has completed the Practical
Activities (PA) satisfactorily in Course Microprocessor for the
academic year 2021 – 2022 as prescribed in the curriculum.
Place: Sudumbare …… Enrollment No: 2016240019
Exam. Seat No: …………………………
Subject Teacher Head of Department Principle
Maharashtra State Board of Technical Education
Certificate
This is to certify that Mr. Om Markad ……. Roll No….. Of fourth
Semester of Diploma in Computer Engineering of Institute, Siddhant
college of Engineering (Code: 1624) has completed the Practical
Activities (PA) satisfactorily in Course Microprocessor for the
academic year 2021 – 2022 as prescribed in the curriculum.
Place: Sudumbare Enrollment No: 2016240017
Exam. Seat No: …………………………
Subject Teacher Head of Department Principle
ACKNOWLEDGEMENT
It is a matter of great pleasure by getting the opportunity of
highlighting. A fraction of knowledge I acquired during our
technical education through this project.
This would not have been possible without the guidance and
help of many people. This is the only page where we have the
opportunity of expressing our emotions and gratitude from the
core of our heart to them. This project would not have been
successful without enlightened ideas, timely suggestions and
interest of our most respected guide Of Mrs. Yogita Rode mam
without her best guidance; this would have been an impossible
task to complete.
I would like to thank Mrs. Sarita Kale mam Head of our
department for providing the necessary facility using the period
of working on this project work. I would also like to thank our
Principal Mrs. Nanda Kulkarni who encouraged us and created
a healthy environment for all of us to learn in the best possible
way.
Finally, I would pay my respect and love to my parents and all
Family members as well as friends for their love and
encouragement throughout this Micro Project.
Index
Sr. No. Content
1 Abstract
2 Introduction
3 Source Code
5 Reference
Abstract
Assembly language program to find the equivalent hexadecimal
number from a BCD number. The number is stored at memory
offset 500 and store the result at memory offset.
To convert BCD to hexadecimal at first we have to cut the BCD
digits. The most significant digit will be multiplied with 0AH (10D),
and then least significant digit will be added with the result of
multiplication. Thus the BCD will be converted to its equivalent
hexadecimal form.
Aurally live in a decimal (base-10) world we need some way of
converting these decimal numbers into a binary (base-2)
environment that computers and digital electronic devices
understand, and binary coded decimal code allows us to do that.
Introduction
He decimal weight of each decimal digit to the left increases by
a factor of 10. In the BCD number system, the binary weight of
each digit increases by a factor of 2 as shown. Then the first digit
has a weight of 1 ( 20 ), the second digit has a weight of 2 ( 21 ),
the third a weight of 4 ( 22 ), the fourth a weight of 8 ( 23 ). But
do not get confused, binary coded decimal is not the same as
hexadecimal. Whereas a 4-bit hexadecimal number is valid up
to F16 representing binary 11112, (decimal 15), binary coded
decimal numbers stop at 9 binary 10012. This means that
although 16 numbers (24) can be represented using four binary
digits, in the BCD numbering system the six binary code
combinations of: 1010 (decimal 10), 1011 (decimal
11), 1100 (decimal 12), 1101 (decimal 13), 1110 (decimal 14),
and 1111 (decimal 15) are classed as forbidden numbers and
cannot be used.
The main advantage of binary coded decimal is that it allows
easy conversion between decimal (base-10) and binary (base-
2) form. However, the disadvantage is that BCD code is wasteful
as the states between 1010 (decimal 10), and 1111 (decimal 15)
are not used. Nevertheless, binary coded decimal has many
important applications especially using digital displays.
Main Content / Body
BCD to HEX Conversion
Algorithm
1. Initialize memory pointer to 4150 H
2. Get the Most Significant Digit (MSD)
3. Multiply the MSD by ten using repeated addition
4. Add the Least Significant Digit (LSD) to the result obtained in previous
step
5. Store the HEX data in Memory
Program and Result
LXI H,5000
MOV A,M ;Initialize memory pointer
ADD A ;MSD X 2
MOV B,A ;Store MSD X 2
ADD A ;MSD X 4
ADD A ;MSD X 8
ADD B ;MSD X 10
INX H ;Point to LSD
ADD M ;Add to form HEX
INX H
MOV M,A ;Store the result
HLT
Input:
Data 0: 02H in memory location 5000
Data 1: 09H in memory location 5001
Output:
Data 0: 1DH in memory location 5002
BCD represents decimal digits using groups of 4 bits. Since a
decimal digit can be 0–9 only, but 4 bits can represent 16
possible symbols, this is a little wasteful, but it’s convenient for
some situations, so the inefficiency is accepted.
Hexadecimal also groups bits into sets of 4. Unlike BCD,
hexadecimal can represent all 16 possible symbols, and it does
this using 0–9, then A-F. But over the range that BCD can
represent, 0–9, hexadecimal uses the same symbols. So to
convert BCD to hexadecimal, there is nothing to do - the
representation is identical. 123456 in BCD is 0001 0010 0011
0100 0101 0110 and in hex, that is….
But over the range that BCD can represent, 0–9, hexadecimal
uses the same symbols. So to convert BCD to hexadecimal,
there is nothing to do - the representation is identical. 123456 in
BCD is 0001 0010 0011 0100 0101 0110 and in hex, that
is….123456
Hex
Hexadecimal is a numeric system widely used by systems
designers and computer programmers. It contains 16 symbols
from 0 to 9 and A to F, thus having a base of 16.
Problem Statement
A BCD number is stored at location 802BH. Convert the number
into its binary equivalent and store it to the memory location
802CH.
Discussion
In this problem we are taking a BCD number from the memory
and converting it to its binary equivalent. At first we are cutting
each nibble of the input. So if the input is 52 (0101 0010) then
we can simply cut it by masking the number by 0FH and F0H.
When the Higher order nibble is cut, then rotate it to the left four
times to transfer it to lower nibble.
Now simply multiply the numbers by using decimal adjust
method to get final decimal result.
Reference
http://www.w3schools.com/
http://www.roseindia.com/css/asseblyl/lang
http://www.stackoverflow.com/tags/assembly/info
http://wikipedia.com/wiki/mic
Microprocessor Models, Languages, Design and Application
Programming, Ramer Elastic and Sham Kant B.
Navaho, 7th Edition, 2017, Pearson.