We all are familiar with the number system whether it be binary, decimal, hexadecimal, etc.

While executing programs throughout this series we have mostly taken 8-bit numbers but the 8085 microprocessor doesn’t take it as an 8-bit number rather it takes a binary number.

Therefore, whatever number we input let it be an 8-bit number or a 16-bit number, all the numbers are converted into binary format. So for this program, we are going to take an 8-bit number and then store it at any GPR.


Let the 8-bit hexadecimal number be 0AH, and instead of storing this 8-bit data on a memory location, we are going to store this value in B register.


MVI B, 0A// the 8-bit immediate data is stored at B register

MVI H, 00// the content of H register by zero

MVI L, 00 // the content of L register is set to zero

MVI C, 08 // the content of C register is assigned with 8 which will act as a counter

MOV A, B // the content of B register is copied to the accumulator

Label1 RAR //each bit of the accumulator is rotated right one by one through the carry flag

JNC Label2 // JNC will jump when carry flag is not set

INR H // the  content of H register is incremented by 1

JMP Label3 // JMP will jump to DCR C

Label2 INR L // the content of L register is incremented by 1

Label3 DCR C // the content of C register gets decremented by 1

JNZ Label1 // JNZ will jump to RAR



Programming Details
Memory Location OPCODE Operand Label Hex Code
2000 MVI B, 0A O6H
2001 0AH
2002 MVI H, 00 26H
2003 00H
2004 MVI L, 00 2EH
2005 00H
2006 MVI C, 08 0EH
2007 08H
2008 MOV A,B 78H
2009 RAR Label1 1FH
200A JNC Label2 D2H
200B 11H
200C 20H
200D INR H 23H
200E JMP Label3 C3H
200F 12H
2010 20H
2011 INR L Label2 22H
2012 DCR C Label3 0DH
2013 JNZ Label1 C2H
2014 09H
2015 20H
2016 HLT 76H