CMP (immediate)

A32: data processing and miscellaneous instructions / T32: 16-bit instructions

fixed bit field field the encoding fixes should be

A1

313029282726252423222120191817161514131211109876543210
cond00110101Rn0000imm12

xxxx00110101xxxx0000xxxxxxxxxxxx
cond != 1111

Decode Sail

if ConditionPassed() then {
    assert(cond != 0b1111);
    let 'n = UInt(Rn);
    let imm32 : bits(32) = A32ExpandImm(imm12);
    execute_aarch32_instrs_CMP_i_Op_A_txt(imm32, n)
};
()

T1

1514131211109876543210
00101Rnimm8

00101xxxxxxxxxxx

Decode Sail

if ConditionPassed() then {
    let 'n = UInt(Rn);
    let imm32 : bits(32) = ZeroExtend(imm8, 32);
    execute_aarch32_instrs_CMP_i_Op_A_txt(imm32, n)
};
()

Operation Sail

nzcv : bits(4) = undefined;
result : bits(32) = undefined;
(result, nzcv) = AddWithCarry(R_read(n), not_vec(imm32), 0b1);
(PSTATE.N @ PSTATE.Z @ PSTATE.C @ PSTATE.V) = nzcv

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.