Tutorialspoint.dev

8085 program to reverse 8 bit number

Problem – Write an assembly language program in 8085 microprocessor to reverse 8 bit number.

Example –

Assume that number to be reversed is stored at memory location 2050, and reversed number is stored at memory location 3050.

Algorithm –

  1. Load content of memory location 2050 in accumulator A
  2. Use RLC instruction to shift content of A by 1 bit without carry. Use this instruction 4 times to reverse the content of A
  3. Store content of A in memory location 3050

Program –

MEMORY ADDRESS MNEMONICS COMMENT
2000 LDA 2050 A <- M[2050]
2003 RLC Shift content of accumulator left by 1 bit without carry
2004 RLC Shift content of accumulator left by 1 bit without carry
2005 RLC Shift content of accumulator left by 1 bit without carry
2006 RLC Shift content of accumulator left by 1 bit without carry
2007 STA 3050 M[2050] <- A
200A HLT END

Explanation – Register A used:

  1. LDA 2050: load value of memory location 2050 in Accumulator A.
  2. RLC: shift content of accumulator left by 1 bit without carry.
  3. RLC: shift content of accumulator left by 1 bit without carry.
  4. RLC: shift content of accumulator left by 1 bit without carry.
  5. RLC: shift content of accumulator left by 1 bit without carry.
  6. STA 3050: store content of A in memory location 3050.
  7. HLT: stops executing the program and halts any further execution.


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter