- 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 subtract two BCD numbers
Here we will see how to perform BCD subtractions using 8085.
Problem Statement
Write 8085 Assembly language program to perform BCD subtractions of tow numbers stored at location 8001 and 8002. The result will be stored at 8050 and 8051.
Discussion
To subtract two BCD numbers, we are going to use the 10s complement method. Taking the first number and storing into B, Load 99 into A then subtract the number to get the 9’s complement. After that add 1 with the result to get 10’s complement. We cannot increase using INR instruction. This does not effect on CY flag. So we have to use ADI 01. Then DAA instruction will be used to adjust the decimal. Then if the result is negative we are storing FF as upper byte, otherwise 00 as upper byte.
Input
Address | Data |
---|---|
. . . | . . . |
8000 | 01 |
8001 | 97 |
8002 | 88 |
. . . | . . . |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 01, 80 | | LXI H,8001H | Point to get the choice |
F003 | 46 | | MOV B,M | Load operand to B |
F004 | 3E, 99 | | MVI A,99H | Load A with 99H |
F006 | 23 | | INX H | Point to next operand |
F007 | 96 | | SUB M | Subtract M from A |
F008 | C6, 01 | | ADI 01H | Add 01H to get 10's complement |
F00A | 80 | | ADD B | Add B with A |
F00B | 27 | | DAA | Adjust decimal |
F00C | 6F | | MOV L,A | Store A to L |
F00D | DA, 3A, F0 | | JC SKP2 | If CY = 1, jump to SKP2 |
F010 | 26, FF | | MVI H,FFH | Load H with FFH |
F012 | C3, 62, F0 | | JMP STORE | Store result |
F015 | 26, 00 | SKP2 | MVI H,00H | Clear HL |
F017 | 22, 50, 80 | STORE | SHLD 8050H | Store result from HL |
F01A | 76 | | HLT | Terminate the program |
Output
Address | Data |
---|---|
. . . | . . . |
8050 | 09 |
8051 | 00 |
. . . | . . . |
- Related Articles
- 8086 program to subtract two 8 bit BCD numbers
- 8086 program to subtract two 16 bit BCD numbers
- 8085 Program to Add two multi-byte BCD numbers
- 8085 Program to multiply two 2-digit BCD numbers
- 8085 Program to Subtract two 8 Bit numbers
- 8085 Program to Subtract two multi-Byte numbers
- 8085 program to add 2-BCD numbers
- Program to multiply two 2-digit BCD numbers in 8085 Microprocessor
- Program to Subtract two 8 Bit numbers in 8085 Microprocessor
- 8085 program to subtract two 8-bit numbers with or without borrow
- BCD numbers in 8085 Microprocessor
- 8085 Program to convert a two-digit BCD to binary
- 8085 Program for subtraction of multi-Byte BCD numbers
- 8085 program with a subroutine to add ten packed BCD numbers.
- 8085 Program to do an operation on two BCD numbers based on the contents of X

Advertisements