subp

Subtract Pointers

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

Subtracts pointers ignoring Tags.

Details

Subtracts the pointer in Xm from the pointer in Xn, removing any Allocation Tags from both operands before performing the subtraction. The result is stored in Xd. This instruction does not modify the condition flags and operates only in AArch64 execution state with MTE support.

Pseudocode Operation

Xd ← (Xn | SP)[55:0] - (Xm | SP)[55:0]

Example

SUBP x0, x1, x2

Encoding

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

Operands

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

Reference (Arm A64 ISA)

Instruction Forms

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

Description

Subtract Pointer 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.

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;

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

X[d, 64] = result;