ands

Bitwise AND and Set Flags (Shifted Register 64-bit)

ANDS <Xd>, <Xn>, <Xm> {, <shift> #<amount>}

Bitwise AND shifted register, updates flags (64-bit).

Details

Performs a bitwise AND between Xn and a shifted Xm, storing the result in Xd and updating the condition flags. Sets the Z flag if the result is zero, the N flag based on bit 63 of the result, and clears the C and V flags.

Pseudocode Operation

result ← Xn AND (Xm shifted by shift_amount)
Xd ← result
N ← result[63]
Z ← (result == 0)
C ← 0
V ← 0

Example

ANDS x0, x1, x2

Encoding

Binary Layout
1
11
01010
shift
0
Rm
imm6
Rn
Rd
 
Format Logical (Register)
Opcode 0xEA000000
Extension Base

Operands

  • Xd
    Destination 64-bit integer register
  • Xn
    First source / base 64-bit integer register
  • Xm
    Second source / offset 64-bit integer register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x72000000 ANDS <Wd>, <Wn>, #<imm> A64 0 | 11 | 100100 | 0 | immr | imms | Rn | Rd
0xF2000000 ANDS <Xd>, <Xn>, #<imm> A64 1 | 11 | 100100 | N | immr | imms | Rn | Rd
0x6A000000 ANDS <Wd>, <Wn>, <Wm>{, <shift> #<amount>} A64 0 | 11 | 01010 | shift | 0 | Rm | imm6 | Rn | Rd
0xEA000000 ANDS <Xd>, <Xn>, <Xm>{, <shift> #<amount>} A64 1 | 11 | 01010 | shift | 0 | Rm | imm6 | Rn | Rd
0x25404000 ANDS <Pd>.B, <Pg>/Z, <Pn>.B, <Pm>.B A64 00100101 | 0 | 1 | 00 | Pm | 01 | Pg | 0 | Pn | 0 | Pd

Description

Bitwise AND (shifted register), setting flags, performs a bitwise AND of a register value and an optionally-shifted register value, and writes the result to the destination register. It updates the condition flags based on the result.

Operation

bits(datasize) operand1 = X[n, datasize];
bits(datasize) operand2 = ShiftReg(m, shift_type, shift_amount, datasize);
bits(datasize) result;


result = operand1 AND operand2;
PSTATE.<N,Z,C,V> = result<datasize-1>:IsZeroBit(result):'00';

X[d, datasize] = result;