A32: data processing and miscellaneous instructions / T32: 16-bit instructions
fixed bit field field the encoding fixes should be
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| cond | 0 | 0 | 0 | 0 | 1 | 0 | 0 | S | Rn | Rd | imm5 | stype | 0 | Rm | |||||||||||||||||
xxxx0000100xxxxxxxxxxxxxxxx0xxxx
cond != 1111
if ConditionPassed() then {
assert(cond != 0b1111);
shift_n : int = undefined;
shift_t : SRType = undefined;
if Rn == 0b1101 then {
throw(Error_See("ADD (SP plus register)"))
};
let 'd = UInt(Rd);
let 'n = UInt(Rn);
let 'm = UInt(Rm);
let setflags : bool = S == 0b1;
(shift_t, shift_n) = DecodeImmShift(stype, imm5);
let 'shift_n = shift_n;
execute_aarch32_instrs_ADD_r_Op_A_txt(d, m, n, setflags, shift_n, shift_t)
};
()
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | Rm | Rn | Rd | ||||||
0001100xxxxxxxxx
if ConditionPassed() then {
shift_n : int = undefined;
shift_t : SRType = undefined;
let 'd = UInt(Rd);
let 'n = UInt(Rn);
let 'm = UInt(Rm);
let setflags : bool = not_bool(InITBlock());
(shift_t, shift_n) = (SRType_LSL, 0);
let 'shift_n = shift_n;
execute_aarch32_instrs_ADD_r_Op_A_txt(d, m, n, setflags, shift_n, shift_t)
};
()
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | DN | Rm | Rdn | |||||
01000100xxxxxxxx
if ConditionPassed() then {
shift_n : int = undefined;
shift_t : SRType = undefined;
if (DN @ Rdn) == 0b1101 | Rm == 0b1101 then {
throw(Error_See("ADD (SP plus register)"))
};
let 'd = UInt(DN @ Rdn);
let 'n = d;
let 'm = UInt(Rm);
let setflags : bool = false;
(shift_t, shift_n) = (SRType_LSL, 0);
let 'shift_n = shift_n;
if n == 15 & m == 15 then {
throw(Error_Unpredictable())
};
if (d == 15 & InITBlock()) & not_bool(LastInITBlock()) then {
throw(Error_Unpredictable())
};
execute_aarch32_instrs_ADD_r_Op_A_txt(d, m, n, setflags, shift_n, shift_t)
};
()
nzcv : bits(4) = undefined;
result : bits(32) = undefined;
let shifted : bits(32) = Shift(R_read(m), shift_t, shift_n, PSTATE.C);
(result, nzcv) = AddWithCarry(R_read(n), shifted, 0b0);
if d == 15 then {
if setflags then {
ALUExceptionReturn(result)
} else {
ALUWritePC(result)
}
} else {
R_set(d) = result;
if setflags then {
(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.