Texas Instruments MSC1210 User Manual

Page 58

Advertising
background image

Indirect Addressing

5-4

5.4

Indirect Addressing

Indirect addressing is a very powerful addressing mode that in many cases
provides an exceptional level of flexibility. Indirect addressing is also the only
way to access the upper 128 bytes of Internal RAM found on an 8052.

Indirect addressing appears as follows:

MOV A,@R0

This instruction causes the MSC1210 to analyze the value of the R0 register.
The MSC1210 then loads the accumulator (A) with the value from Internal
RAM that is found at the address indicated by R0.

For example, suppose R0 holds the value 40

H

and internal RAM address 40

H

holds the value 67

H

. When the above instruction is executed, the 8052 checks

the value of R0. The MSC1210 gets the value out of internal RAM address 40

H

(which holds 67

H

) and stores it in the accumulator because R0 holds 40

H

.

Thus, the accumulator ends up holding 67

H

.

Indirect addressing always refers to internal RAM; it never refers to an SFR.
In a prior example, it was mentioned that SFR 99

H

can be used to write a value

to the serial port. Therefore, one can think that the following code would be a
valid solution to write the value of 1 to the serial port:

MOV R0,#99h

;Load the address of the serial port

MOV @R0,#01h ;Send 01 to the serial port −− WRONG!!

This is not valid. These two instructions write the value 01

H

to internal RAM

address 99

H

on the MSC1210 because indirect addressing always refers to

internal RAM.

Advertising