- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
8085 Program to convert ASCII to binary
Now let us see a program of Intel 8085 Microprocessor. This program will convert ASCII to binary values.
Problem Statement
Write 8085 Assembly language program to convert ASCII to binary or Hexadecimal character values.
Discussion
We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is39H (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 than58H, then it is alphabetical value. So for that we are subtracting37H.
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 withASCII(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 30to 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 ASCII to binary in 8085 Microprocessor
- 8085 code to convert binary number to ASCII code
- 8085 Program to convert ASCII to HEX
- 8085 Program to convert HEX to ASCII
- Program to convert ASCII to HEX in 8085 Microprocessor
- Program to convert HEX to ASCII in 8085 Microprocessor
- 8085 program to convert gray to binary
- 8085 program to convert binary numbers to gray
- 8085 Program to convert two-digit hex to two ASCII values
- 8085 program to convert 8 bit BCD number into ASCII Code
- Program to convert two-digit hex to two ASCII values in 8085 Microprocessor
- 8085 Program to convert a two-digit BCD to binary
- 8085 Program to convert an 8-bit binary to BCD
- 8085 Program to convert a 16-bit binary number to BCD
- Program to convert a 16-bit binary number to BCD in 8085 Microprocessor
