8051 Program to Rotate DPTR value

8051 Program to Rotate DPTR Value. 
ALGORITHM:
  1. Start.
  2. Load the value to be rotated in DPTR.
  3. Move the Lower nibble of DPTR in Accumulator.
  4. Rotate Left 8 bits along with carry.
  5. Move the Upper nibble of DPTR in Accumulator.
  6. Rotate Left 8 bits along with carry.
  7. Now we got the Upper nibble of DPTR move it to DPH.
  8. Move the Lower nibble of DPTR in Accumulator.
  9. Rotate Left 8 bits along with carry.
  10. Now we got the Lower nibble of DPTR move it to DPL.
  11. The output is stored in the DPTR.
  12. End.
For example if we are trying to rotate the number as below.

After rotating the DPTR the value will be:
! Information
To get details about instructions used visit Keil Website.
CODE:


ORG 0000H
MOV DPTR,#0A550H         ;Number to be rotated
MOV A,DPL                ;Lower nibble in A
RLC A                    ;Rotate left 8 bits
MOV A,DPH                ;Upper nibble in A
RLC A                    ;Rotate left 8 nibble
MOV DPH,A                ;MOV A -> DPH
MOV A,DPL                ;Lower nibble in A
RLC A                    ;Rotate left 
MOV DPL,A                ;MOV A -> DPL
END


Output Images:
Rotate DPTR Output Image
Download Code:
If you are facing problem reading the code.Download this code.
Click on the link below to Download


8051 Rotate DPTR File

No comments:

Powered by Blogger.