2. Instructions: Language of the Computer > 2-2. Design principles 4 of MIPS ISA
Design principles 4 of MIPS ISA
Updated at 2022.09.20
The assembly language that has been studied so far is not a form that the processor can understand.
Therefore, we need to encode instructions and data in well-formed binary.
two's complement
Sometimes, we need to represent n-bit numbers by using more than n bits
lb/lh
loads byte/halfword from memory space and store it into 32-bit registersLike data, instructions are also encoded/represented in binary
We call the encoded instructions as machine instructions
For representing instructions, ISA defines instruction format
Issue: to represent all kinds of instructions, we might need many instrucion formants
Based on this, MIPS keeps formats as similar as possible (regularity)
For the instructions that use only Register operands
op
(opcode): basic operation of the instruction (what the instruction does)rs
: the first source register operandrt
: the second source register operandrd
: the destination register operandshamt
: shift amount (used for shift operations)funct
: function code (the specific variant of the operation)Q. why are the rs, rt, rd 5 bits?
A. registers are 32, which means 5 bits are enough to express each register
For the instructions that use Immediate operands
op
(opcode): basic operation of the instruction (what the instruction does)rs
: the first source register operandrt
: the second source register operandConstant or address
Key underlying design principles
All MIPS arithmetic instructions include a single operation & three operands
Operands of MIPS arithmetic instructions must be chosen in a small number of registers.
MIPS keeps more complex data in memory and supports data transfer between memory and registers.
Support 16-bit immediate operands for handling small constants + $zero
Keep all instructions the same length + keep instruction formats similar as possible.
Data (numbers) are also represented in binary based on two's complement rules.