Talking about the working process of computer program

Source: Internet
Author: User

--------------------------------------------------------------------------------------------------------------- -------------------------

  This article is the MOOC course http://mooc.study.163.com/course/USTC-1000029000 of Linux kernel analysis. Homework after the first lesson. Student Name: Liu Zheng

  The main content of this paper is to write a simple C language program, convert it into assembly code, analyze the changes in the stack. If there is an error, please give your valuable comments, thank you.

--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------

Before analyzing the code, let's talk about the basic assembly language:

1, Movl%eax,%edx//edx=eax (register addressing is memory Independent)

2, Movl $0x123,%edx//edx=0x123 (immediate addressing)

3, Movl 0x123,%edx//edx=* (int32_t *) 0x123

4, MOVL (%EBX),%edx//edx=* (int32_t *) ebx

5, MOVL 4 (%EBX),%edx//edx = * (int32_t *) (EBX+4)

6, PUSHL%eax//subl $4,%esp

Movl%eax, (%ESP)

7, Popl%eax//MOVL (%ESP),%eax

Addl $4,%esp

8, ret//POPL%EIP

  

 I. Establishment of a C procedure and conversion to a compilation document

1. Open the Linux virtual machine and use the VI main.c command to edit the code in the editor as follows:

    

    2. Convert it to a compilation file in a Linux virtual machine and name it MAIN.S

    

3, finishing get MAIN.S assembly code

    

second, analysis of the stack in the assembly code change situation

 Iii. Summary

The basic principle of computer is stored program and program control. A sequence of instructions (called a program) and raw data that directs the operation of the computer in advance is delivered to the computer's memory via the input device. Each instruction explicitly specifies which address the computer takes from, what to do, and what address to send to. When the computer is running, the first instruction is removed from the memory, and the decoding of the controller, according to the requirement of the instruction, takes the data from the memory to perform the processing of the specified arithmetic and logic operation, and then sends the result to the memory by the address. Next, take out the second instruction and complete the specified operation under the command of the controller. Proceed accordingly. Until a stop command is encountered. The program and data storage, according to the Order of the program, step-by-step take out the instructions, automatic completion of the instructions prescribed by the computer is the most basic principle of operation. This principle was originally proposed by the Hungarian-American mathematician von Neumann in 1945, so it is called von Neumann principle. (from Baidu Encyclopedia)

  

Talking about the working process of computer program

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.