当前位置:网站首页>Execution of procedures
Execution of procedures
2022-07-02 07:40:00 【Xiao Chen who wants money】
CPU When the command is executed :
1、 First ,CPU Read program counter (PC,program counter) The instruction that the pointer points to , Import it into the instruction register (IR, Instruction Register), say concretely , The completion of the read instruction has 3 A step :
- CPU The control unit operation address bus specifies the memory address to be accessed .( Simple understanding , Is to put PC The value in the pointer is copied to the address bus ).
- CPU Notify the memory device to prepare data .
- CPU After receiving the data from memory , Store this data in the instruction register .
Complete the above 3 Step ,CPU Read successfully PC The pointer points to the instruction , Stored in the instruction register .
However ,CPU Analyze the instructions in the instruction register , Determine the type and parameters of the instruction . If it's a compute type instruction , Then it's up to the logic unit to calculate ; If it's a storage type instruction , So it's executed by the control unit .
PC The pointer increases by itself , Ready to get the next instruction .
For example 32 On the machine , Instruction is 32 position 4 Bytes , need 4 Memory address storage , therefore PC The pointer will increase automatically 4.
With a=11+15 For example .
We will have a Review Next question : Programs written by programmers a=11+15 yes character string ,CPU Cannot execute string , Only instructions can be executed . So a special program is needed here —— compiler . The core competence of the compiler is translation , It translates one program into another program language .
here , We need a compiler to translate the program written by the programmer into CPU Know the instructions ( Instructions are considered a low-level language , We usually write high-level languages ).
Let's elaborate on a=11+15 Implementation process of :
1. The compiler analyzes , Find out 11 and 15 Is the data ( The code will indicate the data type ), So when the compiled program starts , A special area will be opened in memory to store such constants , This area is dedicated to storing constants , Data segment , As shown in the figure below :
11 Stored in the address 0x100;
15 Stored in the address 0x104;
2. Compiler will a=11+15 Convert to 4 Orders , After the program starts , These instructions are imported into an area dedicated to storing instructions , That is, the body segment , As shown in the figure above , this 4 Instructions are stored in 0x200-0x20c In the area of :
0x200 Positional load The command will address 0x100 Data in 11 Import register R0;
0x204 Positional load The command will address 0x104 Data in 15 Import register R1;
0x208 Positional add Instruction will register R0 and R1 Add the values in , Storage register R2;
0x20c Positional store Instruction will register R2 The values in are stored back in the data area 0x1108 Location .
3. When it comes to concrete implementation ,PC The pointer first points to 0x200 Location , Then execute this in turn 4 Orders .
Here are a few more questions to explain :
1. Variable a It's actually an address in memory ,a It's a mnemonic for programmers .
2. Why? 0x200 The instructions representing loading data into registers in are 0x8c000100, We will discuss in detail below .
3. I don't know whether careful students find , In the example above , Every time we operate 4 An address , That is to say 32 position , This is because we are using 32 The seat is wide CPU give an example . stay 32 The seat is wide CPU in , So are the instructions 32 Bit . But the data can be less than 32 position , For example, you can add two 8 Bytes of bits .
4. About the content of data segment and body segment , I will continue to explain in the process and thread section of module 4 .
边栏推荐
- Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
- 使用Matlab实现:弦截法、二分法、CG法,求零点、解方程
- [torch] the most concise logging User Guide
- 【Mixup】《Mixup:Beyond Empirical Risk Minimization》
- ModuleNotFoundError: No module named ‘pytest‘
- Implementation of yolov5 single image detection based on pytorch
- 半监督之mixmatch
- Typeerror in allenlp: object of type tensor is not JSON serializable error
- 【信息检索导论】第三章 容错式检索
- label propagation 标签传播
猜你喜欢

Proof and understanding of pointnet principle

SSM laboratory equipment management

Common CNN network innovations

【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》

程序的内存模型

Spark SQL task performance optimization (basic)

How do vision transformer work?【论文解读】

iOD及Detectron2搭建过程问题记录
![[introduction to information retrieval] Chapter 7 scoring calculation in search system](/img/cc/a5437cd36956e4c239889114b783c4.png)
[introduction to information retrieval] Chapter 7 scoring calculation in search system

Alpha Beta Pruning in Adversarial Search
随机推荐
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
Calculate the difference in days, months, and years between two dates in PHP
常见CNN网络创新点
[torch] the most concise logging User Guide
优化方法:常用数学符号的含义
【信息检索导论】第一章 布尔检索
Sorting out dialectics of nature
SSM garbage classification management system
Open failed: enoent (no such file or directory) / (operation not permitted)
CONDA creates, replicates, and shares virtual environments
Calculate the total in the tree structure data in PHP
程序的内存模型
基于onnxruntime的YOLOv5单张图片检测实现
SSM student achievement information management system
Classloader and parental delegation mechanism
超时停靠视频生成
Cognitive science popularization of middle-aged people
Huawei machine test questions
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation

