How the computer works
Name: Gao Yi Tong
Learning resources: "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
One, the model of the storage program computer work
The von Neumann architecture, in other words, is a stored-program computer model.
(1) From the hardware point of view
Between the CPU and the memory through the bus connection, the CPU IP register is divided into 16bit 32bit 64bit,cpu from the IP point to the memory address take instruction execution, the IP adds one, takes down an instruction to execute again.
(2) from the programmer's point of view
A For loop execution instruction within the CPU, connected to the memory via the bus.
ABI: interface between program and CPU
EPI: Add one, execute next instruction
Ii. the basis of X86 compilation
2.1 X86 CPU Register
(1) General purpose register
Note: The register with the start of E is the 32-bit register EBP stack base register ESP stack top register
(2) Segment register
Note: cs-code segment Register ss-stack Register
The CPU actually takes command CS:EIP to determine the bit an instruction
(3) Flag Register: The current position of the flag
2.2 X86 64-bit Register
There is little difference between 32-bit and 64-bit core mechanisms. 64-bit register with R at the beginning
(1) General purpose register
2.3 mov instruction and several addressing methods
(1) MOV instruction
Note: MOVB stands for 8 bits, MOVW stands for 16 bits. MOVL stands for 32 bits, MOVQ stands for 64 bits.
Register mode, registers marked with% start, etc.
MOVL%eax,%edx assigns eax to edx Register addressing
16 MOVL of the &ox123,%edx 123 into edx immediate addressing
MOVLX Ox123%,%edx 16 binary 123 refers to the memory data placed in EdX direct addressing (direct access to a specified memory address data)
MOVLX (%EBX),%edx the value of the register directly as a memory address to access indirect addressing
MOVLX 4 (%EBX),%edx change the value of the Register address on the basis of the indirect addressing
2.4 Several important assembly instructions
Third, the analysis of the code in the experimental building
3.1 Enter the experimental building to experiment with the following
Note:
CD Code to download
I exit insert for Insert mode ESC
Delete the entire line at the beginning of the code with the DD combination deleted, leaving the pure assembly code
3.2 Conducting Code Analysis
Iv. Summary
Through this study of the Linux course, I learned that the computer through the CPU registers read instructions to work, and mastered the simple assembly instructions, such as MOV instructions, push instructions, pop instructions, ret instructions, leave instructions, etc., Through the deep understanding of the code snippet to consolidate and improve the above instructions, and understand the similarities and differences of these instructions, such as the pop instruction and the push command, the push instruction first%ESP, then the assignment, and the pop instruction first%ESP the addition, and then the ESP memory address to assign value. These details are somewhat negligent, and the results are quite different. In the future study, we must pay more attention to detail, perfect self. In the experimental building experiment, because the first time to contact the Linux language, so in the code of the paste step appeared a problem, and later through the classmate learned that input I into the insertion mode, paste, Esc key exit paste mode, let me benefit.
In the future study of the Linux course, I will be more intentions, careful, patient, focus on review and consolidation, develop good learning habits.
How the computer works