Does SB store the whole register?
SB stores only the low 8 bits of rs2, not necessarily the full XLEN-wide register.
Store the low 8 bits of rs2 to memory
SB uses opcode 0100011 (0x23), funct3 000. The rs1 field holds the base address, rs2 holds the store data, and the 12-bit immediate split across imm[11:5] and imm[4:0] provides the offset.
SB (S-type, opcode=0100011, funct3=000) stores the low 8 bits of rs2 to the effective address (rs1 + sign-extended 12-bit offset). The S-type immediate is split: upper 7 bits at inst[11:5], lower 5 bits at inst[4:0]. Misaligned access behavior is EEI-defined.
SB forms the effective address as rs1 plus a signed 12-bit offset and stores the low 8 bits of rs2 to memory.
Understand this scenario with real code like «sb x5, 0(x10) # mem[x10+0][7:0] = x5[7:0]».
Understand this scenario with real code like «sb x5, 0(x10) # mem[x10+0][7:0] = x5[7:0]».
Understand this scenario with real code like «sb x5, 0(x10) # mem[x10+0][7:0] = x5[7:0]».
SB stores only the low 8 bits of rs2, not necessarily the full XLEN-wide register.
The effective address is the base register rs1 plus a sign-extended 12-bit byte offset.