Analyze assembly code to understand how computers work, assembly code to understand computers
For reprinted original works of Zhou yuyong, please indicate the source
Linux Kernel Analysis MOOC course http://mooc.study.163.com/course/USTC-1000029000
Decompiling C code into assembly code to analyze how the computer works.Below is the simplified assembly code for compiling C code into assembly code
1g: 2 pushl % ebp 3 movl % esp, % ebp 4 movl 8 (% ebp), % eax 5 addl $6, % eax 6 popl % ebp 7 ret 8 f: 9 pushl % ebp10 movl % esp, % ebp11 subl $4, % esp12 movl 8 (% ebp), % eax13 movl % eax, (% esp) 14 call g15 leave16 ret17 main: 18 pushl % ebp19 movl % esp, % ebp20 subl $4, % esp21 movl $4, (% esp) 22 call f23 addl $2, % eax24 leave25 ret
Analysis of stack changes in the working process of assembly code
Conclusion: The EIP tells the CPU which command to execute. by executing a specific sequence of commands, the computer can complete a specific computing task.