Texas Instruments MSC1210 manual Indirect Addressing

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 58
Image 58

Indirect Addressing

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 40H and internal RAM address 40H holds the value 67H. When the above instruction is executed, the 8052 checks the value of R0. The MSC1210 gets the value out of internal RAM address 40H (which holds 67H) and stores it in the accumulator because R0 holds 40H. Thus, the accumulator ends up holding 67H.

Indirect addressing always refers to internal RAM; it never refers to an SFR. In a prior example, it was mentioned that SFR 99H 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 01H to internal RAM address 99H on the MSC1210 because indirect addressing always refers to internal RAM.

5-4

Page 58
Image 58
Texas Instruments MSC1210 manual Indirect Addressing