8086 program to convert ASCII to BCD number

MicroprocessorMicrocontroller8086

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


raja
Published on 12-Mar-2019 11:05:25
Advertisements