Lecture 4
Lecture 4
Edition
The Hardware/Software Interface
Chapter 2
Instructions: Language
of the Computer
◼ LEGv8 instructions
◼ Encoded as 32-bit instruction words
◼ Small number of formats encoding operation code
(opcode), register numbers, …
◼ Regularity!
◼ Instruction fields
◼ opcode: operation code
◼ Rm: the second register source operand
◼ shamt: shift amount (00000 for now) used in
shift instructions
◼ Rn: the first register source operand
◼ Rd: the register destination
ADD X9,X20,X21
Decimal
1112ten 21ten 0ten 20ten 9ten Representation
10001011000two 10101two 000000two 10100two 01001two Machine
Language
1000 1011 0001 0101 0000 0010 1000 1001two =
8B15028916
◼ Load/store instructions
◼ Can not use R-Type instruction format as the 5-bit field is too
small to be used for the address as the largest constant would
be 31
◼ Rn: base register
◼ address: constant offset from contents of the base register (+/-
32 doublewords)
◼ Rt: destination (load) or source (store) register number
◼ Design Principle 3: Good design demands good
compromises
◼ Different formats complicate decoding but allow 32-bit
instructions uniformly
◼ Keep formats as similar as possible
Chapter 2 — Instructions: Language of the Computer — 6
LEGv8 I-format Instructions
I-Type
opcode immediate Rn Rd Instruction
10 bits 12 bits 5 bits 5 bits Format
◼ Immediate instructions
◼ Rn: source register
◼ Rd: destination register
let’s first represent the machine language instructions using decimal numbers.