8085 program to separate (or split) a byte into two nibbles
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 –
- Load the content of memory location 2500 in accumulator A.
- Now we will perform AND operation with the content of accumulator and OFH.
- Using STA we will now store the result in 2501H memory location.
- Using LDA we’ll load the content of 2500H in the accumulator.
- Once again perform AND operation to separate another nibble i.e AND operation with the content of accumulator and F0H.
- Now rotate each bit in accumulator right by one position and repeat this step four times.
- Now using STA we will store another nibble in 2502H memory location.
Program –
MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|
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.
- LDA 2500H – loads the content of memory location 2500 in accumulator A.
- ANI 0FH –Perform AND operation with contents of accumulator and 0FH.
- STA 2501H –store contents of Accumulator to memory location 2501H.
- LDA 2500H – loads the content of memory location 2500 in accumulator A.
- ANI F0H – Perform AND operation with contents of accumulator and F0H.
- RRC –rotate each bit in accumulator right by one position.
- RRC –rotate each bit in accumulator right by one position.
- RRC –rotate each bit in accumulator right by one position.
- RRC –rotate each bit in accumulator right by one position.
- STA 2502H –store contents of Accumulator to memory location 2502H.
- HLT –Stop the execution of program.
Contact Us