Linux kernel Analysis experiment one--by Wangyue

Source: Internet
Author: User

First, the contents of the experiment

1) Experimental section (the following command is available for lab building 64-bit Linux virtual machine environment, 32-bit Linux environment may be slightly different)

Use

    1. Gcc–s–o main.s Main.c-m32

The commands are compiled into assembly code, and the numbers in the following code should be modified to avoid being identical to others.

  1. int g (int x)
  2. {
  3. return x + 3;
  4. }
  5. int f (int x)
  6. {
  7. return g (x);
  8. }
  9. int main (void)
  10. {
  11. return F (8) + 1;
  12. }

2) According to the knowledge of this week to analyze the work process of compiling code, write a signed blog, and in the blog post "real name (and the name of the final application certificate must be consistent) + Original works reproduced please specify the source +" Linux kernel Analysis "MOOC Course/http mooc.study.163.com/course/ustc-1000029000 ", the specific requirements of the blog content are as follows:

    • The topic is self-prepared, and the content revolves around how the computer works;

    • You need to use an experiment in your blog

    • Blog content requires careful analysis of stack changes during the work of the assembler code

    • The summary section needs to clarify its understanding of how the computer works.

3) Please submit the blog post URL to the NetEase cloud classroom Mooc Platform, edited into a link can be directly clicked open.

Second, the experiment

1. Prepare and disassemble the C program:

2. Use VIM.S to view the results after disassembly:

3. Analyze stack changes during the work of the assembler code:

Iii. Summary

Through this experiment, I have consolidated the knowledge learned in the compilation, and have a more profound understanding of the way the computer works. The role of the X86 Assembly directive and the various registers is clearer, and the Linux kernel uses the/T assembler format. Knowing that the function call stack is the key to understanding C code execution on the CPU and that the function call stack is superimposed on logically multiple stacks. 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.

Linux kernel Analysis experiment one--by Wangyue

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.