CPU: 8051 based
The following lines of code will set 0xaa
value at 0x0aaa
address in external flash memory.
mov a,#0aah
mov dptr,#X0aaa
movx @dptr,a
The following is mov
The MOV instruction allows data to be transferred between any internal I-RAM spaces or SFR locations and between accumulator to internal I-RAM spaces or SFR locations.
and and movx instruction descriptions from CPU datasheet
MOVX instruction is used to access the internal X-RAM and e-FLASH area. Only indirect addressing can be used. The choice whether to use a one-byte address, @Ri, where Ri can be either R0 or R1 of the selected register bank, or a two-byte address, @DPTR.
Some code that I've seen in examples:
xdata UCHAR * data ecFlashaaa = (xdata UCHAR *)(0xaaa);
*ecFlashaaa = 0xaa;
the code doesn't compile because it doesn't know what is xdata
and also confused on data
. So somehow I need to explain linker that ecFlashaaa is pointing to e-Flash...