- Related Questions & Answers
- C++ Program for Dijkstra’s shortest path algorithm?
- C program to find the length of a string?
- Ways to paint N paintings such that adjacent paintings don’t have same colors in C programming
- How to find the unicode category for a given character in Java?
- How to find the number of days in a month of a particular year in Java?
- To find sum of even factors of a number in C++ Program?
- 5 Different methods to find the length of a string in C++?
- How to find If a given String contains only letters in Java?
- How to find Date after 1 week in java 8?
- Find the k most frequent words from data set in Python
- Find size of a list in Python
- Find length of a string in python (3 ways)
- Find all the numbers in a string using regular expression in Python
- intersection_update() in Python to find common elements in n arrays
- Program to build DFA that starts and ends with ‘a’ from the input (a, b)

- 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 find 2’s complement with carry.

Write 8085 Assembly language program to find 2’s complement of a number stored in F100 with the carry, and store at F150 and F151.

In 8085, there is CMA instruction to complement a number. Then we can add 01 with it to make it 2’s complement. While adding 01 with it, the carry may generate. We will store it to F151, and the actual complemented value will be at F150.

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

… | … |

F100 | 08 |

… | … |

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

F000 | 3A, 00, F1 | | LDA F100H | get number from memory to A |

F003 | 2F | | CMA | get 1's complement |

F004 | C6, 01 | | ADI 01 | Increase it by 1 |

F006 | 6F | | MOV L,A | Store A into L |

F007 | 3E, 00 | | MVI A,00H | Clear Accumulator |

F009 | 8F | | ADC A | Add A + A + carry |

F00A | 67 | | MOV H,A | Load A into H |

F00B | 22, 50, F1 | | SHLD F150 | Store HL into memory |

F00E | 76 | | HLT | Terminate the program |

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

… | … |

F150 | F8 |

F151 | 00 |

… | … |

Advertisements