LoveUnix » 编程开发 & Rational » gcc -S编译出来的汇编语言怎么看啊
让LU留住您的每

一天 让LU博客留住您的每一天
2006-10-10 09:05 pkar
gcc -S编译出来的汇编语言怎么看啊

使用gcc -S编译出来的东西像下面这样
跟以前学过的8086的汇编语言好像不太一样啊      
在网上查找了一下,说这好像是gcc内嵌的at&t格式的汇编语言
而关于gcc内嵌汇编语言的说明,网上也就是那么一篇文章,
被到处拷贝,而且说明还不全
比如下面的subl, leal指令的说明都没有
哪里有gcc内嵌汇编语言指令说明的资料啊
linux系统的man上有吗?


test.c
      1 #include "stdio.h"
      2 main(){
      3     int i = 2;
      4     int j = (++i) + (++i);
      5     printf("%d\n", j);
      6 }


test.s
     1         .file   "test.c"
      2         .section        .rodata
      3 .LC0:
      4         .string "%d\n"
      5         .text
      6 .globl main
      7         .type   main,@function
      8 main:
      9         pushl   %ebp
     10         movl    %esp, %ebp
     11         subl    $8, %esp
     12         andl    $-16, %esp
     13         movl    $0, %eax
     14         subl    %eax, %esp
     15         movl    $2, -4(%ebp)
     16         leal    -4(%ebp), %eax
     17         incl    (%eax)
     18         leal    -4(%ebp), %eax
     19         incl    (%eax)
     20         movl    -4(%ebp), %eax
     21         addl    -4(%ebp), %eax
     22         movl    %eax, -8(%ebp)
     23         subl    $8, %esp
     24         pushl   -8(%ebp)
     25         pushl   $.LC0
     26         call    printf
     27         addl    $16, %esp
     28         leave
     29         ret
     30 .Lfe1:
     31         .size   main,.Lfe1-main
     32         .section        .note.GNU-stack,"",@progbits
     33         .ident  "GCC: (GNU) 3.2.3 20030502 (Red Hat Linux 3.2.3-52)"

2006-10-10 12:25 sinister
那是 AT&T 的语法格式,没啥区别。你最好用 gdb 从头调试一下加深理解。

2006-10-10 13:43 pkar
刚才问了一个同事,也是这么说的
看来8086的汇编还得好好看看

gdb还没有用过,好像很难
不过,谢谢
晚上回家再看看,弄一弄
:handshake

页: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.