当前位置:网站首页>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 .
边栏推荐
- MySQL composite index with or without ID
- win10解决IE浏览器安装不上的问题
- SSM second hand trading website
- Win10 solves the problem that Internet Explorer cannot be installed
- ModuleNotFoundError: No module named ‘pytest‘
- Pointnet understanding (step 4 of pointnet Implementation)
- @Transitional step pit
- Conda 创建,复制,分享虚拟环境
- Translation of the paper "written mathematical expression recognition with bidirectionally trained transformer"
- [introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
猜你喜欢
Practice and thinking of offline data warehouse and Bi development
【信息检索导论】第七章搜索系统中的评分计算
Sparksql data skew
[introduction to information retrieval] Chapter 6 term weight and vector space model
Cognitive science popularization of middle-aged people
[introduction to information retrieval] Chapter 7 scoring calculation in search system
Implementation of yolov5 single image detection based on onnxruntime
图片数据爬取工具Image-Downloader的安装和使用
[medical] participants to medical ontologies: Content Selection for Clinical Abstract Summarization
How to efficiently develop a wechat applet
随机推荐
Alpha Beta Pruning in Adversarial Search
聊天中文语料库对比(附上各资源链接)
Win10 solves the problem that Internet Explorer cannot be installed
Comparison of chat Chinese corpus (attach links to various resources)
使用Matlab实现:Jacobi、Gauss-Seidel迭代
【信息检索导论】第三章 容错式检索
使用Matlab实现:弦截法、二分法、CG法,求零点、解方程
[torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated
论文tips
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
矩阵的Jordan分解实例
SSM supermarket order management system
Typeerror in allenlp: object of type tensor is not JSON serializable error
ModuleNotFoundError: No module named ‘pytest‘
基于onnxruntime的YOLOv5单张图片检测实现
MMDetection模型微调
allennlp 中的TypeError: Object of type Tensor is not JSON serializable错误
mmdetection训练自己的数据集--CVAT标注文件导出coco格式及相关操作
PHP returns the corresponding key value according to the value in the two-dimensional array
【Programming】