Coal W3-4
Coal W3-4
Coal W3-4
Instructions as Numbers
In a computer, instructions are represented as electronic signals, which can be
interpreted as binary numbers. The components of each instruction (like the
operation type, registers involved, etc.) are represented as distinct numbers. Putting
these parts together as a single series of numbers makes up the complete instruction,
ready for the computer to process.
Mapping Registers to Numbers
In MIPS, registers (which are like small storage locations inside the CPU)
have names for easier reference in assembly code, such as $s0, $t0, etc.
However, each register name has an associated number that the machine
understands:
The $s registers are for "saved" values and map to numbers 16 to 23. For instance:
● $s0 is register 16.
● $s1 is register 17.
● This pattern continues up to $s7, which is register 23.
The $t registers are for "temporary" values and map to numbers 8 to 15:
● $t0 is register 8.
● $t1 is register 9, and so on, until $t7, which is register 15.
Why This Mapping is Important
• This numbering system allows MIPS instructions to directly refer to
registers by number, which makes encoding the instructions into binary
numbers (machine code) straightforward.
Decimal Representation?
Example: Translating a MIPS Assembly
Instruction into a Machine Instruction
add $t0,$s1,$s2 MIPS assembly instruction.
Decimal Representation:
Example: Translating a MIPS Assembly
Instruction into a Machine Instruction
add $t0,$s1,$s2 MIPS assembly instruction.
Decimal Representation:
Binary Representation: