rd, rs1, immrd = rs1 & immandi is the bitwise AND, but with a constant. The plain and instruction ANDs two registers together; andi ANDs a register against an immediate — a fixed value written straight into the instruction (the suffix i means immediate). The AND rule itself is unchanged: at each bit position the result is 1 only when both bits are 1, so the constant acts as a mask that keeps some bits and clears the rest. If masking or bitwise operations are unfamiliar, the and page walks through them.
The form is andi rd, rs1, imm: AND the value in rs1 against the constant imm and store the result in rd. Because the mask is built into the instruction, this is the natural choice whenever the bits you want to keep are known in advance. andi t1, t0, 0xff (the 0x prefix marks a hexadecimal constant) keeps the lowest 8 bits of t0 and zeroes the upper 24 — the standard way to pull one byte out of a larger value.
The constant is limited: it must fit in 12 bits, so it cannot directly express a wide mask. For masks larger than that, load the full mask into a register with li and use the register form and.
Two handy patterns: andi t1, t0, 1 keeps only the lowest bit, which is 1 for odd numbers and 0 for even — a reliable odd/even test. andi t1, t0, 7 gives the remainder when dividing by 8, since an unsigned remainder by a power of two is just the low bits.
andi t1, t0, 0xff # keep only the low byte