The near memory access method
In this section:
Near memory is the memory that is located at ±32 Kbytes around address 0. The assembler code for storing something using this memory access method is simply:
ST.W R1, x[R0]
Remember that R0 will act as a normal processor register with the exception that the value of the register always will be zero.
Clearly, the memory range that this assembler instruction can access is limited by the range of the displacement. Because the displacement is limited to a signed 16-bit value, only the first and last 32 Kbytes of memory can be reached.
Examples
Address of:
movea MyVar, r0, r1
Reading a global variable:
ld.b MyVar[zero], r1
Reading a global array using an unknown index:
ld.b MyArr[r1], r6
Reading a structure using a pointer:
ld.b (4)[r1],r1