1 64-byte block move with dual data pointer, Emory, Ccess – Maxim Integrated High-Speed Microcontroller User Manual
Page 82: Figure 6-3. data memory interface

High-Speed Microcontroller User’s Guide
Rev: 062210
82 of 176
The user switches between data pointers by toggling the SEL bit. The INC instruction is the fastest way to
accomplish this. All DPTR-related instructions use the currently selected DPTR for any activity.
Therefore only one instruction is required to switch from a source to a destination address. Using the Dual
Data Pointer saves code from needing to save source and destination addresses when doing a block move.
Once loaded, the software simply switches between DPTR0 and DPTR1. Sample code listed below
illustrates the saving from using the dual DPTR. The relevant register locations are summarized as
follows.
Low byte original DPTR
High byte original DPTR
84h
Low byte new DPTR1
85h
High byte new DPTR1
DPTR Select (LSb)
The example program listed below was original code written for an 8051 and requires a total of 1869
machine cycles on the DS80C320. This takes 299
s to execute at 25MHz. The new code using the Dual
DPTR requires only 1097 machine cycles taking 175.5
s. The Dual DPTR saves 772 machine cycles or
123.5
s for a 64-byte block move. Since each pass through the loop saves 12 machine cycles when
compared to the single DPTR approach, larger blocks gain more efficiency using this feature.
A typical application of the Dual Data Pointer is moving data from an external RAM to a memory-
mapped display. Another application would be to retrieve data from a stored table, process it using a
software algorithm, and store the result in a new table.
6.5.1 64-Byte Block Move With Dual Data Pointer
; SH and SL are high and low byte source address.
; DH and DL are high and low byte of destination address.
; DPS is the data pointer select. Reset condition DPTR0.
#
CYCLES
DPS
EQU 86h
; TELL ASSEMBLER ABOUT DPS
MOV
R5, #64
; NUMBER OF BYTES TO MOVE
2
MOV
DPTR, #DHDL
; LOAD DESTINATION ADDRESS
3
INC
DPS
; CHANGE ACTIVE DPTR
2
MOV
DPTR, #SHSL
; LOAD SOURCE ADDRESS
2
MOVE:
; THIS LOOP IS PERFORMED R5 TIMES, IN THIS EXAMPLE 64
MOVX
A, @DPTR
; READ SOURCE DATA BYTE
2
INC
DPS
; CHANGE DPTR TO DESTINATION
2
MOVX
@DPTR, A
; WRITE DATA TO DESTINATION
2
INC
DPTR
; NEXT DESTINATION ADDRESS
3
INC
DPS
; CHANGE DATA POINTER TO SOURCE
2
INC
DPTR
; NEXT SOURCE ADDRESS
3
DJNZ
R5, MOVE
; FINISHED WITH TABLE?
3