subps

Subtract Pointers, Setting Flags

SUBPS <Xd>, <Xn|SP>, <Xm|SP>

Subtracts pointers (ignoring tags) and sets condition flags.

Details

Subtracts the second source pointer from the first, ignoring memory tag bits in both operands, and updates the N, Z, C, and V condition flags based on the 64-bit result. The tagged address bits are excluded from the arithmetic so the comparison reflects only the pointer value. Available when the Memory Tagging Extension (MTE) is implemented.

Pseudocode Operation

Xd ← Xn - Xm
// Flags affected: N, Z, C, V

Example

SUBPS x0, x1, x2

Encoding

Binary Layout
1
0
1
11010110
Xm
000000
Xn
Xd
 
Format Data Processing
Opcode 0xBAC00000
Extension MTE (Memory Tagging)

Operands

  • Xd
    Destination 64-bit integer register
  • Xn
    Addr 1
  • Xm
    Addr 2

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0xBAC00000 SUBPS <Xd>, <Xn|SP>, <Xm|SP> A64 1 | 0 | 1 | 11010110 | Xm | 000000 | Xn | Xd

Description

Subtract Pointer, setting Flags subtracts the 56-bit address held in the second source register from the 56-bit address held in the first source register, sign-extends the result to 64-bits, and writes the result to the destination register. It updates the condition flags based on the result of the subtraction.

Operation

bits(64) operand1 = if n == 31 then SP[] else X[n, 64];
bits(64) operand2 = if m == 31 then SP[] else X[m, 64];
operand1 = SignExtend(operand1<55:0>, 64);
operand2 = SignExtend(operand2<55:0>, 64);

bits(64) result;
bits(4) nzcv;

operand2 = NOT(operand2);
(result, nzcv) = AddWithCarry(operand1, operand2, '1');

PSTATE.<N,Z,C,V> = nzcv;
X[d, 64] = result;