 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8086 program to convert ASCII to BCD number
In this program we will see how to find the equivalent BCD number from an ASCII value.
Problem Statement
Write 8086 Assembly language program to find the equivalent BCD number from an ASCII value. The number is stored at memory location 2050 and store the result at memory location 3050.
Discussion
This program can change ASCII value of a number to its BCD (Decimal) form. The ASCII values of the numbers are like below:
| ASCII (in Hex) | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 
|---|---|---|---|---|---|---|---|---|---|---|
| BCD | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 
From this table we can easily find that the last nibble of the ASCII value is actually the BCD equivalent. So to take the last nibble we have masked the upper nibble, and take the lower nibble as result.
Input
| Address | Data | 
|---|---|
| … | … | 
| 2050 | 39 | 
| … | … | 
Flow Diagram
 
Program
 
Output
| Address | Data | 
|---|---|
| … | … | 
| 3050 | 09 | 
| … | … | 
Advertisements
 