20135201 Li Chenxi How does the computer work in the first week of Linux kernel analysis?

Source: Internet
Author: User

How the computer works

1 von Neumann architecture: A computer architecture with a stored program

Most of the devices that have computing and storage capabilities (smartphones, tablets, computers, etc.) are von Neumann architectures at the moment

    1. From the hardware point of view: The CPU and memory through the main line connection, the CPU on the IP (may be 16, 32, 64 bits) always point to an area of memory, the IP points to the CS (code snippet) is also in memory; The CPU always executes the instruction that the IP points to.
    2. From the Software View: API (Application Programming interface, with programmer) and ABI (the interface between program and CPU) are two important software interfaces.
2. x86 (32-bit) registers, low 16 bits as 16-bit register3. The stack segment registers have EBP (stack base register) and ESP (stack top pointer register). 4.64-bit CPU: In fact, with 32 bit in the core mechanism of small differences, 64 bits of the machine, the Register to RXX represents 5. Common Assembly directives
    1. The suffix of the b,w,l,q represents the 8,16,32,64 position respectively.
    2. Register addressing with% ID does not "deal" with memory
    3. Direct addressing & immediate number addressing
      1. MOVL $0x123,%eax--%eax=0x123
      2. MOVL 0x123,%eax--Immediate number is a hexadecimal value that begins with $. Directly accesses the data in the specified memory address (0x123) and assigns it to%eax
    4. Variable address addressing

      movl 4(%ebx),%edx//edx = *(inet_32 *)(ebx+4),即ebx的值加4之后作为一个地址,将其指向的数据赋给%edx
    5. Most directives have direct access to memory addresses

Homework

汇编一个简单的C程序分析其汇编指令执行过程:




编译结果:






删除掉以点(.)开头的指令之后,得到干净完整的汇编指令如下:

g:pushl %ebpmovl %esp, %ebpmovl 8(%ebp), %eaxaddl $6, %eaxpopl %ebpretf:pushl %ebpmovl %esp, %ebpsubl $4, %espmovl 8(%ebp), %eaxmovl %eax, (%esp)call addleaveretmain:pushl %ebpmovl %esp, %ebpsubl $4, %espmovl $6, (%esp)call faddl $1, %eaxleaveret
分析:







总结:
首先,因为是跟新电脑的磨合期解聘工具没找着,图片怎么也旋转不过来请谅解。
对“计算机是如何工作的”的理解:
我眼中的计算机是一个非常听话,中规中矩的孩子,一步步按照命令来执行,犯的错误也很少,不会耍小聪明走捷径,除非指出来。但要做到这一点就需要他的五脏六腑来协调工作。储存设备给予他空间去存储各种东西,指令负责指挥各项操作,就像人体的器官和血液一样,互相互利共生。

最后,这一学期请老刘男神多多指教啦!


李辰希 《Linux内核分析》MOOC课程http://mooc.study.163.com/course/USTC-1000029000







20135201 Li Chenxi How does the computer work in the first week of Linux kernel analysis?

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.