C51程序中使用汇编代码
2006-04-19 22:59
363 查看
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选项跟库函数路径冲突??失效了??
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选项跟库函数路径冲突??失效了??
相关文章推荐
- windows下32位汇编语言学习笔记 第四章 第一个窗口程序 1 (消息的使用和入口代码)
- 使用MPLAB编译C程序,查看生成的汇编代码
- [转]C# 2.0:使用匿名方法、迭代程序和局部类来创建优雅的代码
- C++ STL入门教程(1)——vector(向量容器)的使用(附完整程序代码)
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(二)
- 关于js的三种使用方式(行内js、内部js、外部js)的程序代码
- 使用WinDbg获得托管方法的汇编代码
- [C++ 基础] VS2005下查看C++程序汇编代码
- [编写高质量代码:改善java程序的151个建议]建议58 强烈建议使用UTF-8编码
- 使用jdk的jps、jstack工具检测代码问题,提高程序性能
- 使用Visual Studio(VS)开发Qt程序代码提示功能的实现
- 使用WinDbg获得托管方法的汇编代码
- C# 2.0:使用匿名方法、迭代程序和局部类来创建优雅的代码
- MS-VC 使用MAP文件快速定位程序崩溃代码行
- 编写高质量代码改善C#程序的157个建议——建议5: 使用int?来确保值类型也可以为null
- [编写高质量代码:改善java程序的151个建议]建议58 强烈建议使用UTF-8编码
- [编写高质量代码:改善java程序的151个建议]建议68 频繁插入和删除时使用LinkedList
- [编写高质量代码:改善java程序的151个建议]建议76 集合运算时使用更优雅的方式
- 汇编调试程序Debug使用