Linux kernel analysis-how the computer works

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.