rd, rs1, immrd = rs1 ^ immxori is bitwise XOR with a constant, completing the set of immediate logic instructions alongside andi and ori. The i suffix means immediate — a fixed value written into the instruction rather than read from a second register. The XOR rule is the difference detector: at each bit position the result is 1 when the two bits differ (see the xor page). Against a constant mask, that rule becomes a toggle: every 1 in the mask flips the matching bit, every 0 leaves it alone.
The form is xori rd, rs1, imm: XOR the value in rs1 against the constant imm and write the result to rd. So where andi clears chosen bits and ori sets them, xori inverts them — and inverting twice returns the original.
Its most important use builds another instruction entirely. Flipping *every* bit of a value is just XOR against a mask of all 1s, and that is exactly what the not instruction does — it is shorthand for xori rd, rs, -1, since -1 in bits is all 1s. RISC-V has no separate invert-everything instruction because this one covers it.
A common small use is toggling a yes/no value stored as 0 or 1: xori t0, t0, 1 flips it to the other state each time. The constant is limited to 12 bits; for wider patterns, load the mask into a register and use the register form xor.