当前位置:网站首页>2021.8.29 notes: register, bit operation, pointer, structure

2021.8.29 notes: register, bit operation, pointer, structure

2022-06-25 04:25:00 Robin Luo Bing

One 、 register

1、 The purpose of setting the register :

Memory in CPU Outside , Generally refers to hard disk ,U Disk and other devices that can save data after cutting off the power supply , The capacity is generally large , The disadvantage is that the reading and writing speed is very slow , The reading and writing speed of ordinary mechanical hard disk is generally 50MB/S about . Memory and register is a multi-level storage mechanism to solve the problem of slow memory reading and writing speed ,

2、CPU When calculating , First read the data to be used from the hard disk to the memory in advance , Then read the data to be used into the register

3、 register ( Also known as cache ) Generally, it refers to the basic RS Derived from the trigger structure D Trigger , It's the structure of some NAND gates , Generally integrated in CPU Inside , Its reading and writing speed is the same as CPU The running speed basically matches

4、 Different registers have different functions , Such as : General registers (GR) Used to store operands 、 The address or intermediate result of an operand ; Instruction register (IR) It is used to store the currently executing instructions , So that in the process of instruction execution , Control completes all functions of an instruction .

5、cpu The composition of :

CPU The fundamental task is to execute instructions , For a computer, it's all a bunch of things “0” and “1” The sequence of components .CPU Logically, it can be divided into 3 A module , The control unit 、 Computing units and storage units , These three parts are made up of CPU Internal bus connection .

A、 control unit

The control unit is the whole CPU Command and control center , By the instruction register IR(Instruction Register)、 Instruction decoder ID(Instruction Decoder) And operating controls OC(Operation Controller) etc. , It is very important to coordinate the orderly work of the whole computer .

It's based on the user's pre programmed program , Take each instruction out of the memory in turn , Put it in the instruction register IR in , By decoding instructions ( analysis ) Determine what to do , And then by operating the controller OC, In a certain sequence , Send micromanipulation control signals to corresponding components .

Operating the controller OC It mainly includes beat pulse generator 、 Control matrix 、 Clock generator 、 Reset circuit, start stop circuit and other control logic .

B、 Arithmetic unit

It's the core of the arithmetic unit . Can perform arithmetic operations ( Including addition and subtraction multiplier and other basic operations and additional operations ) And logic ( Including displacement 、 Logic test or comparison of two values ). Relative to the control unit , The arithmetic unit receives the command from the control unit and operates , That is to say, all operations carried out by the operation unit are directed by the control signals sent by the control unit , So it's the executive part .

C、 Storage unit

Include CPU On chip cache and register group , yes CPU Where data is temporarily stored in , It holds the data waiting to be processed , Or data that has been processed ,CPU It takes less time to access registers than to access memory .

Use register , Can reduce the CPU Number of memory accesses , So as to improve CPU Working speed of .

But because of the limitation of chip area and integration , The capacity of a register group cannot be large . Register group can be divided into special register and general register . The function of special register is fixed , Register the corresponding data separately .

General purpose registers are widely used and can be specified by programmers , The number of general purpose registers varies from microprocessor to microprocessor . This is the key point we will introduce later , Let me first mention .

Two 、 An operation

35:  0 0 1 0 0 0 1 1
47:  0 0 1 0 1 1 1 1
————————————————————
82:  0 1 0 1 0 0 1 0

The calculation process : Each bit does XOR first 、1 and 1 The result is 10, That is, you need to carry . So the whole process is :" And " Operation and " displacement " Operation to achieve . The law of binary number operation is every two into one

1、 An operation :https://www.runoob.com/w3cnote/bit-operation.html

2、 The addition, subtraction, multiplication and division of integers are realized by bit operation :https://www.cnblogs.com/rgbit/p/10365840.html

3、 Decimal to binary , Using short division ; Binary to decimal , Weighted addition

3、 ... and 、 The pointer

1、 Concept :https://www.php.cn/cpl/cpl-pointers.html

2、C When do languages use pointers :

a. You can use a pointer at any time , Because using pointers is more efficient than using variables .
b. When a function returns 1 When there are more than operation results , You have to use a pointer , Because a function can only return one value , More have to use pointers “ Bring back ”.
c. When manipulating an array , Not only is it much more convenient to use pointers, but also the code is very time efficient .
d. When operating files , You can't walk without a pointer .
e. Using pointers can simplify the writing process of function calls , Make the source code easy to read .

Four 、C Structure

C Arrays allow you to define variables that can store items of the same type , The structure is C Another user-defined data type available in programming , It allows you to store different types of data items .

原网站

版权声明
本文为[Robin Luo Bing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210534569184.html