8051 Program to Rotate DPTR value
8051 Program to Rotate DPTR Value.
ALGORITHM:
- Start.
- Load the value to be rotated in DPTR.
- Move the Lower nibble of DPTR in Accumulator.
- Rotate Left 8 bits along with carry.
- Move the Upper nibble of DPTR in Accumulator.
- Rotate Left 8 bits along with carry.
- Now we got the Upper nibble of DPTR move it to DPH.
- Move the Lower nibble of DPTR in Accumulator.
- Rotate Left 8 bits along with carry.
- Now we got the Lower nibble of DPTR move it to DPL.
- The output is stored in the DPTR.
- End.
After rotating the DPTR the value will be:
CODE:
! Information
To get details about instructions used visit Keil Website.
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 |
If you are facing problem reading the code.Download this code.
Click on the link below to Download
Click on the link below to Download
No comments: