Program to convert ASCII to HEX in 8085 Microprocessor


Here we will see one 8085 Microprocessor program. This program will convert ASCII to HEX values.

Problem Statement 

Write an 8085 Assembly language program to convert ASCII to Hexadecimal character values.

Discussion 

We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is 39H (57D). So all other numbers are in the range 30H to 39H. The ASCII value of 0AH is 41H (65D) and ASCII of 0FH is 46H (70D), so all other alphabets (B, C, D, E, F) are in the range 41H to 46H.

Here the logic is simple. We are checking whether the ASCII value is less than 58H (ASCII of 9 + 1) When the number is less 58, then it is numeric value. So we simply subtract 30H from the ASCII value, and when it is greater than 58H, then it is alphabetical value. So for that we are subtracting 37H.

Input

first input

Address
Data


8000
41


second input

Address
Data


8000
35


third input

Address
Data


8000
46


 

Flow Diagram

 

 

 

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
21, 00, 80


LXI H, 8000H
Load address of the number
F003
7E


MOV A,M
Load ASCII data to Acc from memory
F004
FE, 58


CPI 58H
Compare with ASCII(9) + 1
F006
D2, 0E, F0


JNC NUM
The input is numeric
F009
D6, 37


SUI 37H
Subtract offset to get Alphabetic character
F00B
C3, 10, F0


JMP STORE
Store the result
F00E
D6, 30
NUM
SUI 30H
Subtract 30 to get numeric value
F010
23
STORE
INX H
Point to next location
F011
77


MOV M,A
Store Acc content to memory
F012
76


HLT
Terminate the program


Output

first output

Address
Data


8001
0A


second output

Address
Data


8001
05


third output

Address
Data


8001
0F


raja
Published on 09-Oct-2019 11:05:22
Advertisements