8051 code to convert hexadecimal to ascii value

In this article let’s learn how to convert Hexadecimal value to Ascii equivalent number.

Hexadecimalvalue             Asciivalue
01H             31H
02H             32H
03H             33H
04H             34H
05H             35H
06H             36H
07H             37H
08H             38H
09H             39H
0AH             41H
0BH             42H
0CH             43H
0DH             44H
0EH             45H
0FH             46H


 1)Initialize R0 with number which is required to find equivalent Ascii code.
 2)Compare it with 0AH and jump to label1 if it is equal.
3)Compare the carry bit to find which is greater and lesser.
4)If the carry bit is not set(it implies it is greater)jump to label2.
 5)If it is lesser add the number with 30H.
6)If it is greater add the number with 37H.

Code goes here: