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

(五)
40. 链表题:一个链表的结点结构
struct Node
{
int data ;
Node *next ;
};
typedef struct Node Node ;
(1)已知链表的头结点head,写一个函数把这个链表逆序 ( Intel)
Node * ReverseList(Node *head) //链表逆序
{
i ......

flashpolicyd c 版本

#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#define MAX_READFILE 24
#define MAX_INPUTFILE 10240
char *file ;
void time_out(){
syslog(LOG_INFO,"read inp ......

用C/gsoap实现WebService

转贴自:http://blog.sina.com.cn/s/blog_629562fe0100gs2l.html
稍作修改
 
gSOAP是一个夸平台的,用于开发Web Service服务端和客户端的工具,在Windows、Linux、MAC OS和UNIX下使用C和C++语言编码,集成了SSL功能。
下载地址:http://sourceforge.net/projects/gsoap2
官方网站:http://genivia.com/Products/g ......

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

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