"copyright notice: respect for the original, reproduced please retain the source: blog.csdn.net/shallnet, the article only for learning Exchange, do not use for commercial purposes"
The modern computer computation process is usually the high-level language program which the user writes and feeds into the computer, translates the machine to recognize the language program, and then the machine automatically runs the language program to calculate the result and output. but in the early days when there was no high-level language, the user was writing machine language directly in the machine execution. To write this binary code consisting of only 0, 1, the requirements of the programmer is not very high, need to be familiar with the computer hardware and instruction system, so it is difficult to write programs, and the operation process is complex and error-prone. In the the 1950s there appeared a symbolic programming language, that is, assembly languages, assembly language no longer use the complex error-prone binary 0, one to write programs, but instead use such as Add, SUB, MUL, Div, etc. to represent the operation of subtraction, and the instruction or storage address is also represented by a symbol. The use of assembly language to run on the machine or need to translate it into machine language, machine can only recognize machine language, except machine language is not recognized, the assembly language translated into machine language is the machine system software program to complete. Although assembly language makes it easy for users to program, programming with assembly language still requires that the program ape is familiar with the machine's instruction system, and each machine is an assembly language corresponding to different kinds of machine assembly language, so that programmers need to master the different machine instruction system, It is not easy to use the computer extensively. in the 60 's after the emergence of high-level language, high-level language with high versatility, programmers only need to master the high-level language syntax can be programmed, do not need to master the type of machine, composition or instruction system. The computer still does not recognize the high-level language directly, the high-level language program needs to be converted into assembly language before it is run, and the assembly language is converted into machine languages before the machine can recognize and run the program.
Computer ArchitectureA computer has an architecture that determines the interface between the computer hardware and software, focusing on the operation and memory access within the central processing unit. Taking the design of the common von Neumann computer as an example, the architecture design includes:
The instruction set schema (instruction set architecture; ISA) is considered a machine language that contains a number of related instruction sets (memory addressing, processor control, scratchpad control, and so on ...). micro-architecture/microarchitecture (microarchitecture) or computer organization (computer organization): is a more detailed description of how the internal elements of the system cooperate and communicate. data representation, i.e. data types and data formats that can be directly identified and processed by the hardware; addressing methods, including minimum addressing units and address arithmetic; a register definition, including the definition, number and usage of the operand register, the variable address register, the control register, etc. The instruction system includes the operation type and format of the machine instruction, the ordering and control mechanism among the instructions, etc. anomaly mechanisms, including interrupts, NMI, and internal anomalies; the definition and switching of the working state of the machine, such as the pipe state and the configuration; input and output structure, including processor, the connection between memory and input, data transmission mode, data flow, and data exchange process control;
the composition of modern computersmodern computer is composed of arithmetic, memory, controller, I/O device. An operator is used to perform arithmetic and logic operations, and the intermediate results are computed, and the memory is used to store data and programs, and the controller is used to control, command, and manipulate the input, operation and processing results of the data, and the I/O devices are used to implement the input of the program data and the output of the calculation results. The arithmetic and controller are closely related to the logic relationship and the circuit structure, these two parts are often integrated on the same chip, usually together they are collectively referred to as the central processing unit, namely CPU. So modern computers usually have three components: CPU, memory, I/O devices. The main memory works by reading and writing each storage bit according to the storage unit address number. This access is known as access to memory by address. Memory This kind of work is very advantageous to the computer composition and operation, the people only need to pre-programmed in the sequence of main memory units, when running the program, first give the program in main memory first address, and then use the program Count plus one method, automatically form the next instruction where the storage unit address, The machine can automatically complete this program operation. In main memory, two registers Mar and Mdr,mar are used to store the address of the storage unit to be accessed, and the MDR is a memory data register, which is used to store the data taken from a memory unit and the data to be written to a memory unit, and the CPU is added to the control signal for the specific fetch and write action. The operator consists of at least 3 registers and an arithmetic logic unit (ALU). ACC is an accumulator register, MQ is the carrier register, and x is the operand register. The controller is the nerve center of the computer, and he directs each part to work automatically and harmoniously. The controller consists of a program counter (PC), instruction Register (IR), and a control unit. The PC holds the address of the current command to execute, it has a direct path between the Mar and the main memory, and has the function of Auto plus one, which automatically forms the address of the next instruction. IR is used to store the current current instruction, IR content to save the MDR independently. The operation code in IR is sent to CU, which is used to analyze the instruction, and its address code is sent to the memory of Mar as the operand, and the control unit CU is used to analyze the operation required by the current instruction and burst out various sequences of operation commands to control all the controlled objects. It takes three stages to complete an instruction operation: The controller first commands the memory to read a command, called the reference stage. This instruction is then analyzed to indicate what kind of operation the command is going to take and the address of the operand according to the addressing feature, called the analysis phase. Finally, according to the address of the operand and the operation code of the instruction to complete a certain operation, called the execution phase. The I/O subsystem includes various I/O devices and their corresponding interfaces, each IO device accepts various control commands issued by CU and is completed accordingly.
Here 's how the whole process of computer work is understood:First, the n instruction data is entered into main memory unit 0-n by the keyboard, and the PC initial value is 0 (the first address of the program). After starting the machine, the computer automatically according to the order of instruction in the memory to complete the reference, analysis instructions, execution instructions, until the execution of the last command.
The first instruction executes: After starting the machine, the controller immediately sends the contents of the PC to main memory mar (pc-> mar), and commands the memory to do the reading operation, at this moment the main memory No. 0 unit content is fed into the MDR, and then the MDR is sent to the controller IR (Mdr->ir), The process of taking a instruction is completed. after the CU analysis (OP (IR)->CU), the operation code is obtained, if the number of instructions, the CU will be in the IR address code sent to the MAR (IP)->mar, and command memory to do the read operation, the address unit in the number of operations sent to the MDR, The MDR is then sent to the operator's ACC (MDR->ACC) to complete the execution of this command, and the first takes the entire process of the command. At the same time, the PC completes the automatic addition of one operation, forming the address of the next operation instruction, that is, address No. 1th. Second instruction: With the first instruction, the PC sends the second instruction address to mar, commands the memory to do the reading operation, sends the 1th unit content to the MDR, also has the MDR sends to the IR, then the CU analyzes the operation code, if is the multiplication instruction, the CU sends the reading command to the memory, Take out the number of operands in the corresponding address cell in the IR, and the MDR is sent to the operator Mq,cu and then the multiplication Operation command is sent to the operator, the multiplication is completed and the result is stored in Acc. At the same time the PC completes the PC plus one operation. Third to fourth ... directive: And so on, each point refers to the analysis of execution, until the final result.
Linux Platform x86 compilation (i): modern computer structure composition and working process