What is the opcode and the rs fields encoded in the following instruction:
30620001
Answer :
All instructions in the MIPS R2000 Architecture are 32 bits in length. There are three different instruction formats: R-Type instructions, I-Type instructions, and J-Type instructions.
R-Type instructions, or Register instructions are used for register based ALU operations. The two operands and the destination of the result are specified by locations in the register file.
I-Type instructions, or Immediate instructions, can be either Load/Store operations, Branch operations, or Immediate ALU operations. In these instructions, one two register file locations are specified as well as a 16-bit immediate value which may be used as an operand or an address.
The rs and rt register addresses, which are present in both R- and I-type instructions, specify the two addresses which the register file is to read. In R-Type instructions the destination (write) register for the register file is specifies by rd and in I-Type instructions the destination register is specified by rt (the second read from the register file is ignored).
An R-Type instruction contains 6 fields: a 6 bit function code (funct), a 5 bit shift amount (shamt), three 5 bit register addresses (rd, rt, rs), and a 6 bit operation code (opcode) which is always zero.
An I-Type instruction contains 4 fields: a 16 bit immediate field (immed. or address), two 5 bit register addresses (rt, rs) and a 6 bit operation code (opcode).
R-Type Instruction Format:
31-26 | 25-21 | 20-16 | 15-11 | 10-6 | 5-0 |
opcode (000000) | rs | rt | rd | shamt | funct |
rs = operand A location in register file; rt = operand B location in register file; rd = result destination location in register file; shamt = shift amount; funct = function code
I-Type Instruction Format (ALU immediate):
31-26 | 25-21 | 20-16 | 15-0 |
opcode | rs | rt | immed. |
rs = operand A location in register file; rt = result destination location in register file; immed. = operand B location in register file
Now the binary notation of the given instruction 30620001 is :
0011 0000 0110 0010 0000 0000 0000 0001
MSB LSB
In both the type of instruction bits 31 to 26 are opcode and bits 25 to 21 is for rs , so the opcode and rs for this instruction will be :
Opcode : 001100
rs : 00011
Get Answers For Free
Most questions answered within 1 hours.