3 Instruction Organisation in Memory

Instructions are stored in memory as machine codes (binary patterns).
ARM instructions are human-readable representations of machine code.

ARM instructions are 32 bits long.

ARM Instruction format (32 bits long)

3.1 ARM Programmer’s Model

Programmer’s model is an abstract, simplified view of the processor.
It includes just the parts a programmer needs to write and run code.

Visible registers in User Mode of the ARM processor

3.2 Execution Cycle

The CPU repeatedly performs the Fetch-Decode-Execute cycle.

Considering the instruction 𝙻𝙳𝚁 𝚁𝟷, [𝚁𝟶]\texttt{LDR R1, [R0]}, and where the instruction and data are stored:

We get this execution cycle:

  1. Fetch cycle - Instruction

    PC points to address of next instruction, the opcode fed into IR.
  2. Fetch cycle - Operand

    Another fetch required to retrieve operand in CPU.
  3. Execute Cycle - Load

    The operand fetched from memory is loaded into memory.

Takeaways:

  1. Different instructions require multiple accesses to memory, hence taking different number of clock cycles.

  2. von Neumann bottleneck - System performance limited by data traffic bandwidth between CPU and memory, because data transfer on the external bus is slower than within CPU’s internal bus. Hence keeping regularly used operands in the CPU registers may help reduce memory access.

  3. Keeping instructions and data in separate memories (i.e. Harvard architecture) can make instructions execute in more regular cycles (using parallel fetches).