Let the CPU run the program (ii)

Source: Internet
Author: User

Simple Assembly Instruction Design

A computer instruction written in a text symbol is an assembly instruction. What format does this assembly instruction follow in order to correspond to the machine instruction one by one we are designing? As a CPU designer in the design of the command system, it is necessary to consider this aspect of the problem. Consider the format of the machine instruction, and then consider how the assembly instruction corresponds to it.

    1. How to design machine instruction format?

Instruction format is the basis of instruction analysis execution, instructions written in accordance with a certain instruction format, to be able to let the CPU analysis of which instruction, this instruction to do what action, and how to move. In order to be able to analyze the execution instructions, the general CPU has to set up a directive register, this register to put the instructions taken from the program memory, through the pre-designed instruction format to decompose the instructions, the different codes sent to the control matrix. The control matrix methodically directs the CPU action through the information sent by the beat, the flag line, and the instruction register.

Since the machine can only represent a certain length of binary number, the computer CPU instruction format can only be in the fixed-length binary number of the fuss. A basic idea is to have a certain number of binary numbers represent the instruction name, leaving the other part to represent the operand. So the simplest form of machine instruction is: The instruction name Operation object.

Inside the machine, instructions can only exist in the form of a binary encoding, so the instruction name is an encoding. The instruction code is also called the opcode. The object of the instruction operation is also a binary number, so it is called the operand. The directive name is unique, so it's easier to use binary numbers. But the operation of the object is relatively complex, there are values, memory address, there are registers and so on. Fortunately, the instructions we have here are too many to work with and it's not difficult to plan. Figure 3-4 shows the 16-bit binary instruction format we've planned, and we've designed both of these instruction formats to represent all of the previous design instructions.

The above instruction format can define access memory class directives, such as program structure transfer class instruction, arithmetic operation class instruction and logical operation instruction. The following instruction format is a type of instruction format for data transfer or operation, which can feed 8-bit numbers into a numbered register, or allow data to be passed between numbered registers, and can perform various operations between numbered registers. If a lot of registers in the CPU, often take the encoding is the form, so distinguish these registers to use the method of encoding. The use of these registers is generally coded to indicate that the register needs to be encoded in the instruction Operation object. If the number of registers is very small, usually marked with a special name, such as accumulator DA, instruction register IR, address register mar, output register out, front-end registers A and B, etc., they are implicit registers in the instruction encoding, do not need to be in the instruction operator object. The form of register encoding occurs when the CPU uses multiple universal registers. For example, the CPU of a thin instruction system will have multiple general-purpose registers.

    1. Design your own assembly instructions

Based on the previous functions and formats of the CPU instruction system, we will design the assembly instructions and machine instructions in table 3-1. The machine instruction just gives the operation code, does not generalize the Operation object, but the assembly instruction can use the symbol to replace the operation code and the Operation object.

  

Let the CPU run the program (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.