Subtract immediate value, setting flags
This instruction subtracts an optionally-shifted immediate value from a register value, and writes the result to the destination register. It updates the condition flags based on the result.
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 |
1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | ||||||||||||||||||||||||
sf | op | S | sh | imm12 | Rn | Rd |
---|
SUBS <Wd>, <Wn|WSP>, #<imm>{, <shift>}
SUBS <Xd>, <Xn|SP>, #<imm>{, <shift>}
constant integer d = UInt(Rd); constant integer n = UInt(Rn); constant integer datasize = 32 << UInt(sf); constant bits(24) imm = if sh == '0' then Zeros(12):imm12 else imm12:Zeros(12);
constant bits(datasize) operand1 = if n == 31 then SP[datasize] else X[n, datasize]; constant bits(datasize) operand2 = ZeroExtend(imm, datasize); bits(datasize) result; bits(4) nzcv; (result, nzcv) = AddWithCarry(operand1, NOT(operand2), '1'); X[d, datasize] = result; PSTATE.= nzcv;
If PSTATE.DIT is 1: