Li Zeyuan
"Linux kernel Analysis" MOOC course Http://mooc.study.163.com/course/USTC-1000029000#/info
Knowledge Preparation
von Neumann architecture
Core Ideas
1. Von Neumann is: The digital computer system is binary; the computer should be executed in the order of the program.
2. The binary system is used as the basis of computer numerical calculation, and 0 and 1 represent the value. The binary system makes it easy for the computer to calculate the numerical value without using the decimal counting method commonly used by humans.
3. The sequence of procedures or instructions, that is, pre-programmed, and then handed to the computer in accordance with the pre-defined sequence of the program to perform numerical calculations.
Five types of addressing modes in assembly language
· Register addressing Registermode:% Register For example:%edx Access register edx
· Immediate addressing immediate: $ number for example: $0x123 value 0x123
· Direct addressing directly: numbers such as: 0x123 access address 0x123 point to memory
· Indirect addressing indirect: (% Register) (%EBX) For example: the memory in the Access register EBX the address pointed to
· Addressing displaced: offset (% register) 4 (%EBX): Accesses the address in the register EBX and adds 4 points to the memory;
A few important assembly instructions
Example instruction |
What it does |
PUSHL%eax |
Subl $4,%ESP//stack top pointer minus 4, stack grows down one position Movl%eax, (%ESP)//The memory location where the value in the EAX is placed on the top of the stack pointer |
POPL%eax |
MOVL (%ESP),%eax//from the in-memory value pointed to by the top of the stack into EAX Addl $4,%ESP//stack top pointer plus 4, stack is shrinking upward |
Call 0x12345 |
PUSHL%eip//IP Press Stack MOVL $0x12345,%EIP//0x12345 into EIP |
Ret |
POPL%eip//ip out Stack |
Command line:
Generated assembly code:
Schematic code:
How does a computer work?
The user will prepare the program through the input device into the computer, stored in the memory, through the input device to the computer to issue the command to execute the program. Therefore, under the control of the controller, the computer will work according to the program requirements automatically. When the computer is working, the controller takes out an instruction program from memory, analyzes what kind of operation the instruction requires the computer to perform, then executes the specified operation, executes an instruction, then takes the next instruction from the memory, and then analyzes and executes ... This is repeated until the program finishes executing.
How does a computer work? ----Li Zeyuan