Ax51 User's Guide

CODE

CODE memory can be accessed with the instruction MOVC via the DPTR register.

Example for all 8051 variants
?CO?my_seg SEGMENT CODE                ; define a SEGMENT of class CODE
           RSEG    ?CO?my_seg
TABLE:     DB      1,2,4,8,0x10        ; a table with constant values

?PR?myprog SEGMENT CODE                ; define a segment for program code
           RSEG    ?PR?myprog
           MOV     DPTR,#TABLE         ; load address of table
           MOV     A,#3                ; load offset into table
           MOVC    A,@A+DPTR           ; access via MOVC instruction