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 Rotate content of accumulator left by 1 bit
2004 RLC Rotate content of accumulator left by 1 bit
2005 RLC Rotate content of accumulator left by 1 bit
2006 RLC Rotate content of accumulator left by 1 bit
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: Rotate content of accumulator left by 1 bit
  3. RLC: Rotate content of accumulator left by 1 bit
  4. RLC: Rotate content of accumulator left by 1 bit
  5. RLC: Rotate content of accumulator left by 1 bit
  6. STA 3050: store content of A in memory location 3050.
  7. HLT: stops executing the program and halts any further execution.

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.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.



Improved By : dilipsolanki1020