Home  >  Article  >  Every time the CPU executes something, it completes a basic operation

Every time the CPU executes something, it completes a basic operation

青灯夜游
青灯夜游Original
2021-01-11 10:27:0529036browse

Every time the cpu executes an "instruction", it completes a basic operation or judgment. In the CPU, the execution of an instruction includes three steps: instruction fetching, analysis and execution. Therefore, executing an instruction will complete a basic operation or judgment.

Every time the CPU executes something, it completes a basic operation

#The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

Cpu completes basic operations by executing "instructions". Every time the computer's CPU executes an "instruction", it completes a basic operation or judgment. In the CPU, the execution of an instruction includes three steps: fetching, analysis and execution. Therefore, executing an instruction will complete one basic operation or judgment.

Central processing unit (CPU) is one of the main devices of electronic computers and the core component of computers. Its function is mainly to interpret computer instructions and process data in computer software. The CPU is the core component of the computer that reads instructions, decodes them, and executes them. The central processing unit mainly consists of two parts, namely the controller and the arithmetic unit, which also include cache memory and the data and control bus that realize the connection between them. The three core components of an electronic computer are the CPU, internal memory, and input/output devices. The main functions of the central processing unit are to process instructions, perform operations, control time, and process data.

In the computer architecture, the CPU is the core hardware unit that controls and allocates all hardware resources of the computer (such as memory, input and output units) and performs general operations. The CPU is the computing and control core of the computer. The operations of all software layers in the computer system will eventually be mapped to CPU operations through the instruction set.

How the CPU works

The Von Neumann architecture is the foundation of modern computers. Under this architecture, programs and data are stored uniformly. Instructions and data need to be accessed from the same storage space and transmitted through the same bus, and cannot be executed overlappingly. According to the von Neumann system, the work of the CPU is divided into the following five stages: instruction fetch stage, instruction decoding stage, instruction execution stage, memory access and result write back.

Instruction fetch (IF, instruction fetch) is the process of fetching an instruction from the main memory to the instruction register. The value in the program counter indicates the location of the current instruction in main memory. When an instruction is fetched, the value in the PC will be automatically incremented according to the length of the instruction word.

Instruction decoding stage (ID, instruction decode), after fetching the instruction, the instruction decoder splits and interprets the fetched instruction according to the predetermined instruction format, and identifies and distinguishes different instruction categories. Various methods of obtaining operands.

Execution instruction phase (EX, execute), specifically implements the function of the instruction. Different parts of the CPU are connected to perform the required operations.

Access and access phase (MEM, memory), according to the instruction needs to access the main memory and read the operand, the CPU gets the address of the operand in the main memory, and reads the operand from the main memory Used for operations. Some instructions do not require access to main memory, so this stage can be skipped.

Result write back stage (WB, write back), as the last stage, the result write back stage "writes back" the running result data of the execution instruction stage to some storage form. The result data is generally written to the internal register of the CPU so that it can be quickly accessed by subsequent instructions; many instructions also change the status of the flag bits in the program status word register. These flag bits identify different operation results and can be Used to affect program actions.

After the instruction is executed and the result data is written back, if no unexpected events (such as result overflow, etc.) occur, the computer will obtain the next instruction address from the program counter and start a new cycle. The instruction cycle will fetch the next instruction sequentially.

If you want to read more related articles, please visit PHP Chinese website! !

The above is the detailed content of Every time the CPU executes something, it completes a basic operation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What service is port 445?Next article:What service is port 445?