- Related Questions & Answers
- Average numbers in array in C Programming
- C Program for Tower of Hanoi
- C++ Program for Dijkstra’s shortest path algorithm?
- C/C++ Program for nth Catalan Number?
- C Program to Multiply two Floating Point Numbers?
- C program to find the length of a string?
- C Program to Check if all digits of a number divide it
- C Program to Check if a Given String is a Palindrome?
- Write a program to Delete a Tree in C programming
- Write a C program to print “ Tutorials Point ” without using a semicolon
- Sum of the numbers up to N that are divisible by 2 or 5 in c programming
- Sum of the nodes of a Singly Linked List in C Program
- Sum of first n natural numbers in C Program
- C Program for simple interest?
- Area of a n-sided regular polygon with given Radius in C Program?

- 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