Skip to main content
Be Bitwise

Array in Memory

Store a sequence of values at consecutive memory addresses and read them back. This is how arrays work at the lowest level - just numbers at adjacent addresses.

An array is not a special data structure at the hardware level — it is simply a sequence of values stored at consecutive memory addresses. Accessing element N means computing base_address + N and reading from that address. This simulation shows the fundamental pattern: a base address in one register, an offset that increments, and STORE/LOAD instructions that move data between registers and memory.

Simulator

Loading simulator...

Walkthrough Guide

  1. 1

    Set up base address and first value

    Do this: Step through the first two MOV instructions

    Watch for: R0 = 128 (base address), R1 = 10 (first value)

    R0 acts as a pointer — it holds the memory address where the next element will be stored. R1 holds the value to write.

  2. 2

    Store the array elements

    Do this: Step through the alternating STORE / ADD / ADD pattern

    Watch for: Values 10, 11, 12, 13 appear at addresses 128, 129, 130, 131 in the memory grid

    After each STORE, we increment both the address (R0 += 1) and the value (R1 += 1). This creates an array [10, 11, 12, 13] at consecutive addresses. The +1 to the address is pointer arithmetic.

  3. 3

    Reset the pointer and read back

    Do this: Step through MOV R0, #128 then LOAD R2, [R0] and the remaining instructions

    Watch for: R0 resets to 128 (base address). R2 = 10, R3 = 11 after the LOADs

    To read back, we point R0 at the base address again and LOAD from it. Incrementing R0 by 1 advances to the next array element. This is exactly how array indexing works: base + index.

Objectives

  • •Watch values 10, 11, 12, 13 appear at memory addresses 128, 129, 130, 131
  • •See R0 act as a pointer that advances through the array
  • •Observe LOAD reading values back from memory into R2 and R3
  • •Notice the pattern: incrementing the address by 1 moves to the next array element

Hints

  • An array is just values stored at consecutive addresses - the base address plus an offset gives you each element