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

Algorithm –
- Load a 16-bit number from memory 3000 into a register pair (H-L)
- Move content of register L to accumulator
- Complement content of accumulator
- Move content of accumulator to register L
- Move content of register H to accumulator
- Complement content of accumulator
- Move content of accumulator to register H
- Store content of register pair in memory 3002 (1’s complement)
- Increment content of register pair by 1
- Store content of register pair in memory 3004 (2’s complement)
- Stop
Program –
| Memory | Mnemonics | Operands | Comment |
|---|---|---|---|
| 2000 | LHLD | [3000] | [H-L] <- [3000] |
| 2003 | MOV | A, L | [A] <- [L] |
| 2004 | CMA | [A] <- [A^] | |
| 2005 | MOV | L, A | [L] <- [A] |
| 2006 | MOV | A, H | [A] <- [H] |
| 2007 | CMA | [A] <- [A^] | |
| 2008 | MOV | H, A | [H] <- [A] |
| 2009 | SHLD | [3002] | 1’s complement |
| 200C | INX | H | [H-L] <- [H-L] + 1 |
| 200D | SHLD | [3004] | 2’s complement |
| 2010 | HLT | Stop |
Explanation –
- A is an 8-bit accumulator which is used to load and store the data
- LHLD is used to load register pair H-L direct using 16-bit address (3 Byte instruction)
- MOV is used to transfer the data from accumulator to register(any) or register(any) to accumulator (1 Byte)
- CMA is used to complement content of accumulator (1 Byte instruction)
- SHLD is used to store data from register pair H-L into memory direct using 16-bit address (3 Byte instruction)
- INX is used to increase H-L register pair by 1 (1 Byte instruction)
- HLT is used to halt the program
Recommended Posts:
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 2's complement of the contents of Flag Register
- Interface 8255 with 8085 microprocessor for 1’s and 2’s complement of a number
- 8085 program to find nth power of a number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find the factorial of a number
- 8085 program to find square of a 8 bit number
- 8085 program to find square root of a 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 find the set bit of accumulator
- 8085 program to find the sum of a series
- 8085 program to find the sum of series of even numbers
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find the element that appears once
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.



