- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 |
… | … |
- Related Articles
- Program to convert HEX to ASCII in 8085 Microprocessor
- Program to convert two-digit hex to two ASCII values in 8085 Microprocessor
- 8085 Program to convert ASCII to HEX
- 8085 Program to convert HEX to ASCII
- Program to convert BCD to HEX in 8085 Microprocessor
- Program to convert HEX to BCD in 8085 Microprocessor
- Program to convert ASCII to binary in 8085 Microprocessor
- 8085 Program to convert two-digit hex to two ASCII values
- 8085 Program to convert BCD to HEX
- 8085 Program to convert HEX to BCD
- 8085 Program to convert ASCII to binary
- ASCII to hex and hex to ASCII converter class in JavaScript
- Convert Hex to ASCII Characters in the Linux Shell
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 code to convert binary number to ASCII code
