易截截图软件、单文件、免安装、纯绿色、仅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++面试题(三)

1) 什么是预编译,何时需要预编译:总是使用不经常改动的大型代码体。
程序由多个模块组成,所有模块都使用一组标准的包含文件和相同的编译选项。在这种情况下,可以将所有包含文件预编译为一个预编译头。
2) char * const p;
  char const * p
  const char *p ......

Pro*C对inner join的支持情况

整理自:http://forums.oracle.com/forums/thread.jspa?threadID=664180&tstart=0
问:Is it possible to use INNER JOIN's with Pro*C? I'm currently getting this error:
INNER JOIN t_diagnosis b ON a.sak_diag = b.sak_diag
....1
PCC-S-02201, Encountered the symbol "INNER" when expecting on ......

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 ......

C51: MIXING C AND ASSEMBLY

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

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号