Which instructions are used in MIPS

MIPS adheres to the number of instructions and the design concept of the instruction function. How is such a design concept achieved? In this section we analyze the characteristics of the MIPS policy in the future.

The MIPS policy can be understood through the use of these two sheets of paper compared to the policy statements provided by the X86 statement.

The basic format of the MIPS policy is broken down into these three: R-Type, Type I, and J.

R-type refers to a type of register;

The I-type refers to the immediate number;

The J-type refers to the transfer type.

We use this table to classify the instructions of MiPs, and the horizontal axis is divided into R-Type, Type I, and J, and the vertical axis is divided into operating instructions, and divided according to the functional type of the instruction.

First, look at the instruction format, the operating instruction is R-type.

The R-type policy contains six domains. The highest opcode domain is six bits, the lowest bit funct field is also six bits, and the four domains in the middle are five bits. We consider the use of each domain:

OPCODE domain for specifying the type of instructions. For all R-type statements, the value of this domain is zero. However, this is not to be explained by the fact that the R-Type policy is only one, but must also be specified in more detail by the FUNKT domain. For R-type instructions, there are actually 12 bits in total. That everyone can think about why the opcode domain and the FUNKT domain are not merged into a 12-bit domain? Isn't it straight anymore?

Let's take another 5-bit domain. RS domain, this domain is normally used to indicate register numbers in which the first source operand is located. The RT domain is typically used to indicate the number of registers in which the second source operand is located; The RD domain is typically used to indicate the number of target operas. The register number, which is the location where the operation is stored.

The 5 bits of the domain can represent the number from 0-31 only in the 32 general registers in the MIPS architecture.

There is also the last domain shamt, which indicates the number of digits in the switching process. Since the number of 32 bits the 5-bit domain can represent the number of switching bits from 0-31. The domain is only useful for relocation instruction, and this domain is set to 0 for non-shift instructions.

Let us assume an example, this is the number of numbers in registers and No. 10 that the calculation results are stored in register No. 8. Then we get the binary coding of MIPS instructions through these assembled instructions. It's actually very simple. First, we ask the MIPS instruction coding table, you can get the opcode domain of the addition instructions, should be 0 (decimal number), and the FUNCT domain should be 32. Since it is not a switching instruction, the Shamt domain has been moved to 0. Then we can get the number of operands according to this instruction, and then Rd is 8, the first source operand should be 9, the second source operand should be 10. In this way we convert the value of each domain to a binary number, fill in the corresponding position, you can get the binary encoding of this instruction.

The rule of the MIPS instruction system makes us very easy to create such manual coded conversions in the instructions and also explains the decoding of the hardware of the CPU for such instructions. It's very convenient.

If you need to use the immediate number in the instruction, you should use the I-type instructions.

Since there is only a 5-bit domain between the R-type instructions i.e. the Shamt shift, this domain can be used to represent an instant number and the number of numbers can be anywhere from 0-31. The immediate number of frequencies used in the program is much larger than this assortment, so the R-type guideline does not apply and we need a new instruction format. This is the I-type instruction, and most of the domains of the I-type instructions are the same as the R-type instructions.

The first domain of the I-Type policy is also an opcode domain to indicate the type of instructions. However, it has no function, so different I-Type instructions differ from their opcode domain.

The second domain RS indicates the register number in which the first source operand is located;

The third domain RT is used to indicate the number of target operas.

The I-Type policy is different from the R-Type instruction, which contains only two digital register domains.

The remaining 16 bits are integrated into a complete domain and can store the immediate number of 16 bits, which can represent two sixteen parties. For general tour guidance we need to use a register to add an instant number to indicate a storage unit. This number is then the offset of the access address, the immediate number of 16 bits, can refer to the positive and negative 32k (216−1 = 32K216−1 = 32K The assortment of bytes, what if we want to jump to another address, what should i do? There is a very simple method to call the J instruction twice. The first J instruction will jump to the furthest possible and put a J directive in that destination address and jump once like the relay Method is simple, but it's not too convenient to use. So what can I use? Do you remember we have indirect transfer instructions? The same method can also be used in MIPS which is JR instruction. The JR instruction has a register operand that is used to transfer the destination address to the register so that the 32-bit destination address can be used, but such instructions can be clearly implemented with J-type instructions, so need new instruction en? In fact, we don't need it. We can use the original R-type instructions. Just use one of the registers it takes up and then add some funct coding.