How does a computer work? ----Li Zeyuan

Source: Internet
Author: User

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

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.