Skip to content
Related Articles

Related Articles

Improve Article

8085 program to separate (or split) a byte into two nibbles

  • Last Updated : 18 Jun, 2018

Problem – Write an assembly language program in 8085 microprocessor to split a byte into two nibbles and store result in 2001H and 2002H.
Example –

Algorithm –

  1. Load the content of memory location 2500 in accumulator A.
  2. Now we will perform AND operation with the content of accumulator and OFH.
  3. Using STA we will now store the result in 2501H memory location.
  4. Using LDA we’ll load the content of 2500H in the accumulator.
  5. Once again perform AND operation to separate another nibble i.e AND operation with the content of accumulator and F0H.
  6. Now rotate each bit in accumulator right by one position and repeat this step four times.
  7. Now using STA we will store another nibble in 2502H memory location.

Program –



MEMORY ADDRESSMNEMONICSCOMMENT
2000LDA 2500HA <- M[2500]
2003ANI 0FHA <- A (AND) 0FH
2005STA 2501HM[2501] <- A
2008LDA 2500HA <- M[2500]
200BANI F0HA <- A (AND) F0H
200DRRCRotate right by one position
200ERRCRotate right by one position
200FRRCRotate right by one position
2010RRCRotate right by one position
2011STA 2502HM[2502] <- A
2014HLTStop the program.

Explanation –
RRC – Each binary bit of the accumulator is rotated right by one position. Bit D0 is placed in the position of D7 as well as in the Carry flag. CY is modified according to bit D0.

  1. LDA 2500H – loads the content of memory location 2500 in accumulator A.
  2. ANI 0FH –Perform AND operation with contents of accumulator and 0FH.
  3. STA 2501H –store contents of Accumulator to memory location 2501H.
  4. LDA 2500H – loads the content of memory location 2500 in accumulator A.
  5. ANI F0H – Perform AND operation with contents of accumulator and F0H.
  6. RRC –rotate each bit in accumulator right by one position.
  7. RRC –rotate each bit in accumulator right by one position.
  8. RRC –rotate each bit in accumulator right by one position.
  9. RRC –rotate each bit in accumulator right by one position.
  10. STA 2502H –store contents of Accumulator to memory location 2502H.
  11. HLT –Stop the execution of program.

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 :