Texas Instruments MSC1210 User Manual

Page 60

Advertising
background image

External Indirect Addressing

5-6

5.6

External Indirect Addressing

External memory can also be accessed using a form of indirect addressing
called external indirect. This form of addressing is usually only used in relative-
ly small projects that have a very small amount of external RAM. An example
of this addressing mode is:

MOVX @R0,A

Once again, the value of R0 is first read and the value of the accumulator is
written to that address in external RAM, internal extended SRAM, and internal
flash data memory. High address A8

A15 is provided by the MPAGE SFR be-

cause the value of @R0 can only be 00

H

through FF

H—

that is A0

A7 of the

previous memories.

5.7

Code Indirect Adressing

The last addressing mode is called code indirect and offers two additional 8052
instructions that allow you to access the program code itself. This is useful for
accessing data tables, strings, etc. The two instructions are:

MOVC A,@A+DPTR

MOVC A,@A+PC

For example, if you want to access the data stored in code memory at address
2021

H

, execute the instructions:

MOV

DPTR,#2021h

;Set DPTR to 2021h

CLR A

;Clear the accumulator (set to 00h)

MOVC A,@A+DPTR

;Read code memory address 2021h into
;the accumulator

The MOVC A,@A+DPTR instruction moves the value contained in the code
memory address that is pointed to by adding DPTR to the accumulator.

To write to flash code memory, set the MXWS bit and MOVX will write to flash
code memory (if the memory is not write protected by harware configuration
bits). The same operation can be used to perform flash page erase. See sec-
tion 1.5, Flash Memory, for more details.

Advertising