Output
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.
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'
1 thought on “8051 Program to Rotate DPTR value”