疯狂java


您现在的位置: 疯狂软件 >> 新闻资讯 >> 正文

从汇编的角度分析C语言


 

#include <stdlib.h> #include <stdio.h>

  int main()

  { int m = 1;int * p;int * q;p = &m;q = p;*p = 2;*q = 3;return 0;} view plain(gdb) disassemble main Dump of assembler code for function main:0x08048394 <+0>:     push   %ebp 0x08048395 <+1>:     mov    %esp,%ebp 0x08048397 <+3>:     sub    $0x10,%esp view plain 0x0804839a <+6>:     movl   $0x1,-0xc(%ebp)

  view plain 0x080483a1 <+13>:    lea    -0xc(%ebp),%eax 0x080483a4 <+16>:    mov    %eax,-0x4(%ebp)

  view plain 0x080483a7 <+19>:    mov    -0x4(%ebp),%eax 0x080483aa <+22>:    mov    %eax,-0x8(%ebp)

  view plain 0x080483ad <+25>:    mov    -0x4(%ebp),%eax 0x080483b0 <+28>:    movl   $0x2,(%eax)

  view plain 0x080483b6 <+34>:    mov    -0x8(%ebp),%eax 0x080483b9 <+37>:    movl   $0x3,(%eax)

  view plain 0x080483bf <+43>:    mov    $0x0,%eax view plain 0x080483c4 <+48>:    leave 0x080483c5 <+49>:    ret End of assembler dump.(gdb)