Tutorialspoint.dev

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 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 –

  1. Load the data from memory 3000 into A (accumulator)
  2. Complement content of accumulator
  3. Store content of accumulator in memory 3001 (1’s complement)
  4. Add 01 to Accumulator content
  5. Store content of accumulator in memory 3002 (2’s complement)
  6. 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 –

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


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter