CA 05 Instructions
CA 05 Instructions
RISC-V
Edition
The Hardware/Software Interface
Week 5
Instructions: Language of
the Computer (Chap. 2)
Contents
◼ Instruction formats
◼ R-format / S-format / I-format
◼ Operations
◼ Arithmetic / Logical / Conditional
◼ Operands
◼ Immediate / Register / Memory
◼ RISC-V instructions
◼ Encoded as 32-bit instruction words
◼ Small number of formats encoding operation code
(opcode), register numbers, …
◼ Regularity!
ld x9, 64(x22)
add x9, x21, x9
sd x9, 96(x22)
◼ Instruction fields
◼ opcode: operation code
◼ rd: destination register number
◼ funct3: 3-bit function code (additional opcode)
◼ rs1: the first source register number
◼ rs2: the second source register number
◼ funct7: 7-bit function code (additional opcode)
add x9,x20,x21
0 21 20 0 9 51
imm[12] imm[11]
◼ PC-relative addressing
◼ Target address = PC + immediate × 2