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

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 Version 5 and Later
QUESTION
I wish to call a function written in C from my assembly code. How do I do it?
ANSWER
The easiest way to achieve this is to let the C compiler generate the correct assembly code for you.
Suppose you have a C function called 'foo' which takes a single unsigned char argument and returns an unsigned char value. In a new C file write a dummy function that calls 'foo'. For example:
#pragma src
extern unsigned char foo(unsigned char);
void dummy(void)
{
unsigned char x,y;
x = 1;
y = foo(x);
}
#pragma SRC directs the C compiler to generate assembly code when the file is compiled. The extension of the assembly file will be 'src'.
If you view the src file you will see how to call the function 'foo' from assembly. It shows the registers or memory locations used to pass the function arguments and which registers or memory locations are used to return a value. In addition it also gives you the correct function naming convention to use, which is essential for interfacing assembly to C.
You can then use the src file as a template to write the function call in your own assembly code. Note that you must also include the EXTRN directive for the function, eg:
EXTRN CODE (_foo)
Permission to use documents and related graphics available from this server ("Server") is granted, provided that (1) the below copyright notice appears in all copies and that both the copyright notice and this permission notice appear, (2) use of documents and related graphics available from this Server is for informational and non-commercial or personal use only, (3) no documents or related graphics, including logos, available from this Server are modified in any way


相关文档:

经典C/C++面试题(二)

char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha&nb ......

关于C的思考


关于C的思考
Cong Wang
May, 2006
Network Engineering Department
Institute of Post and Telecommunications, Xi'an, P.R.China
引言
    C语言结合了汇编的所有威力,它的抽象程度碰巧既满足了程序员的要求, 又容易实现。因其独特的灵活性和强大的可移植性,系统程序员和黑客们更是对它钟爱 ......

语言混编之java调用c dll jni技术小试

刚从网上看到c和java混编的文章,就亟不可待的尝试了一下。呵呵,效果还是很好的。下面将自己成果粘贴出来
(转载于http://www.zxbc.cn/html/20070518/19986.html)。实验之后可以通过。
1java中调用c语言
首先编写Main.java
public class Main 
{
 public native static int getStrNum(byte str[], int s ......

Pro*C SQLDA 结构体

--摘自 《Oracle Pro*C 程序开发》     --Create/Modify Email:xingchengli@gmail.com
SQLDA 的结构如下:
struct SQLDA
{
long N; /* Descriptor size in number of entries */
char **V; Ptr to Arr of addresses of main variables */
long *L; /* Ptr to Arr of lengths of buffe ......

ARM第一个项目中关于C的总结

1:每一个变量在使用前都得声明,不然在使用的时候就有可能是随机的数字
2:注意头文件中函数声明的时候要在后面加上分号
3:注意串口可以打印变量,就像C中的printf一样
4:DNW中不能打印float型数据
5:注意结构体指针数组 的使用和调用
6: ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号