Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

zz C/C++ÖеÄÈÕÆÚºÍʱ¼ä


C/C++ÖеÄÈÕÆÚºÍʱ¼ä
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼ÆÊ±¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ ......

Ïê½âCÅÌWindowsÎļþ¼ÐÀïÖØÒªÎļþµÄ×÷ÓÃ

Ïê½âCÅÌWindowsÎļþ¼ÐÀïÖØÒªÎļþµÄ×÷Óà
ÔÚÕû¸öWindows²Ù×÷ϵͳÖУ¬×îÖØÒªµÄιýÓÚ“Windows”Îļþ¼Ð£¬¶ÔµçÄÔ½øÐÐÈκβÙ×÷¼¸ºõ¶¼Óйء£Á˽âÕâÀï¶ÔÓÚÕÆÎÕÕû¸öϵͳµÄÔË×÷ÓкܴóµÄ×÷Óã¬Èç¹ûÓÐÐËȤ²»·ÁÍùÏ¿´¿´¡£
Ò»¡¢Ó¡ÏóÖеÄWindowsÎļþ¼Ð
“Windows”Îļþ¼Ð¸øÈ˵ĵÚÒ»Ó¡Ïó¾ÍÊÇ´ó¶øÂÒ£¬¸Ð¾õÀïÃæ ......

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

NetBeans + MinGW µÄ C/C++ ¿ª·¢»·¾³ÅäÖÃ


Ç°ÃæµÄÎÄÕ¡¶´î½¨»ùÓÚ NetBeans µÄ OpenGL ¿ª·¢»·¾³¡·Ìáµ½ÁË NetBeans ºÍ MinGW µÄÅäÖ㬵±Ê±¼ÇµÃºÃÏñÒÔǰд¹ý²½Ö裬¾ÍËæÊÖÂÔ¹ýÁË¡£½ñÌìÊÕµ½ÍøÓѵÄÌáÐѲŷ¢ÏÖÊÇÎҼǴíÁË£¬ÔÚÕâÀï²¹ÉÏ£¬Í¬Ê±Ð»Ð»Ä㣡
¡¡¡¡²½ÖèÈçÏ£º
ÏÂÔØ×Ô¶¯ MinGW °²×°³ÌÐò£¬Õâ¶Ô³õѧÕßÀ´ËµÊDZȽϷ½±ãµÄ·½Ê½£¬È±µã¾ÍÊÇÏÂÔØËÙ¶ÈÂýµÃ²»ÈçÎÏÅ£¡£
ÔËÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ