C\C++º¯Êýµ÷Óõļ¸ÖÖ·½Ê½
µ÷Óú¯Êýʱ£¬¼ÆËã»ú³£ÓÃÕ»À´´æ´¢´«µÝ¸øº¯ÊýµÄ²ÎÊý¡£
Õ»ÊÇÒ»ÖÖÏȽøºó³öµÄÊý¾Ý½á¹¹£¬Õ»ÓÐÒ»¸ö´æ´¢Çø¡¢Ò»¸öÕ»¶¥Ö¸Õë¡£Õ»¶¥Ö¸ÕëÖ¸Ïò¶ÑÕ»ÖеÚÒ»¸ö¿ÉÓõÄÊý¾ÝÏ±»³ÆΪջ¶¥£©¡£Óû§¿ÉÒÔÔÚÕ»¶¥ÉÏ·½ÏòÕ»ÖмÓÈëÊý¾Ý£¬Õâ¸ö²Ù×÷±»³ÆΪѹջ(Push)£¬Ñ¹Õ»ÒÔºó£¬Õ»¶¥×Ô¶¯±ä³ÉмÓÈëÊý¾ÝÏîµÄλÖã¬Õ»¶¥Ö¸ÕëÒ²ËæÖ®Ð޸ġ£Óû§Ò²¿ÉÒÔ´Ó¶ÑÕ»ÖÐÈ¡×ßÕ»¶¥£¬³ÆΪµ¯³öÕ»(pop)£¬µ¯³öÕ»ºó£¬Õ»¶¥ÏµÄÒ»¸öÔªËرä³ÉÕ»¶¥£¬Õ»¶¥Ö¸ÕëËæÖ®Ð޸ġ£º¯Êýµ÷ÓÃʱ£¬µ÷ÓÃÕßÒÀ´Î°Ñ²ÎÊýѹջ£¬È»ºóµ÷Óú¯Êý£¬º¯Êý±»µ÷ÓÃÒÔºó£¬ÔÚ¶ÑÕ»ÖÐÈ¡µÃÊý¾Ý£¬²¢½øÐмÆËã¡£º¯Êý¼ÆËã½áÊøÒԺ󣬻òÕßµ÷ÓÃÕß¡¢»òÕߺ¯Êý±¾ÉíÐ޸ĶÑÕ»£¬Ê¹¶ÑÕ»»Ö¸´Ô×°¡£
ÔÚ²ÎÊý´«µÝÖУ¬ÓÐÁ½¸öÖØÒªµÄÎÊÌâ±ØÐëÒªÃ÷ȷ˵Ã÷£º
1. µ±²ÎÊý¸öÊý¶àÓÚÒ»¸öʱ£¬°´ÕÕʲô˳Ðò°Ñ²ÎÊýѹÈë¶ÑÕ»£»
2. º¯Êýµ÷Óúó£¬ÓÉËÀ´°Ñ¶ÑÕ»»Ö¸´Ô×´¡£
Ôڸ߼¶ÓïÑÔÖУ¬¾ÍÊÇͨ¹ýº¯ÊýµÄµ÷Ó÷½Ê½À´ËµÃ÷ÕâÁ½¸öÎÊÌâµÄ¡£³£¼ûµÄµ÷Ó÷½Ê½ÓУº
stdcall
cdecl
fastcall
thiscall
thiscall
naked call
ÏÂÃæ¾Í·Ö±ð½éÉÜÕ⼸ÖÖµ÷Ó÷½Ê½£º
1. stdcall
stdcallµ÷Ó÷½Ê½ÓÖ±»³ÆΪPascalµ÷Ó÷½Ê½¡£ÔÚMicrosoft C++ϵÁеÄC/C++±àÒëÆ÷ÖУ¬Ê¹ÓÃPASCALºê£¬WINAPIºêºÍCALLBACKºêÀ´Ö¸¶¨º¯ÊýµÄµ÷Ó÷½Ê½Îªstdcall¡£
stdcallµ÷Ó÷½Ê½µÄº¯ÊýÉùÃ÷Ϊ£º
int _stdcall function(int a, int b);
stdcallµÄµ÷Ó÷½Ê½Òâζ×Å£º
£¨1£© ²ÎÊý´ÓÓÒÏò×óÒ»´ÎѹÈë¶ÑÕ»
£¨2£© Óɱ»µ÷Óú¯Êý×Ô¼ºÀ´»Ö¸´¶ÑÕ»
£¨3£© º¯ÊýÃû×Ô¶¯¼ÓÇ°µ¼Ï»®Ïߣ¬ºóÃæ½ô¸ú×ÅÒ»¸ö@,Æäºó½ô¸ú×ŲÎÊýµÄ³ß´ç
ÉÏÃæÄǸöº¯Êý·Òë³É»ã±àÓïÑÔ½«±ä³É£º
push b ÏÈѹÈëµÚ¶þ¸ö²ÎÊý
push a ÔÙѹÈëµÚÒ»¸ö²ÎÊý
call function µ÷Óú¯Êý
ÔÚ±àÒëʱ£¬´Ëº¯ÊýµÄÃû×Ö±»·ÒëΪ_function@8
2. cdecl
cdeclµ÷Ó÷½Ê½ÓÖ³ÆΪCµ÷Ó÷½Ê½£¬ÊÇCÓïÑÔȱʡµÄµ÷Ó÷½Ê½£¬ËüµÄÓ﷨Ϊ£º
int function(int a, int b) // ²»¼ÓÐÞÊηû¾ÍÊÇCµ÷Ó÷½Ê½
int _cdecl function(int a, int b) // Ã÷È·Ö¸¶¨ÓÃCµ÷Ó÷½Ê½
cdeclµÄµ÷Ó÷½Ê½¾ö¶¨ÁË£º
£¨1£© ²ÎÊý´ÓÓÒÏò×óÒÀ´ÎѹÈë¶ÑÕ»
£¨2£© Óɵ÷ÓÃÕ߻ָ´¶ÑÕ»
£¨3£© º¯ÊýÃû×Ô¶¯¼ÓÇ°µ¼Ï»®Ïß
ÓÉÓÚÊÇÓɵ÷ÓÃÕßÀ´»Ö¸´¶ÑÕ»£¬Òò´ËCµ÷Ó÷½Ê½ÔÊÐíº¯ÊýµÄ²ÎÊý¸öÊýÊDz»¹Ì¶¨µÄ£¬ÕâÊÇCÓïÑÔµÄÒ»´óÌØÉ«¡£
´Ë·½Ê½µÄº¯Êý±»·ÒëΪ£º
push b // ÏÈѹÈëµÚ¶þ¸ö²ÎÊý
push a // ÔÚѹÈëµÚÒ»¸ö²ÎÊý
call funtion // µ÷Óú¯Êý
add
Ïà¹ØÎĵµ£º
Ç°Ãæ½éÉܵĸ÷ÖÖÔËË㶼ÊÇÒÔ×Ö½Ú×÷Ϊ×î»ù±¾Î»½øÐеġ£ µ«Ôںܶàϵͳ³ÌÐòÖг£ÒªÇóÔÚλ(bit)Ò»¼¶½øÐÐÔËËã»ò´¦Àí¡££ÃÓïÑÔÌṩÁËλÔËËãµÄ¹¦ÄÜ£¬ÕâʹµÃ£ÃÓïÑÔÒ²ÄÜÏñ»ã±àÓïÑÔÒ»ÑùÓÃÀ´±àдϵͳ³ÌÐò¡£
12.1 λÔËËã·û£ÃÓïÑÔÌṩÁËÁùÖÖλÔËËã·û£º
& °´ ......
ÎÒÊÇÒ»¸ö¼ÆËã»úרҵµÄ±¾¿ÆÉú£¬ÏÖÔÚÎÒÃǸոÕѧÍêÁËÊý¾Ý½á¹¹¡£¾Ý˵Êý¾Ý½á¹¹¶ÔÓÚÎÒÃDZà³ÌºÜÖØÒª£¬¿ÉÊÇÎÒÏÖÔÚ²»ÖªÔõô°ÑÊý¾Ý½á¹¹ºÍCÓïÑÔ½áºÏÆðÀ´£¬ÒÔ±ã¸üºÃµÄ½øÐÐcÓïÑÔ±à³Ì¡£ÓÐÄÄλ¸ßÊÖÖ¸µãÒ»¶þ£¬ÔÚÏ¸м¤²»¾¡£¡
......
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch£¨Ê±¼äµã£©£¬cl ......
תÔØÓÚÕâÀhttp://www.programfan.com/article/showarticle.asp?id=2798
²»Ì«¶®ÈçºÎ¶ÔÔËÓÃc++µÄʱ¼äº¯ÊýµÄÅóÓѶ࿴¿´°É¡£
*************************ÆÓËصķָîÏß**********************************
׫ÎÄ/ÖÜÏè
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê ......
CÓïÑÔ»ù±¾¹¦½Ì³ÌϵÁÐ(3) - ¿ìËٵĺ¯Êýµ÷ÓÃ
ÎÒÓÖÀ´ÁË£¬½ñÌ쿲¿²º¯Êýµ÷ÓõÄÎÊÌâ¡£º¯ÊýÄÄÀﶼÓУ¬Ð¡µÄ³ÌÐòÒ»Á½¸öº¯Êý£¬´óµÄ³ÌÐò³É°ÙÉÏǧ¸öº¯Êý¡£¼´Ê¹ÔÚÓÎÏ·µÄ¹Ø¼üÑ»·ÖУ¬µ÷Óü¸Ê®¸öº¯ÊýÒ²ÊǺܳ£¼ûµÄ¡£ËùÒÔº¯Êýµ÷ÓôúÂëµÄÖÊÁ¿£¬Ôںܴó³Ì¶ÈÉÏÓ°Ïì×ÅÓÎÏ·µÄÖÊÁ¿¡£
»¹ÊÇÏÈ˵×î»ù±¾µÄ´úÂë·ç¸ñÎÊÌâ¡£Ê×ÏÈ£¬¶ÔÓÚº¯ÊýµÄ²ÎÊý£¨ÌرðÊÇ ......