美文网首页
c语言 生成汇编代码

c语言 生成汇编代码

作者: 曾柏超 | 来源:发表于2019-08-18 10:23 被阅读0次
    #include <stdio.h>
    
    // test.c
    int main()
    {
        int a = 1;
        int b = 2;
        a = a + b;
    }
    
    
    
    gcc -g -c test.c
    objdump -d test.o
    
    test.o: file format Mach-O 64-bit x86-64
    
    Disassembly of section __TEXT,__text:
    _main:
           0:   55  pushq   %rbp
           1:   48 89 e5    movq    %rsp, %rbp
           4:   31 c0   xorl    %eax, %eax
           6:   c7 45 fc 01 00 00 00    movl    $1, -4(%rbp)
           d:   c7 45 f8 02 00 00 00    movl    $2, -8(%rbp)
          14:   8b 4d fc    movl    -4(%rbp), %ecx
          17:   03 4d f8    addl    -8(%rbp), %ecx
          1a:   89 4d fc    movl    %ecx, -4(%rbp)
          1d:   5d  popq    %rbp
          1e:   c3  retq
    
    

    相关文章

      网友评论

          本文标题:c语言 生成汇编代码

          本文链接:https://www.haomeiwen.com/subject/tvqrsctx.html