**Problem –** Write a program to find 1’s and 2’s complement of 8-bit number where starting address is **2000** and the number is stored at **3000** memory address and store result into **3001** and **3002** memory address.

**Example –**

**Algorithm –**

- Load the data from memory 3000 into A (accumulator)
- Complement content of accumulator
- Store content of accumulator in memory 3001 (1’s complement)
- Add 01 to Accumulator content
- Store content of accumulator in memory 3002 (2’s complement)
- Stop

**Program –**

Memory | Mnemonics | Operands | Comment |
---|---|---|---|

2000 | LDA | [3000] | [A] <- [3000] |

2003 | CMA | [A] <- [A^] | |

2004 | STA | [3001] | 1’s complement |

2007 | ADI | 01 | [A] <- [A] + 01 |

2009 | STA | [3002] | 2’s complement |

200C | HLT | Stop |

**Explanation –**

**A**is an 8-bit accumulator which is used to load and store the data directly**LDA**is used to load accumulator direct using 16-bit address (3 Byte instruction)**CMA**is used to complement content of accumulator (1 Byte instruction)**STA**is used to store accumulator direct using 16-bit address (3 Byte instruction)**ADI**is used to add data into accumulator immediately (2 Byte instruction)**HLT**is used to halt the program

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find 2's complement of the contents of Flag Register
- What’s difference between 1's Complement and 2's Complement?
- Interface 8255 with 8085 microprocessor for 1’s and 2’s complement of a number
- 8085 program to find the factorial of a number
- 8085 program to find square root of a number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find nth power of a number
- 8085 program to find square of a 8 bit number
- 8085 program to find smallest number between two numbers
- 8085 program to find minimum value of digit in the 8 bit number
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to count number of ones in the given 8-bit number
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to find maximum and minimum of 10 numbers
- 1's and 2's complement of a Binary Number
- Check if binary representation of a given number and its complement are anagram
- 8085 program to show masking of lower and higher nibbles of 8 bit number
- 8085 program to perform AND operation in nibbles of 8 bit number
- Find relative complement of two sorted arrays

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.