rd, rs1, rs2rd = rs1 + rs2Addition is the first thing most people want a processor to do, and add is how RISC-V does it. But before the instruction makes sense, you need one idea: a register. A register is a tiny storage slot built directly into the processor that holds a single number. RISC-V has 32 of them, each storing a 32-bit value — a bit is one 0 or 1, and 32 bits together can hold whole numbers from 0 up to about four billion. Almost all arithmetic happens between registers, never directly on memory.
add reads two registers, adds their contents, and writes the total into a third. In assembly we name the destination first: the form add rd, rs1, rs2 means rd = rs1 + rs2. Here rd is the destination register (where the answer goes) and rs1 and rs2 are the two source registers it reads. The sources are left unchanged, and nothing stops the destination from also being a source: add t0, t0, t1 means take t0, add t1, and store the result back in t0 — the everyday way a running total grows inside a loop.
One surprise waits for very large numbers. Because a register holds only 32 bits, there is a ceiling of about four billion. If a sum climbs past it, the processor does not complain; the value silently wraps around to a small number, the way a car odometer rolls from 999999 back to 000000. This is called overflow, and RISC-V deliberately ignores it — there is no warning flag and no crash. You will not meet this with everyday values, but it is worth knowing the ceiling exists.
In the example, li (load immediate, which simply drops a constant into a register) puts 3 and 4 into t0 and t1, and add t2, t0, t1 leaves 7 in t2. A small trick worth remembering: to double a number, just add it to itself — add t0, t1, t1.
li t0, 3 li t1, 4 add t2, t0, t1 # t2 = 7