Autoincrement and Decrement Addressing Modes (with Proper Examples)
Autoincrement and autodecrement are memory-indirect addressing patterns where a pointer register is automatically updated as part of the load/store. In common assembler syntax, this is often written with symbols like:
- Autoincrement: use , then increment for the next access
- Autodecrement: decrement , then use the new
- Pointer register
- Effective address
The key idea: the pointer update is implicit in the addressing mode, so a loop can traverse arrays without separate add/sub instructions. The exact “increment/decrement amount” depends on the architecture and operand size (e.g., increment by 1 for bytes, by 2 for halfwords, etc.).
Note: Different ISAs use different mnemonics/syntax (e.g., 68k style vs. ARM vs. custom educational assemblers). The semantics below match the canonical “update-before” / “update-after” behavior used in systems teaching these addressing modes.
Footnotes
-
Autoincrement addressing mode (concept) — overview - Describes update-after (autoincrement-like) addressing mode behavior. ↩
-
Autodecrement addressing mode (concept) — overview - Describes update-before (autodecrement-like) addressing mode behavior and variants. ↩
-
ARM load/store addressing with pre/post indexing and writeback - ARM documentation site describing pre/post-indexing and writeback semantics for effective addresses. ↩
-
Stack and addressing mode relationship (general addressing modes) - Background on stack conventions often implemented using pointer increment/decrement patterns. ↩
Addressing modes: autoincrement/autodecrement intuition
Autoincrement addressing (update-after)
Autoincrement uses the current pointer value to form the effective address, performs the memory read/write, and then increments the pointer register for the next access.
Typical pseudo-syntax (architecture-dependent):
LD Rdest, (Rptr)+orLDR Rdest, [Rptr], #+k
Where:
- Effective address
- After the access:
Here is usually the operand size (bytes for byte loads/stores, etc.). This “post-update” behavior is the defining feature of autoincrement. 2
Worked example (conceptual)
Assume:
- Operand size = 4 bytes (so )
- Memory:
Mem[0x1000] = 0xAAAA5555Mem[0x1004] = 0xBBBB6666
Instruction:
LOAD R1, (Rptr)+
Semantics:
- Compute
- Load
R1 ← Mem[0x1000] = 0xAAAA5555 - Update pointer:
So after the instruction:
R1 = 0xAAAA5555Rptr = 0x1004
This “use then increment” pattern is widely used to walk through arrays sequentially. 2
Footnotes
-
Autoincrement addressing mode (concept) — overview - Describes update-after (autoincrement-like) addressing mode behavior. ↩ ↩2
-
Autodecrement addressing mode (concept) — overview - Describes update-before (autodecrement-like) addressing mode behavior and variants. ↩ ↩2
Autodecrement addressing (update-before)
Autodecrement decrements the pointer register and then uses the new value as the effective address.
Typical pseudo-syntax:
LD Rdest, -(Rptr)orLDR Rdest, [Rptr, #-k]!
Where:
- Update-first:
- Then effective address
- Then memory access uses
This “pre-update” behavior is the defining feature of autodecrement. 2
Worked example (conceptual)
Assume:
- Operand size = 4 bytes ()
- Memory:
Mem[0x2004] = 0x11112222Mem[0x2008] = 0x33334444
Instruction:
LOAD R1, -(Rptr)
Semantics:
- Decrement pointer first:
- Load
R1 ← Mem[0x2004] = 0x11112222
After:
R1 = 0x11112222Rptr = 0x2004
Autodecrement is useful for reverse traversal and for stack-like behavior (though real “stack” conventions are architecture-specific). 2
Footnotes
-
Autodecrement addressing mode (concept) — overview - Describes update-before (autodecrement-like) addressing mode behavior and variants. ↩ ↩2
-
ARM load/store addressing with pre/post indexing and writeback - ARM documentation site describing pre/post-indexing and writeback semantics for effective addresses. ↩ ↩2
type="tip" title="Pro Tip" content="To avoid confusion, always decide whether the update is post (autoincrement: use EA first) or pre (autodecrement: update pointer first), then check whether equals operand size in bytes."
type="warning" title="Warning: Syntax varies across ISAs" content="Different architectures write these modes differently (e.g., post-index vs pre-index writeback). Always map the syntax to the underlying semantics: formation and whether pointer update is before/after."
How to reason about autoincrement/decrement in any assembly syntax
- 1Step 1
Look for patterns like (Rptr)+, -(Rptr), [Rptr], #+k, [Rptr,#-k]!, etc. These indicate post-update or pre-update.
- 2Step 2
Find whether the instruction operates on byte/halfword/word/dword to compute the increment/decrement amount .
- 3Step 3
If autoincrement: then . If autodecrement: then .
- 4Step 4
Perform the load/store at address .
- 5Step 5
After the memory operation, ensure reflects the implicit update for the next iteration.
- 6Step 6
Simulate two iterations to confirm the pointer moves in the expected direction and by the expected stride .
Semantic summary: EA computation and pointer update order
Compare autoincrement (post-update) vs autodecrement (pre-update)
Concrete examples in pseudocode + typical assembly forms
Because exact syntax differs, it’s helpful to express the semantics in a uniform pseudocode form.
Autoincrement pseudocode
- Input:
- Compute:
- Access:
- Update:
Autodecrement pseudocode
- Input:
- Update:
- Compute:
- Access:
These update-before vs update-after semantics are the core of the addressing modes across teaching materials. 3
Footnotes
-
Autoincrement addressing mode (concept) — overview - Describes update-after (autoincrement-like) addressing mode behavior. ↩
-
Autodecrement addressing mode (concept) — overview - Describes update-before (autodecrement-like) addressing mode behavior and variants. ↩
-
ARM load/store addressing with pre/post indexing and writeback - ARM documentation site describing pre/post-indexing and writeback semantics for effective addresses. ↩
Common questions and edge cases
Knowledge Check
In autoincrement addressing, when is the pointer register updated relative to the memory access?