gcc将内嵌汇编编译成汇编

 extern int input ,result;
  2
  3 void test_at_t()
  4 {
  5     result = 0;
  6     input = 1;
  7     __asm__
  8     __volatile__("addl%1, %0":"=r"(result):"r"(input));
  9 }
~                                                                               
~                                                                               
~ test.c                                                                             
~                      

$gcc -S test.c


编译后产生test.s


     .file   "test_at_t.c"
  2     .text
  3 .globl test_at_t
  4     .type   test_at_t, @function
  5 test_at_t:
  6     pushl   %ebp
  7     movl    %esp, %ebp
  8     movl    $0, result
  9     movl    $1, input
 10     movl    input, %eax
 11 #APP
 12 # 7 "test_at_t.c" 1
 13     addl%eax, %eax
 14 # 0 "" 2
 15 #NO_APP
 16     movl    %eax, result
 17     popl    %ebp
 18     ret
 19     .size   test_at_t, .-test_at_t
 20     .ident  "GCC: (Debian 4.4.5-8) 4.4.5"
 21     .section    .note.GNU-stack,"",@progbits
~                                                                               
 ~/test_at_t.s[1]                                       [asm] unix utf-8 2:1/21


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值