> In 8051 asembly program, how to determine whether the register used when writing the code isin cpu or in ram?

In 8051 asembly program, how to determine whether the register used when writing the code isin cpu or in ram?

Posted at: 2014-12-18 
MOVX is for external RAM. Some 8051's have RAM internal that is considered external and still uses MOVX.

I think you are referring to the RAM that is located at address 0x00 - 0xff, and the SFR registers that are at 0x80 - 0xff.

The RAM registers located at 0x80 and up are accessed using indirect addressing using R0, which contains the address of the register. Basically treating R0 as a pointer to the location.

The SFR registers located at 0x80 and up are accessed using direct addressing, which means its a simple MOV instruction.

So:

RAM address 0x40 is accessed using direct addressing

MOV 40H, #10H

RAM at address 0x90 is accessed using indirect addressing.

MOV R0, 90H

MOV @R0, #10H

SFR at address 0x90 is accessed using direct addressing

MOV 90H, #10H

So in the end you determine it by the type of addressing used.

If its direct addressing (0x80 and above) its accessing the SFR registers.

if its indirect addressing (0x80 and above) its accessing internal RAM.

RAM is accessed using the MOVX instruction, registers do not use MOVX. If you are writing the program, you need to make yourself totally familiar with the differences.

By definition, all registers are in the CPU.