Skip to content
Related Articles
Open in App
Not now

Related Articles

8085 program to find 1’s and 2’s complement of 16-bit number

Improve Article
Save Article
Like Article
  • Difficulty Level : Expert
  • Last Updated : 03 Oct, 2018
Improve Article
Save Article
Like Article

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 –

  1. Load a 16-bit number from memory 3000 into a register pair (H-L)
  2. Move content of register L to accumulator
  3. Complement content of accumulator
  4. Move content of accumulator to register L
  5. Move content of register H to accumulator
  6. Complement content of accumulator
  7. Move content of accumulator to register H
  8. Store content of register pair in memory 3002 (1’s complement)
  9. Increment content of register pair by 1
  10. Store content of register pair in memory 3004 (2’s complement)
  11. Stop

Program –

MemoryMnemonicsOperandsComment
2000LHLD[3000][H-L] <- [3000]
2003MOVA, L[A] <- [L]
2004CMA[A] <- [A^]
2005MOVL, A[L] <- [A]
2006MOVA, H[A] <- [H]
2007CMA[A] <- [A^]
2008MOVH, A[H] <- [A]
2009SHLD[3002]1’s complement
200CINXH[H-L] <- [H-L] + 1
200DSHLD[3004]2’s complement
2010HLTStop

Explanation –

  1. A is an 8-bit accumulator which is used to load and store the data
  2. LHLD is used to load register pair H-L direct using 16-bit address (3 Byte instruction)
  3. MOV is used to transfer the data from accumulator to register(any) or register(any) to accumulator (1 Byte)
  4. CMA is used to complement content of accumulator (1 Byte instruction)
  5. SHLD is used to store data from register pair H-L into memory direct using 16-bit address (3 Byte instruction)
  6. INX is used to increase H-L register pair by 1 (1 Byte instruction)
  7. HLT is used to halt the program
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!