0% found this document useful (0 votes)
164 views2 pages

SSN College of Engineering Department of Computer Science and Engineering III Year - UCS1512 - Microprocessors Lab BCD To ASCII Conversion Using 8051

1. The document describes an 8051 microprocessor program to convert a binary coded decimal (BCD) number in register R0 to its ASCII representation by extracting each decimal digit, converting it to ASCII, and storing it in registers R1 and R2. 2. The algorithm extracts the first decimal digit by ANDing R0 with F0H, swaps the nibbles, and adds 30H to convert it to ASCII in R1. It then extracts the second digit by ANDing R0 with 0FH, adds 30H to convert it to ASCII in R2. 3. The program is executed successfully, converting the BCD number in R0 (0FH in the sample) to its ASCII

Uploaded by

prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views2 pages

SSN College of Engineering Department of Computer Science and Engineering III Year - UCS1512 - Microprocessors Lab BCD To ASCII Conversion Using 8051

1. The document describes an 8051 microprocessor program to convert a binary coded decimal (BCD) number in register R0 to its ASCII representation by extracting each decimal digit, converting it to ASCII, and storing it in registers R1 and R2. 2. The algorithm extracts the first decimal digit by ANDing R0 with F0H, swaps the nibbles, and adds 30H to convert it to ASCII in R1. It then extracts the second digit by ANDing R0 with 0FH, adds 30H to convert it to ASCII in R2. 3. The program is executed successfully, converting the BCD number in R0 (0FH in the sample) to its ASCII

Uploaded by

prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SSN College of Engineering Department of Computer Science

and Engineering
III year - UCS1512 – Microprocessors Lab
BCD to ASCII conversion using 8051
Exp No: 14
Name: Prakash R
Register Number: 185001108
Date: 20/10/2020
Aim:
To design 8051-program to covert BCD to ASCII.

Algorithm:
1. Move the value in R0 to register A.
2. Extract the first digit of the given number by performing AND on A and F0H. Only the first digit
will be present in the register A.
3. Swap A interchanges the lower order and higher order nibbles of register A.
4. Now add 30H to A to get the ASCII value and move the value to R1.
5. Now extract the second digit of the given number by performing AND on A and 0FH. Only the
second digit will be present in the register A.
6. Now add 30H to A to get the ASCII value and move the value to R2.
7. HERE: Infinite loop to HERE using SJMP HERE.

Program:

Program Comments
MOV A, R0 A <- R0
ANL A, #0F0H A <- A ^ F0H
SWAP A Swap higher and lower order nibbles of A.
ADD A, #30H A <- A + 30H
MOV R1, A R1 <- A
MOV A, R0 A <- R0
ANL A, #0FH A <- A ^ 0FH
ADD A, #30H A <- A + 30H
MOV R2, A R2 <- A
HERE: SJMP HERE Transfers execution to HERE.
Snapshot of sample output:
R0 – 0FH.

Result:
Thus the 8051-program to covert BCD to ASCII is executed successfully.

You might also like