c.andi

And immediate

This instruction is defined by:

  • anyOf:

    • C, version >= 0

    • Zca, version >= 0

This instruction is included in the following profiles:

Encoding

svg

Assembly format

c.andi rd, imm

Synopsis

And an immediate to the value in rd, and store the result in rd. The rd register index should be used as rd+8 (registers x8-x15). C.ANDI expands into andi rd, rd, imm.

Access

M HS U VS VU

Always

Always

Always

Always

Always

Decode Variables

Bits<6> imm = {$encoding[12], $encoding[6:2]};
Bits<3> rd = $encoding[9:7];

Execution

  • IDL

  • Sail

X[rd + 8] = X[rd + 8] & imm;
{
  let rd_val = X(rd+8);
  let immext : xlenbits = sign_extend(imm);
  let result : xlenbits = match op {
    RISCV_ADDI  => rd_val + immext,
    RISCV_SLTI  => zero_extend(bool_to_bits(rd_val <_s immext)),
    RISCV_SLTIU => zero_extend(bool_to_bits(rd_val <_u immext)),
    RISCV_ANDI  => rd_val & immext,
    RISCV_ORI   => rd_val | immext,
    RISCV_XORI  => rd_val ^ immext
  };
  X(rd+8) = result;
  RETIRE_SUCCESS
}