汇编和调用C函数 其他开发语言 / 汇编语言 - CSDN社区 community.csdn.net

导读:



我用汇编1.asm:  
      extrn   _o:near  
      data               segment  
      data               ends  
      code               segment  
      main               proc           far  
                            assume   cs:code,ds:data  
      start:  
                            push   ds  
                            sub     ax,ax  
                            push   ax  
                            mov     ax,data  
                            mov     ds,ax  
      call     _o  
      ret  
      main               endp  
      code               ends  
      end                 start  
   
  调用o.c:  
  #include  
   
  o()  
  {  
  printf("aaa");  
  }  
   
  extern       void       main();  
   
  两个文件分别编译为obj文件:  
  tcc   -c   -Iz:/tc/include   o.c  
  masm   1  
  然后连接  
  tlink   1.obj   o.obj  
  总会报错“Undefined   symbol   '_PRINTF'   in   module   O.C  
  为何?如何解决阿?



文件改为:  
  1.asm:  
      extrn   _o:near  
      public   _main  
      data               segment  
      data               ends  
      code               segment  
      _main               proc           far  
                            assume   cs:code,ds:data  
      start:  
                            push   ds  
                            sub     ax,ax  
                            push   ax  
                            mov     ax,data  
                            mov     ds,ax  
      call     _o  
      ret  
      _main               endp  
      code               ends  
      end                 start  
  o.c:  
  #include   "stdarg.h"  
  #include   "stdio.h"  
   
  o()  
  {  
      printf("%s","aaaaa");  
  }  
   
  extern   void   main();  
   
  拷贝stdarg.h、stdio.h拷到tc根目录下,masm、tcc也在这个目录  
  编译通过  
   
  但是一执行生成的exe,dos就死机了  




本文转自

http://topic.csdn.net/t/20060904/10/4996403.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值