易截截图软件、单文件、免安装、纯绿色、仅160KB

C51: CALLING ASSEMBLY ROUTINES from C

以下全文转载自http://www.keil.com/support/docs/50.htm                            Copyright © 2010 Keil™, An ARM® Company.
Information in this article applies to:
C51 All Versions
QUESTION
In the C51 compiler manual, there is example of an assembly module calling a C function. Is there any example of a C program calling an assembly routine?
ANSWER
There are no examples in the book, but it is easy to create your own. The asm routine must know how parameters are passed, values returned, and the naming conventions of segments. The steps you must follow to create an example are outlined below:
Write a simple function in C that passes parameters and returns values the way you want your assembly routine to.
Use the SRC directive (#PRAGMA SRC at the top of the file) so that the C compiler generates a .SRC file instead of a .OBJ file.
Compile the C file. Since the SRC directive was specified, the .SRC file is generated. The .SRC file contains the assembly code generated for the C code you wrote.
Rename the .SRC file to a .A51 file.
Edit the .A51 file and insert the assembly code you want to execute into the body of the assembly function shell included in the .A51 file.
For example, the following code
#pragma SRC
unsigned char my_assembly_func (
unsigned int argument)
{
return (argument + 1); // Insert dummy lines to access all args and retvals
}
when compiled generates the following assembly SRC file.
NAME TESTCODE
?PR?_my_assembly_func?TESTCODE SEGMENT CODE
PUBLIC _my_assembly_func
; #pragma SRC
; unsigned char my_assembly_func (
RSEG ?PR?_my_assembly_func?TESTCODE
USING 0
_my_assembly_func:
;---- Variable 'argument?040' assigned to Register 'R6/R7' ----
; SOURCE LINE # 2
; unsigned int argument)
; {


相关文档:

经典C/C++面试题(三)2

32)
  int main()
  {
   int x=3;
   printf("%d",x);
   return 1;
  }
  问函数既然不会被其它函数调用,为什么要返回1?
  mian中,c标准认为0表示成功,非0表示错误。具体的值是某中具体出错信息
33) 要对绝对地址0x100000赋值,我们可以用(unsigned int*)0x100 ......

【入门】用Linux中man命令查询C函数

      大家都知道在Unix/Linux中有个man命令,可以查询常用的命令,函数。可是对于我们这样只知道用"man 函数名"来查询的人来说,会遇到很多问题,比如:
      man read,我想看的是ANSI C中stdio的read函数原型和说明,没想到出来的确是BASH命令的说明,这是怎么回事 ......

anic:比C快比Java安全比shell还简单的新语言

一位ID为ultimus的程序员开发了一种名为anic的新语言,近日引起业界关注。根据Google Code上该项目的简介,该语言的正式名称是ANI,anic是这种语言的参考实现。
ANI是一种实验性、高性能、静态安全、完全隐含支持并行、面向对象的通用数据流编程语言。
anic用GNU工具链写成,因此可移植性很好,可以运行于所有主流操作系 ......

A51: CALLING C FUNCTIONS from ASSEMBLY

以下全文转载自http://www.keil.com/support/docs/697.htm                       Copyright © 2010 Keil™, An ARM® Company.
Information in this article applies to:
C51 Versio ......

50个c/c++源代码网站[转]

C/C++是最主要的编程语言。这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码。这份清单提供了源代码的链接以及它们的小说明。我已尽力包括最佳的C/C++源代码的网站。这不是一个完整的清单,您有建议可以联系我,我将欢迎您的建议,以进一步加强这方面的清单。
1、http://snippets.dzone.com/tag/c/ --数以千计 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号