Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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
µVision Version 2.06
QUESTION
Do you have any examples of how to mix C and assembly?
ANSWER
The following example program shows how to mix C and assembly in your 8051 programs.
This example starts with a MAIN C function which calls a routine in assembly which then calls a C function.
The MAIN C module appears as follows:
extern void a_func (void);
void main (void)
{
a_func ();
}
The function a_func is an assembly routine:
NAME A_FUNC
?PR?a_func?A_FUNC SEGMENT CODE
EXTRN CODE (c_func)
PUBLIC a_func
RSEG ?PR?a_func?A_FUNC
a_func:
USING 0
LCALL c_func
RET
END
Note that this assembly routine calls c_func which is a C function:
void c_func (void)
{
}
The actual code for the assembly module was generated using the SRC pragma and the following C source file:
extern void c_func (void);
void a_func (void)
{
c_func ();
}
You may download C2ASM2C.ZIP from the Keil web site.
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, and (4) no graphics, including logos, available from this Server are used separate from accompanying text. Use for any other purpose is expressly prohibited by law, and may result in severe civil and criminal penalties. Violators will be


Ïà¹ØÎĵµ£º

¾­µäC/C++ÃæÊÔÌ⣨Èý£©

1) Ê²Ã´ÊÇÔ¤±àÒ룬ºÎʱÐèÒªÔ¤±àÒ룺×ÜÊÇʹÓò»¾­³£¸Ä¶¯µÄ´óÐÍ´úÂëÌå¡£
³ÌÐòÓɶà¸öÄ£¿é×é³É£¬ËùÓÐÄ£¿é¶¼Ê¹ÓÃÒ»×é±ê×¼µÄ°üº¬ÎļþºÍÏàͬµÄ±àÒëÑ¡Ïî¡£ÔÚÕâÖÖÇé¿öÏ£¬¿ÉÒÔ½«ËùÓаüº¬ÎļþÔ¤±àÒëΪһ¸öÔ¤±àÒëÍ·¡£
2) char * const p;
¡¡¡¡char const * p
¡¡¡¡const char *p ......

¾­µäC/C++ÃæÊÔÌ⣨Èý£©2

32)
¡¡¡¡int main()
¡¡¡¡{
¡¡¡¡¡¡int x=3;
¡¡¡¡¡¡printf("%d",x);
¡¡¡¡¡¡return 1;
¡¡¡¡}
¡¡¡¡Îʺ¯Êý¼ÈÈ»²»»á±»ÆäËüº¯Êýµ÷Óã¬ÎªÊ²Ã´Òª·µ»Ø1£¿
¡¡¡¡mianÖУ¬c±ê×¼ÈÏΪ0±íʾ³É¹¦£¬·Ç0±íʾ´íÎó¡£¾ßÌåµÄÖµÊÇijÖоßÌå³ö´íÐÅÏ¢
33) Òª¶Ô¾ø¶ÔµØÖ·0x100000¸³Öµ£¬ÎÒÃÇ¿ÉÒÔÓÃ(unsigned int*)0x100 ......

C±à³ÌʵÏÖhttpЭÒé


´ó¼Ò¶¼ºÜÊìϤHTTPЭÒéµÄÓ¦Óã¬ÒòΪÿÌì¶¼ÔÚÍøÂçÉÏä¯ÀÀ×Ų»ÉÙ¶«Î÷£¬Ò²¶¼ÖªµÀÊÇHTTPЭÒéÊÇÏ൱¼òµ¥µÄ¡£Ã¿´ÎÓÃthunderÖ®ÀàµÄÏÂÔØÈí¼þÏÂÔØÍøÒ³£¬µ±Óõ½ÄǸö“ÓÃthunderÏÂÔØÈ«²¿Á´½Ó”ʱ×ܾõµÃºÜÉñÆæ¡£
ºóÀ´ÏëÏ룬ÆäʵҪʵÏÖÕâЩÏÂÔØ¹¦ÄÜÒ²²¢²»ÄÑ£¬Ö»Òª°´ÕÕHTTPЭÒé·¢ËÍrequest£¬È»ºó¶Ô½ÓÊÕµ½µÄÊý¾Ý½øÐзÖÎö£¬Èç¹ûÒ ......

¹ØÓÚCµÄ˼¿¼


¹ØÓÚCµÄ˼¿¼
Cong Wang
May, 2006
Network Engineering Department
Institute of Post and Telecommunications, Xi'an, P.R.China
ÒýÑÔ
    CÓïÑÔ½áºÏÁË»ã±àµÄËùÓÐÍþÁ¦£¬ËüµÄ³éÏó³Ì¶ÈÅöÇɼÈÂú×ãÁ˳ÌÐòÔ±µÄÒªÇó, ÓÖÈÝÒ×ʵÏÖ¡£ÒòÆä¶ÀÌØµÄÁé»îÐÔºÍÇ¿´óµÄ¿ÉÒÆÖ²ÐÔ£¬ÏµÍ³³ÌÐòÔ±ºÍºÚ¿ÍÃǸüÊǶÔËüÖÓ°® ......

¡¾C\C++ÓïÑÔÈëÃÅÆª¡¿ »ù±¾Êý¾ÝÀàÐÍ

Ê×ÏÈ¡¢ÎÒÃÇ¿´32λµÄÕûÊý£ºint ¡¢unsigned int¡¢long¡¢unsigned long ¡£ÕâЩ¶¼ÊÇ»ù±¾ÀàÐÍ£¬Ã»ÓÐunsigned¹Ø¼ü×ÖµÄÊÇÓзûºÅµÄ£¬·´Ö®ÊÇÎÞ·ûºÅµÄ¡£»¹ÓбÈÈçDWORD¡¢ UINTÕâЩҲֻÊÇд±ðÃû£¨typedef£©¶øÒÑ¡£ÓзûºÅÕûÊýÖµµÃ×¢ÒâµÄÊÇʲô·¶Î§ÄÚÊÇÕýÊý£¬Ê²Ã´·¶Î§ÊǸºÊý¡£ÕâÑù¶ÔÓÚ¼Ó¼õÔËËã¡¢±È½ÏÔËËãµÈÓкܴó°ïÖú£¬·ñÔòºÜÈÝÒ×Òç³ö»òÕß± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ