Ax51 User's Guide

XDATA

The XDATA memory class can be accessed with the instruction MOVX via the register DPTR. A single page of the XDATA memory can be also accessed via the registers R0, R1. At the C Compiler level this memory type is called pdata and the segment prefix ?PD? is used. The high address for this pdata page is typically set with the P2 register. But in new 8051 variants there are also dedicated special function registers that define the XDATA page address.

Example for all 8051 variants
?XD?my_seg SEGMENT XDATA                ; define a SEGMENT of class XDATA
           RSEG    ?ED?my_seg
XBUFFER:   DS      100                  ; reserve 100 Bytes

?PD?myvars SEGMENT XDATA INPAGE         ; define a paged XDATA segment
           RSEG    ?PD?myvars
VAR1:      DS      1                    ; reserve 1 byte

?PR?myprog SEGMENT CODE                 ; define a segment for program code
           RSEG    ?PR?myprog
           MOV     P2,#HIGH ?PD?myvars  ; load page address register
            :
           MOV     DPTR,#XBUFFER        ; load address
           MOVX    A,@DPTR              ; access via DPTR
           MOV     R1,#VAR1             ; load address
           MOVX    @R1,A                ; access via R0 or R1