C51程序中使用汇编代码

KEIL公司的uVision2 V2.40 自带的C51.pdf如是说:

 


 

ASM / ENDASM
Abbreviation: None.
Arguments: None.
Default: None.
μVision2 Control: This directive may not be specified on the command line.
Description: The ASM directive signals the beginning of a block of
source text to merge into the .SRC file generated using the
SRC directive.
This source text can be thought of as in-line assembly.
However, it is output to the source file generated only when
using the SRC directive. The source text is not assembled
and output to the object file.
In μVision2 you may set a file specific option for C source
files that contain ASM/ENDASM sections as follows:
Right click on the file in the Project Window – Files tab
Choose Options for… to open Options – Properties
page
Enable Generate Assembler SRC file
Enable Assemble SRC file.
With this setting, μVision2 generates an assembler source
file (.SRC) and translates this file with the Assembler to an
Object file (.OBJ).
The ENDASM directive signals the end of the source text
block.
NOTE
The ASM and ENDASM directives can occur only in the
source file, as part of a #pragma directive.

其实这样做不行,编译器将报告 C51代码中的库函数调用找不到目标模块:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  _PUTCHAR
    MODULE:  downmsg.obj (DOWNMSG)
除非关闭代码管理属性中的生成SRC文件的选项,而这时,代码中directive(宏指令?)#pragma asm ...#pragma endasm 又将被报告为需要打开SRC选项。
根据C51/assembly 混合编程的网络信息,在C51中调用汇编模块时,需要将KEIL/C51/LIB/C51S.LIB文件加入工程项目中一起编译,结果发现在C51代码中宏指令方式嵌入汇编代码时,也需要显式的将使用到的库函数obj(C51S.lib)加入编译项目中!——难道SRC选项跟库函数路径冲突??失效了??
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值