- Related Questions & Answers
- 8086 program to subtract two 8 bit BCD numbers
- 8086 program to subtract two 16 bit BCD numbers
- 8085 Program to Subtract two 8 Bit numbers
- 8085 Program to Subtract two multi-Byte numbers
- 8085 Program to Add two multi-byte BCD numbers
- 8085 Program to multiply two 2-digit BCD numbers
- Program to Subtract two 8 Bit numbers in 8085 Microprocessor
- 8085 program to add 2-BCD numbers
- Program to multiply two 2-digit BCD 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
- 8051 Program to Subtract two 8 Bit numbers
- 8085 Program for subtraction of multi-Byte BCD numbers
- 8086 program to add two 8 bit BCD numbers

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Here we will see how to perform BCD subtractions using 8085.

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.

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.

Address | Data |
---|---|

... | . . . |

8000 | 01 |

8001 | 97 |

8002 | 88 |

... | . . . |

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 |

Address | Data |
---|---|

... | . . . |

8050 | 09 |

8051 | 00 |

... | . . . |

Advertisements