ARM Target Guide

The MIRR compiler includes an ARM Thumb-2 backend that translates R-SPU programs into ARM assembly suitable for Cortex-M microcontrollers.

Overview

The ARM backend maps R-SPU instructions to Thumb-2 assembly with:

  • Memory-mapped I/O at 0x4000_0000
  • IT blocks for conditional execution
  • Shift register emulation via data memory
  • Counter emulation via subtract-and-compare

Register Mapping

R-SPU RegisterARM RegisterPurpose
R0–R63R0–R63Input ports
R64–R127R64–R127Output ports
R128–R191R128–R191Internal signals
R192–R255R192–R255Expression temporaries

Memory-Mapped I/O

AddressPurpose
0x4000_0000Input port 0
0x4000_0004Input port 1
0x4000_0008Output port 0
......

Compilation

# Compile MIRR to ARM assembly
cargo run --bin mirr-compile -- --emit rspu examples/flight_controller.mirr

Instruction Mapping

R-SPU InstructionARM Instruction
LOAD_INPUTldr from MMIO
STORE_OUTPUTstr to MMIO
MOVmov rd, rs
LOAD_IMMmov rd, #imm or ldr rd, =imm
ALU ADDadd rd, rs1, rs2
ALU SUBsub rd, rs1, rs2
ALU ANDand rd, rs1, rs2
ALU ORorr rd, rs1, rs2
SR_INITldr + str loop
SR_TICKShift loop
CTR_INITldr + str
CTR_TICKldr + sub + str
REFLEX_IFIT block conditional
HALTbkpt #0

IT Blocks

The ARM backend uses IT (If-Then) blocks for conditional execution:

    cmp r0, #0
    it ne
    movne r1, r2

See Also