LDR (immediate)

T32: 16-bit instructions

fixed bit field field the encoding fixes should be

T1

1514131211109876543210
01101imm5RnRt

01101xxxxxxxxxxx

Decode Sail

if ConditionPassed() then {
    let 't = UInt(Rt);
    let 'n = UInt(Rn);
    let imm32 : bits(32) = ZeroExtend(imm5 @ 0b00, 32);
    let index : bool = true;
    let add : bool = true;
    let wback : bool = false;
    execute_aarch32_instrs_LDR_i_OpT_A_txt(add, imm32, index, n, t, wback)
};
()

T2

1514131211109876543210
10011Rtimm8

10011xxxxxxxxxxx

Decode Sail

if ConditionPassed() then {
    let 't = UInt(Rt);
    let 'n = 13;
    let imm32 : bits(32) = ZeroExtend(imm8 @ 0b00, 32);
    let index : bool = true;
    let add : bool = true;
    let wback : bool = false;
    execute_aarch32_instrs_LDR_i_OpT_A_txt(add, imm32, index, n, t, wback)
};
()

Operation Sail

let offset_addr : bits(32) = if add then R_read(n) + imm32 else
  R_read(n) - imm32;
let address : bits(32) = if index then offset_addr else R_read(n);
if not_bool(wback) & t != 15 then {
    AArch32_SetLSInstructionSyndrome(4, false, t, false)
};
let data : bits(32) = MemU_read(address, 4);
if wback then {
    R_set(n) = offset_addr
};
if t == 15 then {
    if address[1 .. 0] == 0b00 then {
        LoadWritePC(data)
    } else {
        throw(Error_Unpredictable())
    }
} else {
    R_set(t) = data
}

Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.