Assembly Language Programming

Post-indexed Addressing

A fifth and final addressing mode is post-indexed addressing, which is always auto-indexing. In this mode, the base address stored in the base register is used directly as the effective address, and it is then auto-indexed to point to the next memory location.

LDR r0, [r1, #4] ; load value at memory location pointed to by r1.
    ; Then increment r1 such that r1:= r1 +4

The copy data example program can then be modified as follows:

copycode ADR r1, SOURCEDATA ; the value of r1 points to the SOURCEDATA location in memory
  ADR r2, DESTDATA ; the value of r2 points to the DESTDATA location in memory
loop LDR r0, [r1], #4 ; load value at memory location pointed to by r1 into r0. Increment r1
  STR r0, [r2], #4 ; store value in r0 to memory location pointed to by r2. Increment r2
  .   ; decide if more data is available and if so branch to loop
SOURCEDATA   . ; source of data
    .  
DESTDATA   . ; destination for the data