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
Movl8 (%EBP),%eax
Addl$3,%eax
Popl%ebp
Ret
F:
Pushl%ebp
MOVL%ESP,%EBP
Subl$4,%esp
Movl8 (%EBP),%eax
Movl%eax, (%ESP)
Callg
Leave
Ret
Main
Pushl%ebp
MOVL%ESP,%EBP
Subl$4,%esp
Movl$8, (%ESP)
Callf
Addl$1,%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.
Hu Yu Feng
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
How the computer works