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 –

2000 LDA 2500H A <- M[2500]
2003 ANI 0FH A <- A (AND) 0FH
2005 STA 2501H M[2501] <- A
2008 LDA 2500H A <- M[2500]
200B ANI F0H A <- A (AND) F0H
200D RRC Rotate right by one position
200E RRC Rotate right by one position
200F RRC Rotate right by one position
2010 RRC Rotate right by one position
2011 STA 2502H M[2502] <- A
2014 HLT Stop 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.
My Personal Notes arrow_drop_up
Related Articles