当前位置:网站首页>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 .
边栏推荐
- win10+vs2017+denseflow编译
- @Transitional step pit
- 常见的机器学习相关评价指标
- Alpha Beta Pruning in Adversarial Search
- Drawing mechanism of view (I)
- Use Baidu network disk to upload data to the server
- Conda 创建,复制,分享虚拟环境
- Get the uppercase initials of Chinese Pinyin in PHP
- 超时停靠视频生成
- 【TCDCN】《Facial landmark detection by deep multi-task learning》
猜你喜欢
Practice and thinking of offline data warehouse and Bi development
Alpha Beta Pruning in Adversarial Search
自然辩证辨析题整理
【AutoAugment】《AutoAugment:Learning Augmentation Policies from Data》
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
【论文介绍】R-Drop: Regularized Dropout for Neural Networks
A slide with two tables will help you quickly understand the target detection
机器学习理论学习:感知机
【深度学习系列(八)】:Transoform原理及实战之原理篇
[introduction to information retrieval] Chapter 3 fault tolerant retrieval
随机推荐
Delete the contents under the specified folder in PHP
[introduction to information retrieval] Chapter 6 term weight and vector space model
parser. parse_ Args boolean type resolves false to true
Huawei machine test questions-20190417
A summary of a middle-aged programmer's study of modern Chinese history
Feeling after reading "agile and tidy way: return to origin"
一份Slide两张表格带你快速了解目标检测
SSM second hand trading website
腾讯机试题
Module not found: Error: Can't resolve './$$_ gendir/app/app. module. ngfactory'
Sorting out dialectics of nature
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》
parser.parse_args 布尔值类型将False解析为True
Interpretation of ernie1.0 and ernie2.0 papers
A slide with two tables will help you quickly understand the target detection
《Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer》论文翻译
MMDetection安装问题
【TCDCN】《Facial landmark detection by deep multi-task learning》
【Torch】解决tensor参数有梯度,weight不更新的若干思路