24.2 Example Routines
24.2.1 Example Routine 1
Copy 4 bytes of data stored in program space 1000H to 1003H in reverse to 0100H to 0103H of the extended RAM, that is,
C:1000H -> X:0103H
C:1001H -> X:0102H
C:1002H -> X:0101H
C:1003H -> X:0100H
Assembly code
;Operating frequency for test is 11.0592MHz
P0M1 DATA 093H
P0M0 DATA 094H
P1M1 DATA 091H
P1M0 DATA 092H
P2M1 DATA 095H
P2M0 DATA 096H
P3M1 DATA 0B1H
P3M0 DATA 0B2H
P4M1 DATA 0B3H
P4M0 DATA 0B4H
P5M1 DATA 0C9H
P5M0 DATA 0CAH
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP, #5FH
MOV P0M0, #00H
MOV P0M1, #00H
MOV P1M0, #00H
MOV P1M1, #00H
MOV P2M0, #00H
MOV P2M1, #00H
MOV P3M0, #00H
MOV P3M1, #00H
MOV P4M0, #00H
MOV P4M1, #00H
MOV P5M0, #00H
MOV P5M1, #00H
MOV DPS,#00100000B ; enable TSL and select DPTR0
MOV DPTR,#1000H ; write 1000H to DPTR0, and then select DPTR1 as current DPTR
MOV DPTR,#0103H ; write 0103H to DPTR1
MOV DPS,#10111000B ;set DPTR1 in auto decreasing mode,
;DPTR0 in auto increasing mode,enable TSL, AU0 and AU1,
;select DPTR0 as the current DPTR
MOV R7,#4 ; set the counter of copies
COPY_NEXT:
CLR A ;
MOVC A,@A+DPTR ; Read data from the program space indicated by DPTR0,
; When done, DPTR0 increments automatically and select DPTR1 as the current DPTR
MOVX @DPTR,A ; write the content of ACC to XDARA indicated by DPTR1,