Knowledge Points:
Von Neumann architecture, its core idea is to store the program computer.
The CPU is connected to the memory via the bus, and the IP pointer takes one instruction from the memory in turn.
API: interface between programmer and computer.
ABI: interface between program and CPU.
Registers, addressing methods and various directives have been thoroughly understood in the study of "in-depth understanding of computers" and "compilation".
Experiment:
Into the following:
The original code is:
int g (int x) {return x+3;}
int f (int x) {return g (x);} a int main (void) {return F (8) +1;}
The assembly code is:
G:PUSHL%ebp movl%esp,%EBP movl 8 (%EBP),%eax Addl $,%eax popl%EBP ret f:pushl%ebp movl%esp,%ebp subl $4,%esp m OVL 8 (%EBP),%eax movl%eax, (%ESP) call G leave RET MAIN:PUSHL%ebp movl%esp,%ebp subl $4,%esp movl $8, (%ESP) call F Addl $,%eax leave RET
The code is very simple, just remember
PUSHL%EBP equivalent to Subl $4,%esp movl%ebp, (%ESP)
Leave equivalent to MOVL%ebp,%esp popl%EBP
POPL%EBP equivalent to MOVL (%ESP),%EBP Addl $4
Call is the value of the return address that is the current EIP pressed into the top of the stack, and then jump to the start address of the function
RET popup return address to EIP continue to execute the following instruction
How the Computer works:
is to follow the programming of the program, the CPU from memory to take out instructions and data and execute.
Huang Wei
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
Linux kernel analysis-how the computer works