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.