As is Known to us,the function Main is the entry point of all programs.Therefore, we are usually neglecting all that we don't do,which makes us not understanding it more clearly.Now there is a sample arm program which will provide something that opration system usually do.
asm:
IMPORT main
area test,CODE,READONLY
ENTRY
bl start
start
bl main
C:
#define rGPBCON (*(volatile unsigned *)0x56000010) //Port B control
#define rGPBDAT (*(volatile unsigned *)0x56000014) //Port B data
#define rGPBUP (*(volatile unsigned *)0x56000018) //Pull-up control B
int main(int argc, char *argv[])
{
unsigned int temp = 0x0e;
rGPBCON = 0x00555555;
rGPBUP = 0xffff;
rGPBDAT = 0XE1F;
return 0;
}
The code very sample,but it is very useful. ......
ÎÒÃdz£ËµµÄ×óÖµlvalueºÍÓÒÖµrvalue²¢²»¼òµ¥µØÒâζ×Å×óÓÒÇø±ð£¬ËüµÄÔʼ¶¨ÒåÈçÏ£º
Definition:
C and C++ have the notion of lvalues and rvalues associated with
variables and constants. The rvalue is the data value of the variable,
that is, what information it contains. The "r" in rvalue can be thought of as "read"
value
. A variable also has an associated lvalue. The "l" in lvalue can be though of as location
,
meaning that a variable has a location that data or information can be
put into. This is contrasted with a constant. A constant has some data
value, that is an rvalue. But, it cannot be written to. It does not
have an lvalue.
Another view of these terms is that objects with an rvalue, namely a
variable or a constant can appear on the right hand side of a
statement. They have some data value that can be manipulated. Only
objects with an lvalue, such as variable, can appear on the left hand
side of a statement. An object must be addressable ......
ÎÒÃdz£ËµµÄ×óÖµlvalueºÍÓÒÖµrvalue²¢²»¼òµ¥µØÒâζ×Å×óÓÒÇø±ð£¬ËüµÄÔʼ¶¨ÒåÈçÏ£º
Definition:
C and C++ have the notion of lvalues and rvalues associated with
variables and constants. The rvalue is the data value of the variable,
that is, what information it contains. The "r" in rvalue can be thought of as "read"
value
. A variable also has an associated lvalue. The "l" in lvalue can be though of as location
,
meaning that a variable has a location that data or information can be
put into. This is contrasted with a constant. A constant has some data
value, that is an rvalue. But, it cannot be written to. It does not
have an lvalue.
Another view of these terms is that objects with an rvalue, namely a
variable or a constant can appear on the right hand side of a
statement. They have some data value that can be manipulated. Only
objects with an lvalue, such as variable, can appear on the left hand
side of a statement. An object must be addressable ......
×ªÔØ×Ô£ºhttp://www.cnblogs.com/eddyshn/archive/2009/11/23/1608823.html
VC±àÒëÑ¡Ïî ¶àÏß³Ì(/MT)
¶àÏ̵߳÷ÊÔ(/MTd)
¶àÏß³Ì DLL (/MD)
¶àÏ̵߳÷ÊÔ DLL (/MDd)
C ÔËÐÐʱ¿â ¿âÎļþ
Single thread(static link) ML libc.lib
Debug single thread(static link) MLd libcd.lib
MultiThread(static link) MT libcmt.lib
Debug multiThread(static link) MTd libcmtd.lib
MultiThread(dynamic link) MD msvert.lib
Debug multiThread(dynamic link) MDd msvertd.lib
3. ¸÷ÖÖ C ÔËÐÐʱ¿âµÄÇø±ð
£¨ 1 £©¾²Ì¬Á´½ÓµÄµ¥Ï߳̿â
¾²Ì¬ ......
×ªÔØ×Ô£ºhttp://www.cnblogs.com/chio/archive/2007/11/26/972152.html
CRTÔÏÈÊÇÖ¸Microsoft¿ª·¢µÄC Runtime Library£¬ÓÃÓÚ²Ù×÷ϵͳµÄ¿ª·¢¼°ÔËÐС£ºóÀ´ÔÚ´Ë»ù´¡ÉÏ¿ª·¢ÁËC++ Runtime Library£¬ËùÒÔÏÖÔÚCRTÊÇÖ¸Microsoft¿ª·¢µÄC/C++ Runtime Library¡£ÔÚVCµÄCRT/SRCĿ¼Ï£¬¿ÉÒÔ¿´µ½CRTµÄÔ´Â룬²»½öÓÐCµÄ£¬Ò²ÓÐC++µÄ¡£
CRTÔÏȵÄÄ¿µÄ¾ÍÊÇÖ§³Ö²Ù×÷ϵͳµÄÔËÐС£ÒòΪWindows²Ù×÷ϵͳ³ý»ã±à²¿·ÖÍ⣬¶¼ÊÇÓÃC/C++±àдµÄ£¬ËùÒÔÄں˼°Ðí¶à¹Ø¼ü·þÎñ¶¼ÔÚCRTÉÏÔËÐУ¨ËüÃǶ¼²ÉÓÃdll¼¼Êõ¶¯Ì¬Á´½Ó£©¡£´ËÍ⣬Óà VC±àдµÄC/C++³ÌÐòÒ²Óõ½ËüÃÇ£¨¿ÉÒÔ¶¯Ì¬Á´½Ó£¬Ò²¿ÉÒÔ¾²Ì¬Á´½Ó£¬Ç°ÕßÔËÐÐʱÐèҪϵͳÖÐÒѰ²×°CRTµÄdll£¬ºóÕß²»ÐèÒª£©¡£¿ÉÒÔ˵£¬CRT¾ÍÊÇ Microsoft±àдWindowsʱʹÓõĵͲãÀà¿â¡£È»ºó£¬ËüÓÖ±»µ±×÷C++±ê×¼¿âµÄÒ»¸öʵÏÖ°üº¬ÔÚÁËVCϵÁÐÖУ»ÎÒÃÇÔÚVCÖÐʹÓõÄC++±ê×¼¿â£¬Æäʵ¾ÍÊÇCRTµÄÒ»¸öÕæ×Ó¼¯£¨ÉÙÁËC++±ê×¼Ëù²»°üº¬µÄ´úÂë£¬ÌØ±ðÊÇ´óÁ¿µÄµÍ²ãC´úÂ룩
ÖÁÓÚCRTÓëWINDOWS APIµÄ¹ØÏµ£¬ÓëÐí¶àÈËÀí½âµÄÏà·´£¬WINDOWS API×÷ΪWindowsµÄÒ»²¿·Ý£¬ÊÇÔÚCRTµÄ»ù´¡ÉÏ¿ª·¢µÄ¡£Äã¿ÉÒÔ½«Windows£¨¼°ÆäAPI£©¿´×÷Ò»¸ö ......
extern "C" ÊÇ C++ ±àÒëÆ÷Ö§³ÖµÄÒ»ÖÖÁ´½Óָʾ·û£¨linkage directive£©£¬Ëü±íʾÓÉÆäÉùÃ÷µÄº¯ÊýʹÓà C ÓïÑԵķ½Ê½±àÒëºÍÁ´½Ó¡£
C ºÍ C++ ¶Ôº¯Êý±àÒëºó²úÉúµÄ·ûºÅÃûÊDz»Ò»ÑùµÄ¡£¼ÙÉèÒ»¸öº¯ÊýµÄÔÐÍΪ:
void foo(int x, int y);
ÓÉ C ±àÒëÆ÷±àÒëºó²úÉúµÄ·ûºÅÃûΪ _foo£¬¶ø C++ ÓÉÓÚÖ§³ÖÖØÔØµÄÐèÒª£¬±àÒëºóµÄ·ûºÅÃûΪ _foo_int_int ¡£µ±¸Ãº¯ÊýÓÉ extern "C" ÐÞÊκó£¬C++ ±àÒëÆ÷»á°´ C µÄ¹æÔò°ÑËü±àÒë³É _foo¡£
extern "C" µÄÓ÷¨ÓÐÁ½ÖÖ¸ñʽ£º
µ¥Ò»Óï¾äÐÎʽµÄÁ´½Óָʾ·û£º
extern "C" void foo(int, int);
¸´ºÏÓï¾äÐÎʽµÄÁ´½Óָʾ·û£º
extern "C" {
void foo(int, int);
void bar(int, int);
}
extern "C" µäÐ͵ÄÓ÷¨ÊÇÀàËÆÏÂÃæµÄ¸ñʽ°üº¬ÔÚÒ»¸öÍ·ÎļþÖУº
#ifdef __cplusplus
extern “C” {
#endif
void fun(void);
… …
#ifdef __cplusplus
}
#endif
ÕâÑùÉùÃ÷µÄÍ·ÎļþÓÐÒÔÏÂÌØµã£º
1. ÄÜͬʱ֧³Ö C »ò C++ ±àÒëÆ÷¡££¨C ±àÒëÆ÷²»Ö§³Ö extern "C" ·ûºÅ£¬ËùÒÔÓÉ __cplusplus ºê±£»¤£©
2. Í·ÎļþÖÐÉùÃ÷µÄº¯Êý¶¼°´ÕÕ C µÄ·½Ê½±àÒëºÍÁ´½Ó¡£
ÓÉÉÏÃæÁ½¸öÌØµã¿ ......
½ñÌìΪÁ˳¹µ×¸ã¶¨Ò»¸ö¹ØÓÚcÖÐÊý×é³õʼ»¯ºÍÉùÃ÷²»Í¬Çé¿öÏ£¬±ÈÈçÖ»ÉùÃ÷Ò»¸öÊý×échar str[20];ÄÇôÕâstrÀïÃæÊÇʲôÄÚÈÝÄØ£¿ÎÒÓÃvc6++£¬debugÏ¿´µ½¶¼ÊÇ-56¶öascÂ룬ºóÀ´Çë½ÌÁËÒ»¸ö»ªÎªµÄ´óÅ££¬Ëû˵ °´ÕÕÀíÂÛÀ´ËµÀïÃæµÄÄÚÈݶ¼ÊÇÓпÉÄܵģ¬ÕâºÍ½Ð×ö“ÔàÄÚ´æ”»òÕß½Ð×ö“Ò°Êý×锡£ºÃÁ˵ÚÒ»¸öÎÊÌâ¸ã¶®ÁË¡£
µÚ¶þ¸öÎÊÌâ memsetµÄÎÊÌ⣬֮ǰÔÚÍò³¼½âÎöfastÐÒéµÄʱºò£¬ÒòΪÊǸÕÈëÃÅC£¬±¡ºÉÀÏ´ó¸øÎÒ˵һ°ãÉùÃ÷ÁËÊý×éºð¶¼ÓÃmemsetһϡ£µ±Ê±²»ÊǺÜÀí½â£¬µ«ÊÇÏÖÔÚÕâ¾ä»°ÖªµÀÁË¡£
¾ÙÀýһϣº
±ÈÈç char str[20];
¶ÔÓÚstrµÄÁ¬Ðø20¸öµ¥Ôª¶¼ÊÇËæÒâµÄÖµ
char str[20] = "Hello World!";
Õâ¸öʱºò¶ÔÓÚstr£¬Ç°ÃæµÄ×Ö·ûÊÇ Hello World ½ô½Ó×ÅÊÇ'\0'£»Ò²¾ÍÊÇ˵str¾¡¹ÜºóÃæÃ»Óõ½µÄÄÚ´æµ¥ÔªÒ²ÊÇ0ÁË£¬²»ÊÇËæÒâÖµ
Èç¹û memset(str, 0, sizeof(str));
ÄÇôÕâ¾ä»°Ò²ÊǰÑstrµÄǰsizeof(str)¸öµ¥Ôª¶¼¸³Öµ¸ø0
Èç¹ûÊÇmemset(str, 1, 10)
ÄÇôÕâ¾ä»°ÊǰÑstrµÄǰ10¸öµ¥Ôª¶¼¸³Öµ¸ø1ÁË£¬ÆäÓàµÄ»¹ÊÇ ËæÒâÖµ
¼Ç¼һÏ£¡ ......