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 |
| sf | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | Rm | option_name | imm3 | Rn | Rd | ||||||||||||||||
| op | S | ||||||||||||||||||||||||||||||
x0101011001xxxxxxxxxxxxxxxxxxxxx
let 'd = UInt(Rd);
let 'n = UInt(Rn);
let 'm = UInt(Rm);
let 'datasize = if sf == 0b1 then 64 else 32;
let sub_op : bool = op == 0b1;
let setflags : bool = S == 0b1;
let extend_type : ExtendType = DecodeRegExtend(option_name);
let 'shift = UInt(imm3);
if shift > 4 then {
throw(Error_Undefined())
};
execute_aarch64_instrs_integer_arithmetic_add_sub_extendedreg(d, datasize, extend_type, m, n, setflags, shift, sub_op)
result : bits('datasize) = undefined;
let operand1 : bits('datasize) = if n == 31 then
SP_read()[datasize - 1 .. 0]
else
X_read(n, datasize);
operand2 : bits('datasize) = ExtendReg(m, extend_type, shift, datasize);
nzcv : bits(4) = undefined;
carry_in : bits(1) = undefined;
if sub_op then {
operand2 = not_vec(operand2);
carry_in = 0b1
} else {
carry_in = 0b0
};
(result, nzcv) = AddWithCarry(operand1, operand2, carry_in);
if setflags then {
(PSTATE.N @ PSTATE.Z @ PSTATE.C @ PSTATE.V) = nzcv
};
if d == 31 & not_bool(setflags) then {
SP_set() = ZeroExtend(result, 64)
} else {
X_set(d, datasize) = result
}
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.