Skip to content
Related Articles

Related Articles

Improve Article
8085 program to reverse 8 bit number
  • Last Updated : 21 May, 2020

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 ADDRESSMNEMONICSCOMMENT
2000LDA 2050A <- M[2050]
2003RLCRotate content of accumulator left by 1 bit
2004RLCRotate content of accumulator left by 1 bit
2005RLCRotate content of accumulator left by 1 bit
2006RLCRotate content of accumulator left by 1 bit
2007STA 3050M[2050] <- A
200AHLTEND

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
Recommended Articles
Page :