ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡
windows»·¾³ÏÂ32λ»ã±àÓïÑÔ³ÌÐòÉè¼Æ-µÚ1²¿·Ö
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿! Èç¹û±¾ÊéûÓÐÔĶÁÍ꣬ÏëÏ´μÌÐø½Ó×ÅÔĶÁ£¬¿ÉʹÓÃÉÏ·½ "Êղص½ÎÒµÄä¯ÀÀÆ÷" ¹¦ÄÜ ºÍ "¼ÓÈëÊéÇ©" ¹¦ÄÜ£¡
¡¡¡¡
µÚ3Õ¡¡Ê¹ÓÃMASM
3¡£1¡¡Win32»ã±àÔ´³ÌÐòµÄ½á¹¹£¨1£©
¡¡¡¡¡¡¡¡¡¡
¡¡
¡¡
¾¹ýµÚ2ÕµÄ×¼±¸¹¤×÷£¬ÏàÐÅ´ó¼Ò¶¼ÒѾ½¨ºÃÁËWin32»ã±àµÄ¹¤×÷»·¾³£¬²¢ÒѾ¿ÉÒÔ±àÒë³ÌÐòÁË£¬ÏÖÔÚÈÃÎÒÃÇÀ´±àÒëËù´ø¹âÅ̵ÄChapter03HelloWorldĿ¼ÏµÄHello¡¡World³ÌÐò¡£ÕâÊÇÒ»¸öÏ൱СµÄ³ÌÐò£¬¾ÍºÍDOSʱ´úϾµäµÄHello¡¡World³ÌÐòÒ»Ñù£¬²¢Ã»ÓÐÉ漰ϵͳÖкܶàµÄ¶«Î÷£¬ÉõÖÁÁ¬WindowsϵͳÖлù±¾µÄÏûÏ¢Çý¶¯»úÖÆҲûÓп´µ½£¬ËüÖ»ÊǼòµ¥µØµ¯³öÒ»¸öÏûÏ¢¿ò£¬ÔÚÉÏÃæÏÔʾÁËÒ»¾ä¡°Hello£¬World£¡¡±£¬²¢ÔÚÎÄ×ÖµÄÏÂÃæÏÔʾÁËÒ»¸ö¡°È·¶¨¡±°´Å¥£¬¾ÍÍ£ÔÚÄÇÀïÁË£¬µ±Óû§°´Ï¡°È·¶¨¡±°´Å¥£¬³ÌÐò¾ÍÍ˳öÁË£¬Í¬Ê±ÏûÏ¢¿òÏûʧ¡£Õâ¸ö³ÌÐòÔËÐеĽá¹ûÈçͼ3¡£1Ëùʾ¡£
µ«ÕâÑùÒ»¸öС³ÌÐò´Ó½á¹¹À´¿´£¬È´¡°ÂéȸËäС£¬ÎåÔà¾ãÈ«¡±£¬ÓÃËüÀ´¾ÙÀý˵Ã÷Win32»ã±àÔ´³ÌÐòµÄ¿ò¼ÜÊÇ×îºÏÊʲ»¹ýµÄÁË£¬±¾Õ½«´ÓÕâ¸ö³ÌÐò³ö·¢£¬Ì½ÌÖMASMÔÚWin32»ã±àÖеÄÓ÷¨£¬ÓÉÓÚƪ·ùËùÏÞ£¬ÄÚÈÝÖ»Éæ¼°MASMÔÚWin32±à³ÌÖг£ÓõIJ¿·Ö¡£
3¡£1¡¡¡¡Win32»ã±àÔ´³ÌÐòµÄ½á¹¹
ÈκÎÖÖÀàµÄÓïÑÔ£¬×ÜÊÇÓлù±¾µÄÔ´³ÌÐò½á¹¹¹æ·¶£¬ÔÚÌÖÂÛCÓïÑÔµÄÊéÖУ¬´ó¼Ò¶¼»á¼ÇµÃÕâ¸ö·Ç³£¾µäµÄHello¡¡World³ÌÐò£º
#include¡¡
main£¨£©
£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡printf£¨¡¨Hello£»¡¡worldn¡¨£©£»
£ý
ÏñÕâÑùÒ»¸ö³ÌÐò£¬¾Í˵Ã÷ÁËCÓïÑÔÖÐ×î»ù±¾µÄ¸ñʽ£¬main£¨£©ÖеÄÀ¨ºÅºÍÏÂÃæµÄ»¨À¨ºÅ˵Ã÷ÁËÒ»¸öº¯ÊýµÄ¶¨Òå·½·¨£¬printfÓï¾ä˵Ã÷ÁËÒ»¸öº¯ÊýµÄµ÷Ó÷½·¨£¬µ÷Óú¯ÊýÓï¾äºóÃæµÄ·ÖºÅÒ²ÊÇ»ù±¾µÄ¸ñʽ¡£CÊÇÒ»Öָ߼¶ÓïÑÔ£¬ÔÚCÔ´³ÌÐòÖУ¬²»±ØΪ¶ÑÕ»¶Î¡¢Êý¾Ý¶ÎºÍ´úÂë¶ÎµÄ¶¨Òå¶øµ£ÐÄ£¬±àÒëÆ÷»á°Ñ³ÌÐòÖеÄ×Ö·û´®ºÍÓï¾ä´úÂë·Ö±ð·Åµ½ËüÃǸÃÈ¥µÄµØ·½£¬³ÌÐò¿ªÊ¼Ö´ÐеÄʱºòÒ²»á×Ô¼ºÕÒµ½main£¨£©º¯Êý¡£¶ø»ã±àÊǵͼ¶ÓïÑÔ£¬±ØÐëΪËùÓеĶ«Î÷ÕÒµ½ËüÃǸÃÈ¥µÄµØ·½£¬ËùÒÔÔÚDOSµÄ»ã±àÖУ¬Hello¡¡WorldÓÖ³¤³ÉÁËÕâÑùÒ»¸±Ä£Ñù£º
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡¶ÑÕ»¶Î
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
stack¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡segment¡¡stack
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡db¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡100¡¡dup¡¡£¨£¿£©
stack¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ends
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡Êý¾Ý¶Î
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
data¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡segment
szHello¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡db¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'Hello£»¡¡world'£»0dh£»0ah£»''
data¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ends
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡´úÂë¶Î
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
code¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡segment
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡assume¡¡¡¡¡¡¡¡cs£ºcode£»ds£ºdata£»ss£ºstack
start£º
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡ax£»data
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡ds£»ax
¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡ah£»9
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡dx£»offset¡¡szHello
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int¡¡¡¡¡¡¡¡¡¡¡¡¡¡21h
¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡ah£»4ch
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int¡¡¡¡¡¡¡¡¡¡¡¡¡¡21h
code¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ends
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡end¡¡¡¡¡¡¡¡¡¡¡¡¡¡start
ÔÚÕâ¸öÔ´³ÌÐòÖУ¬stack¶ÎΪ¶ÑÕ»ÕÒÁ˸ö¼Ò£¬hello¡¡world×Ö·û´®ÔòÅܵ½Êý¾Ý¶ÎÖÐÈ¥ÁË£¬´úÂëÔò·ÅÔÚ´úÂë¶ÎÖУ¬³ÌÐòµÄ¿ªÊ¼Óï¾ä±ØÐëÓÉ×îºóÒ»¾äend¡¡startÀ´ËµÃ÷Ó¦¸Ã´ÓstartÕâ¸ö±êºÅ¿ªÊ¼Ö´ÐУ¬Õû¸ö³ÌÐòÔÚʹÓùýDOS»ã±àµÄ³ÌÐòÔ±ÑÛÀïÊǷdz£µÄÊìϤ¡£
µ½ÁËWin32»ã±àµÄʱºò£¬³ÌÐòµÄ»ù±¾½á¹¹»¹ÊÇÈç´Ë£¬ÏÈÀ´¿´Ò»¿´Õâ¸ö¿´ÆðÀ´ºÜÐÂÏʵÄWin32µÄHello¡¡world³ÌÐò£º
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£386
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£model¡¡flat£»stdcall
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡option¡¡casemap£ºnone
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡Include¡¡Îļþ¶¨Òå
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡windows¡£inc
include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡user32¡£inc
includelib¡¡¡¡¡¡¡¡¡¡¡¡user32¡£lib
include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡kernel32¡£inc
includelib¡¡¡¡¡¡¡¡¡¡¡¡kernel32¡£lib
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡Êý¾Ý¶Î
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£data
¡¡
szCaption¡¡¡¡¡¡¡¡¡¡¡¡¡¡db¡¡¡¡¡¡¡¡¡¡¡¡'A¡¡MessageBox¡¡£¡'£»0
szText¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡db¡¡¡¡¡¡¡¡¡¡¡¡'Hello£»¡¡World¡¡£¡'£»0
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
£»¡¡´úÂë¶Î
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡de
start£º
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡MessageBox£»NULL£»offset¡¡szText£»offset¡¡szCaption£»MB_OK
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡ExitProcess£»NULL
£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡end¡¡¡¡¡¡¡¡¡¡start
ÔõôÑù£¬¿´À´ºÍÉÏÃæµÄCÒÔ¼°DOS»ã±àÓÖ²»Í¬ÁË°É£¡µ«´Óinclude£¬¡£dataºÍdeµÈÓï¾ä¡°¹ËÃû˼Ò塱ҲÄÜ¿´³öÒ»µãÃçÍ·À´£¬includeÓ¦¸Ã¾ÍÊÇ°üº¬±ðµÄÎļþ£¬¡£dataÏë±ØÊÇÊý¾Ý¶Î£¬deÓ¦¸Ã¾ÍÊÇ´úÂë¶ÎÁË°É£¡½ÓÏÂÀ´Í¨¹ýÕâ¸öÀýÁ˳ÌÐòÖð¶Î½éÉÜWin32»ã±à³ÌÐòµÄ½á¹¹¡£
3¡£1¡£1¡¡¡¡Ä£Ê½¶¨Òå
³ÌÐòµÄµÚÒ»²¿·ÖÊÇģʽºÍÔ´³ÌÐò¸ñʽµÄ¶¨ÒåÓï¾ä£º
¡¡¡¡¡¡¡¡¡£386
¡¡¡¡¡¡¡¡¡£model¡¡flat£»stdcall
¡¡¡¡¡¡¡¡option¡¡casemap£ºnone
ÕâЩָÁÒåÁ˳ÌÐòʹÓõÄÖ¸Á¡¢¹¤×÷ģʽºÍ¸ñʽ¡£
1¡£¡¡Ö¸¶¨Ê¹ÓõÄÖ¸Á
¡£386Óï¾äÊÇ»ã±àÓïÑÔµÄαָÁËüÔڵͰ汾µÄºê»ã±àÖоÍÒѾ´æÔÚ£¬ÀàËƵÄÖ¸ÁÓУº¡£8086£¬¡£186£¬¡£286£¬¡£386/¡£386p£¬¡£486/¡£486pºÍ¡¡¡£586/¡£586pµÈ£¬ÓÃÓÚ¸æËß±àÒëÆ÷ÔÚ±¾³ÌÐòÖÐʹÓõÄÖ¸Á¡£ÔÚDOSµÄ»ã±àÖÐĬÈÏʹÓõÄÊÇ8086Ö¸Á£¬ÄÇʱºòÈç¹ûÔÚÔ´³ÌÐòÖÐдÈë80386ËùÌØÓеÄÖ¸Áî»òʹÓÃ32λµÄ¼Ä´æÆ÷¾Í»á±¨´í£¬ÎªÁËÔÚDOS»·¾³Ï½øÐб£»¤Ä£Ê½±à³Ì»ò½öΪÁËʹÓÃ32λ¼Ä´æÆ÷£¬³£ÔÚDOSµÄ»ã±àÖÐʹÓá¡¡£386À´¶¨Òå¡£Win32»·¾³¹¤×÷ÔÚ80386¼°ÒÔÉϵĴ¦ÀíÆ÷ÖУ¬ËùÒÔÕâÒ»¾ä¡¡¡£386ÊDZز»¿ÉÉٵġ£
ºóÃæ´øpµÄαָÁîÔò±íʾ³ÌÐòÖпÉÒÔʹÓÃÌØȨָÁÈ磺
¡¡¡¡¡¡¡¡mov¡¡cr0£»eax
ÕâÒ»ÀàÖ¸Áî±ØÐëÔÚÌØȨ¼¶0ÉÏÔËÐУ¬Èç¹ûÖ»Ö¸¶¨¡¡¡£386£¬ÄÇôʹÓÃÆÕͨµÄÖ¸ÁîÊÇ¿ÉÒԵģ¬±àÒëʱµ½ÕâÒ»¾ä¾Í»á±¨´í£¬Èç¹ûÎÒÃÇҪдµÄ³ÌÐòÊÇVxDµÈÇý¶¯³ÌÐò£¬ÖмäÒªÓõ½ÌØȨָÁÄÇô±ØÐ붨Òå¡¡¡£386p£¬ÔÚÓ¦ÓóÌÐò¼¶±ðµÄWin32±à³ÌÖУ¬³ÌÐò¶¼ÊÇÔËÐÐÔÚÓÅÏȼ¶3ÉÏ£¬²»»áÓõ½ÌØȨָÁֻÐ趨Òå¡¡¡£386¾Í¹»ÁË¡£80486ºÍPentium´¦ÀíÆ÷Ö¸ÁîÊÇ80386´¦ÀíÆ÷Ö¸ÁîµÄ³¬¼¯£¬Í¬ÑùµÀÀí£¬Èç¹û³ÌÐòÖÐÒªÓÃ80486´¦ÀíÆ÷»òPentium´¦ÀíÆ÷µÄÖ¸ÁÔò±ØÐ붨Òå¡¡¡£486»ò¡¡¡£586¡£ÁíÍ⣬Intel¹«Ë¾µÄ80x86ϵÁд¦ÀíÆ÷´ÓPentium¡¡MMX¿ªÊ¼Ôö¼ÓÁËMMXÖ¸Á£¬ÎªÁËʹÓÃMMXÖ¸Á³ýÁ˶¨Òå¡¡¡£586Ö®Í⣬»¹Òª¼ÓÉÏÒ»¾ä¡¡¡£mmxαָÁ
¡¡¡¡¡¡¡¡¡£586
¡¡¡¡¡¡¡¡¡£mmx
¡¡
À´Ô´£ºµç×Ó¹¤Òµ³ö°æÉç¡¡×÷ÕߣºÂÞÔƱò¡¡ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡
µÚ3Õ¡¡Ê¹ÓÃMASM
3¡£1¡¡Win32»ã±àÔ´³ÌÐòµÄ½á¹¹£¨2£©
¡¡¡¡¡¡¡¡
2¡£¡¡¡£modelÓï¾ä
¡£modelÓï¾äÔڵͰ汾µÄºê»ã±àÖÐÒѾ´æÔÚ£¬ÓÃÀ´¶¨Òå³ÌÐò¹¤×÷µÄģʽ£¬ËüµÄʹÓ÷½·¨ÊÇ£º
¡£model¡¡ÄÚ´æģʽ£§£¬ÓïÑÔģʽ£§£§£¬ÆäËûģʽ£§
ÄÚ´æģʽµÄ¶¨ÒåÓ°Ïì×îºóÉú³ÉµÄ¿ÉÖ´ÐÐÎļþ£¬¿ÉÖ´ÐÐÎļþµÄ¹æÄ£´ÓСµ½´ó£¬¿ÉÒÔÓкܶàÖÖÀàÐÍ£¬ÔÚDOSµÄ¿ÉÖ´ÐгÌÐòÖУ¬ÓÐÖ»Óõ½64¡¡KBµÄ¡¡Îļþ£¬Ò²Óдó´óССµÄ¡¡¡£exeÎļþ¡£µ½ÁËWin32»·¾³Ï£¬ÓÖÓÐÁË¿ÉÒÔÓÃ4¡¡GBÄÚ´æµÄPE¸ñʽ¿ÉÖ´ÐÐÎļþ£¬±àд²»Í¬ÀàÐ͵ĿÉÖ´ÐÐÎļþÒªÓá¡¡£modelÓï¾ä¶¨Ò岻ͬµÄ²ÎÊý£¬¾ßÌåÈç±í3¡£1Ëùʾ¡£
±í3¡£1¡¡¡¡ÄÚ´æģʽ
Ä£¡¡¡¡¡¡¡¡Ê½
¡¡ÄÚ¡¡´æ¡¡Ê¹¡¡Óá¡·½¡¡Ê½
¡¡
tiny
small
medium
pact
large
huge
flat
¡¡ÓÃÀ´½¨Á¢¡¡Îļþ£¬ËùÓеĴúÂë¡¢Êý¾ÝºÍ¶ÑÕ»¶¼ÔÚͬһ¸ö64¡¡KB¶ÎÄÚ
½¨Á¢´úÂëºÍÊý¾Ý·Ö±ðÓÃÒ»¸ö64¡¡KB¶ÎµÄ¡¡¡£exeÎļþ
´úÂë¶Î¿ÉÒÔÓжà¸ö64¡¡KB¶Î£¬Êý¾Ý¶ÎÖ»ÓÐÒ»¸ö64¡¡KB¶Î
´úÂë¶ÎÖ»ÓÐÒ»¸ö64¡¡KB¶Î£¬Êý¾Ý¶Î¿ÉÒÔÓжà¸ö64¡¡KB¶Î
´úÂë¶ÎºÍÊý¾Ý¶Î¶¼¿ÉÒÔÓжà¸ö64¡¡KB¶Î
ͬlarge£¬²¢ÇÒÊý¾Ý¶ÎÖеÄÒ»¸öÊý×éÒ²¿ÉÒÔ³¬¹ý64¡¡KB
Win32³ÌÐòʹÓõÄģʽ£¬´úÂëºÍÊý¾Ý¶ÎʹÓÃͬһ¸ö4¡¡GB¶Î
¡¡
ÔÚÇ°ÃæÕ½ÚÖÐÒѾÌáµ½¹ý£ºWindows³ÌÐòÔËÐÐÔÚ±£»¤Ä£Ê½Ï£¬ÏµÍ³°Ñÿһ¸öWin32Ó¦ÓóÌÐò¶¼·Åµ½·Ö¿ªµÄÐéÄâµØÖ·¿Õ¼äÖÐÈ¥ÔËÐУ¬Ò²¾ÍÊÇ˵£¬Ã¿Ò»¸öÓ¦ÓóÌÐò¶¼ÓµÓÐÆäÏ໥¶ÀÁ¢µÄ4¡¡GB¡¡µØÖ·¿Õ¼ä£¬¶ÔWin32³ÌÐòÀ´Ëµ£¬Ö»ÓÐÒ»ÖÖÄÚ´æģʽ£¬¼´flat£¨Æ½Ì¹£©Ä£Ê½£¬Òâ˼ÊÇÄÚ´æÊǺܡ°Æ½Ì¹¡±µØ´Ó0ÑÓÉìµ½¡¡4¡¡GB£¬ÔÙûÓÐ64¡¡KB¶Î´óСÏÞÖÆ¡£¶Ô±ÈÒ»ÏÂDOSµÄHello¡¡WorldºÍWin32µÄHello¡¡World¿ªÊ¼²¿·ÖµÄ²»Í¬£¬DOS³ÌÐòÖÐÓÐÕâÑùÁ½¾ä£º
mov¡¡¡¡¡¡¡¡¡¡ax£»data
mov¡¡¡¡¡¡¡¡¡¡ds£»ax
Òâ˼ÊÇ°ÑÊý¾Ý¶Î¼Ä´æÆ÷DSÖ¸ÏòdataÊý¾Ý¶Î£¬dataÊý¾Ý¶ÎÔÚÇ°ÃæÒѾÓá¡data¡¡segment¡¡Óï¾ä¶¨Ò壬ֻҪDS²»ÖØÐÂÉèÖã¬ÄÇô´Ó´ËÒÔºóÖ¸ÁîÖÐÉæ¼°µÄÊý¾ÝĬÈϽ«´ÓdataÊý¾Ý¶ÎÖÐÈ¡µÃ£¬ËùÒÔÏÂÃæµÄÓï¾äÊÇ´ÓdataÊý¾Ý¶ÎÈ¡³öszHello×Ö·û´®µÄµØÖ·ºóÔÙÏÔʾ£º
mov¡¡¡¡¡¡¡¡¡¡ah£»9
mov¡¡¡¡¡¡¡¡¡¡dx£»offset¡¡szHello
int¡¡¡¡¡¡¡¡¡¡21h
×ݹÛWin32»ã±àµÄÔ´³ÌÐò£¬Ã»ÓÐÒ»´¦¿ÉÒÔÕÒµ½ds»òesµÈ¶Î¼Ä´æÆ÷µÄʹÓã¬ÒòΪËùÓеÄ4¡¡GB¿Õ¼äÓÃ32λµÄ¼Ä´æÆ÷È«²¿¶¼ÄÜ·ÃÎʵ½ÁË£¬²»±ØÔÚÍ·ÄÔÖÐËæʱ¼Ç×ŵ±Ç°Ê¹ÓõÄÊÇÄĸöÊý¾Ý¶Î£¬Õâ¾ÍÊÇ¡°Æ½Ì¹¡±ÄÚ´æģʽ´øÀ´µÄºÃ´¦¡£
Èç¹û¶¨ÒåÁË¡¡¡£model¡¡flat£¬MASM×Ô¶¯Îª¸÷ÖֶμĴæÆ÷×öÁËÈç϶¨Ò壺
ASSUME¡¡¡¡cs£ºFLAT£»¡¡ds£ºFLAT£»¡¡ss£ºFLAT£»¡¡es£ºFLAT£»¡¡fs£ºERROR£»¡¡gs£ºERROR
Ò²¾ÍÊÇ˵£¬CS£¬DS£¬ESºÍSS¶ÎÈ«²¿Ê¹ÓÃƽ̹ģʽ£¬FSºÍGS¼Ä´æÆ÷ĬÈϲ»Ê¹Óã¬ÕâʱÈôÔÚÔ´³ÌÐòÖÐʹÓÃFS»òGS£¬ÔÚ±àÒëʱ»á±¨´í¡£Èç¹ûÓбØҪʹÓÃËüÃÇ£¬Ö»ÐèÔÚʹÓÃÇ°ÓÃÏÂÃæµÄÓï¾äÉùÃ÷һϾͿÉÒÔÁË£º
assume¡¡¡¡fs£ºnothing£»¡¡gs£ºnothing¡¡»òÕß¡¡assume¡¡fs£ºflat£»¡¡gs£ºflat
ÔÚWin32»ã±àÖУ¬¡£modelÓï¾äÖл¹Ó¦¸ÃÖ¸¶¨ÓïÑÔģʽ£¬¼´×Ó³ÌÐòµÄµ÷Ó÷½Ê½£¬Àý×ÓÖÐÓõÄÊÇstdcall£¬ËüÖ¸³öÁ˵÷ÓÃ×Ó³ÌÐò»òWin32¡¡APIʱ²ÎÊý´«µÝµÄ´ÎÐòºÍ¶ÑջƽºâµÄ·½·¨£¬Ïà¶ÔÓÚstdcall£¬²»Í¬µÄÓïÑÔÀàÐÍ»¹ÓÐC£¬SysCall£¬BASIC£¬FORTRANºÍPASCAL£¬ËäÈ»¸÷Öָ߼¶ÓïÑÔÔÚµ÷ÓÃ×Ó³ÌÐòʱ¶¼ÊÇʹÓöÑÕ»À´´«µÝ²ÎÊý£¬µ«ËüÃǵĴ¦Àí·½·¨¸÷Óв»Í¬¡£ÒªºÍ±ðµÄÓïÑÔÅäºÏ£¬¾Í±ØÐëÖ¸¶¨ÏàÓ¦µÄÓïÑÔÖÖÀà¡£WindowsµÄAPIµ÷ÓÃʹÓõÄÊÇstdcall¸ñʽ£¬ËùÒÔÔÚWin32»ã±àÖÐûÓÐÑ¡Ôñ£¬±ØÐëÔÚ¡¡¡£modelÖмÓÉÏstdcall²ÎÊý¡£¹ØÓÚ²ÎÊý´«µÝµÄ¾ßÌåϸ½Ú£¬ÔÚ3¡£4¡£2½ÚÖÐÓÐÏêϸµÄÃèÊö¡£
3¡£¡¡optionÓï¾ä
ÓÃoptionÓï¾ä¶¨ÒåµÄÑ¡ÏîÓкܶ࣬Èçoption¡¡language¶¨ÒåºÍoption¡¡segment¶¨ÒåµÈ£¬ÔÚWin32»ã±à³ÌÐòÖУ¬ÐèÒªµÄÖ»ÊǶ¨Òåoption¡¡casemap£ºnone£¬Õâ¸öÓï¾ä¶¨ÒåÁ˳ÌÐòÖеıäÁ¿ºÍ×Ó³ÌÐòÃûÊÇ·ñ¶Ô´óСдÃô¸Ð£¬ÓÉÓÚWin32¡¡APIÖеÄAPIÃû³ÆÊÇÇø·Ö´óСдµÄ£¬ËùÒÔ±ØÐëÖ¸¶¨Õâ¸öÑ¡Ï·ñÔòÔÚµ÷ÓÃAPIµÄʱºò»áÓÐÎÊÌâ¡£
3¡£1¡£2¡¡¡¡¶ÎµÄ¶¨Òå
1¡£¡¡¶ÎµÄ¸ÅÄî
°ÑÉÏÃæµÄWin32µÄHello¡¡WorldÔ´³ÌÐòÖеÄÓï¾ä¹éÄɾ«¼òһϣ¬ÔÙÁÐÔÚÏÂÃ棺
¡£386
¡£model¡¡flat£»stdcall
option¡¡casemap£ºnone
¡¡¡¡
¡£data
¡¡¡¡
de
¡¡¡¡
¡¡¡¡
¡¡¡¡¡¡¡¡¡¡
end¡¡¿ªÊ¼±êºÅ
ÉÏÒ»½Ú½²µ½µÄÑ¡ÏģʽµÈ¶¨Òå²¢²»»áÔÚ±àÒëºÃµÄ¿ÉÖ´ÐгÌÐòÖвúÉúʲô¶«Î÷£¬ËüÃÇÖ»ÊÇ¡°ËµÃ÷¡±£¬¶øÕæÕýµÄÊý¾ÝºÍ´úÂëÊǶ¨ÒåÔÚ¸÷¸ö¶ÎÖеģ¬ÈçÉÏÃæµÄ¡¡¡£data¶ÎºÍ¡¡de¶Î£¬¿¼Âǵ½²»Í¬µÄÊý¾ÝÀàÐÍ£¬»¹¿ÉÒÔÓÐÆäËûÖÖÀàµÄÊý¾Ý¶Î£¬ÏÂÃæÊÇ°üº¬È«²¿¶ÎµÄÔ´³ÌÐò½á¹¹£º
¡£386
¡£model¡¡flat£»stdcall
option¡¡casemap£ºnone
¡¡¡¡
¡£stack¡¡£§¶ÑÕ»¶ÎµÄ´óС£§
¡£data
¡¡¡¡
¡£data£¿
¡¡¡¡
nst
¡¡¡¡
de
¡¡¡¡
¡¡¡¡
¡¡¡¡¡¡¡¡¡¡
end¡¡¿ªÊ¼±êºÅ
¡£stack£¬¡£data£¬¡£data£¿£¬nstºÍ¡¡deÊÇ·Ö¶ÎαָÁWin32ÖÐʵ¼ÊÉÏÖ»ÓдúÂëºÍÊý¾ÝÖ®·Ö£¬¡£data£¬¡£data£¿ºÍ¡¡nstÊÇÊý¾Ý¶Î£¬deÊÇ´úÂë¶Î£¬ºÍDOS»ã±à²»Í¬£¬Win32»ã±à²»±Ø¿¼ÂǶÑÕ»£¬ÏµÍ³»áΪ³ÌÐò·ÖÅäÒ»¸öÏòÏÂÀ©Õ¹µÄ¡¢×ã¹»´óµÄ¶Î×÷Ϊ¶ÑÕ»¶Î£¬ËùÒÔ¡¡¡£stack¶Î¶¨Òå³£³£±»ºöÂÔ¡£
¡¡¡¡¡¡Ç°Ãæ²»ÊÇ˵¹ýWin32»·¾³Ï²»ÓöÎÁËÂð£¿Êǵģ¬ÕâЩ¡°¶Î¡±Êµ¼ÊÉϲ¢²»ÊÇDOS»ã±àÖÐÄÇÖÖÒâÒåµÄ¶Î£¬¶øÊÇÄÚ´æµÄ¡°·Ö¶Î¡±¡£ÉÏÒ»¸ö¶ÎµÄ½áÊø¾ÍÊÇÏÂÒ»¸ö¶ÎµÄ¿ªÊ¼£¬ËùÓеġ°·Ö¶Î¡±ºÏÆðÀ´£¬°üÀ¨ÏµÍ³Ê¹ÓõĵØÖ·¿Õ¼ä£¬¾Í×é³ÉÁËÕû¸ö¿ÉÒÔÑ°Ö·µÄ4¡¡GB¿Õ¼ä¡£Win32»·¾³µÄÄÚ´æ¹ÜÀíʹÓÃÁË80386´¦ÀíÆ÷µÄ·ÖÒ³»úÖÆ£¬Ã¿¸öÒ³£¨4¡¡KB´óС£©¿ÉÒÔ×ÔÓÉÖ¸¶¨ÊôÐÔ£¬ËùÒÔÉÏÒ»¸ö4¡¡KB¿ÉÄÜÊÇ´úÂ룬ÊôÐÔÊÇ¿ÉÖ´Ðе«²»¿Éд£¬ÏÂÒ»¸ö4¡¡KB¾ÍÓпÉÄÜÊǼȿɶÁÒ²¿É䵫²»¿ÉÖ´ÐеÄÊý¾Ý£¬ÔÙÏÂÃæÄØ£¿ÓпÉÄÜÊǿɶÁ²»¿ÉдҲ²»¿ÉÖ´ÐеÄÊý¾Ý¡£Win32»ã±àÔ´³ÌÐòÖС°·Ö¶Î¡±µÄ¸ÅÄîʵ¼ÊÉÏÊǰѲ»Í¬ÀàÐ͵ÄÊý¾Ý»ò´úÂë¹éÀ࣬Ôٷŵ½²»Í¬ÊôÐÔµÄÄÚ´æÒ³£¨Ò²¾ÍÊDz»Í¬µÄ¡°·Ö¶Î¡±£©ÖУ¬ÕâÖм䲻É漰ʹÓò»Í¬µÄ¶ÎÑ¡ÔñÆ÷¡£ËäȻʹÓúÍDOS»ã±àͬÑùµÄ¡¡deºÍ¡¡¡£dataÓï¾äÀ´¶¨Ò壬Ò
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿!
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾Ñé½±Àø£¬ÈÏÕæдԴ´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾Ñé½±ÀøŶ£¡