The S-type (store) instruction operates on two registers and one immediate operand. There are two immediate fields that together form a 12-bit signed immediate value. Figure 1 illustrates the instruction format for an S-type instruction, showing how the register, opcode, and immediate fields are segregated.
Figure 1: Instruction Format
- Opcode: The opcode or operation code is a 7-bit field that defines the type of operation to be performed.
- Function Field: This 3-bit
funct3
field, known as the control bits, determines the specific operation to be executed such as store byte (sb
), store half (sh
) and store word (sw
). - Registers: The register
rs1
is the base address of source register andrs2
is the value to be stored to memory. - Immeditate Field: The two immediate fields together make up 12-bit signed offset number for the base address in
rs1
.
Below is table that describes the list of S-type instructions.
funct3 | opcode | Description | Instruction |
---|---|---|---|
000 | 0100011 (35) | store byte | sb rs2, imm(rs1) |
001 | 0100011 (35) | store half | sh rs2, imm(rs1) |
010 | 0100011 (35) | store word | sw rs2, imm(rs1) |