rd, rs1, rs2rd = rs1 ^ rs2xor is the third bitwise instruction, working bit by bit across a register's 32 positions like and and or (see the and page if bitwise is a new idea). Its name is short for exclusive OR, and its rule is the difference detector: at each position the result is 1 only when the two input bits are *different* — one 0 and one 1. If they match, the result is 0. xor rd, rs1, rs2 does this for rs1 and rs2 and writes the result to rd.
Two consequences make XOR surprisingly useful. First, anything XORed with itself is 0, because every bit matches itself — which is why xor t0, t0, t0 is a quick way to set a register to zero. Second, XOR against a mask *flips* exactly the masked bits (a 1 in the mask inverts that bit, a 0 leaves it alone), and flipping twice returns the original — a reversibility that underlies simple encryption and error checks.
XOR is also a fast equality test: after xor t2, t0, t1, t2 is exactly zero when the two inputs were identical, and non-zero otherwise — ready to feed a branch.
The example, xor t0, t0, t0, clears t0 to 0 no matter what it held before. It sits alongside the equally valid li t0, 0 (load the constant zero) as a way to empty a register.
xor t0, t0, t0 # t0 = 0