In: Computer Science
Encode the following instruction
opcode: 100011
(1) identify the instruction format that will be used
(2) indicate the values of each of the fields for that format in decimal
(3) convert each of these decimal values to binary
(4) represent the entire instruction as one hexadecimal value.
subu $t3,$v1,$s2
There are three instruction categories: R-format, I-format, and J-format.
Given,
# opcode: 100011
# Instruction: subu $t3,$v1,$s2
** First we talk about the opcode: 100011
(1)=> Here is the given opcode= 100011, according to this opcode the instruction format come in " I-format instruction" where the instruction format contains:
According to the given opcode the following instruction is:
Example:
lw $t0, 32($s3)
where, $t0, $s3 are registers and 32 is immediate.
(2)=> Here is the instruction format with decimal values:
Opcode | rs | rt | immediate |
35 | 19 | 8 | 32 (offset) |
(3)=> Here is the instruction format with binary values:
Opcode | rs | rt | immediate |
100011 | 10011 | 01000 | 0000000000100000 |
(4)=> Here is the entire instruction as one hexadecimal value:
Binary: 1000 1110 0110 1000 0000 0000 0010 0000
Hexa: 8 E 6 8 0 0 2 0
So, the Hexa value:
0x8E680020
** Lets we talk about the instruction format: subu $t3,$v1,$s2
(1)=> Here is the given Instruction: subu $t3,$v1,$s2, according to this instruction, the instruction format come in " R-format instruction" where the instruction format contains:
(2)=> Here is the instruction format with decimal values:
Opcode | rs | rt | rd | shamt | funct |
0 | 2 | 1 | 3 | 0 | 35 |
(3)=> Here is the instruction format with binary values:
Opcode | rs | rt | rd | shamt | funct |
000000 | 00010 | 00001 | 00011 | 00000 | 100011 |
(4)=> Here is the entire instruction as one hexadecimal value:
Binary: 0000 0000 0100 0001 0001 1000 0010 0011
Hexa: 0 0 4 1 1 8 2 3
So, the Hexa value:
0x00411823