##ands_log_imm_execute
bits(datasize) result;
bits(datasize) operand1 = X[n];
bits(datasize) operand2 = imm;

case op of
    when LogicalOp_AND result = operand1 AND operand2;
    end
    when LogicalOp_ORR result = operand1 OR  operand2;
    end
    when LogicalOp_EOR result = operand1 EOR operand2;
    end

if setflags then
    PSTATE.<N,Z,C,V> = result<datasize-1>:IsZeroBit(result):00;
end

if d == 31 && !setflags then
    SP[] = result;
else
    X[d] = result;
end
@@
