This section will translate the following sub instruction to machine code.
sub $s0, $s1, $s2
The MIPS Greensheet specifies the
sub instruction as an R-format instruction and the op- code/function for the
sub as 0/22. This means the 6 bits for the op code are 000000 and the 6 bits for the function are 100010.
Register Rd is
$s0 is also register
Register Rs is
$s1 is also register
Register Rt is
$s2 is also register
The shamt is
00000 as there are no bits being shifted.
The result is the following R-format instruction.
To write this instruction's machine code, the bits are organized in groups of 4, and hex values given. This results in the number 0000 0010 0011 0010 1000 0000 0010 00102 or 0x02328022.