Linux °æ (¾«»ªÇø)
·¢ÐÅÈË: netiscpu (Ò¹¡îÐǹâµãµã¡î), ÐÅÇø: Linux
±ê Ìâ: NACHOSÂÛ̳(5)
·¢ÐÅÕ¾: ×Ï ¶¡ Ïã (Sun Nov 8 17:28:49 1998), תÐÅ
¼ÄÐÅÈË: ship.bbs@bbs.xmu.edu.cn
±ê Ìâ: NACHOSÂÛ̳(5)(ת¼Ä)
·¢ÐÅÕ¾: »ªÄÏÀí¹¤´óѧ BBSľÃÞÕ¾
ÈÕ ÆÚ: Sun Mar 9 15:05:06 1997
×÷ ¼Ò: solmon (ËùÂÞÃÅÍõ) on board 'Unix'
Ìâ Ä¿: NACHOSÂÛ̳(5)
À´ Ô´: ¹ÄÀËÌýÌÎÕ¾
ÈÕ ÆÚ: Thu Mar 6 23:06:26 1997
³ö ´¦: mysu@JingXian.xmu.edu.cn
µÚÎåÕ NachosÔÚ8086ÉϵÄʵÏÖ
NachosÊÇÒ»¸öÓÅÐãµÄ²Ù×÷ϵͳ¿Î³ÌÉè¼Æϵͳ,Ëü¶ÔѧÉúÀí½âºÍѧϰ²Ù×÷ϵͳµÄ»ù±¾
¸ÅÄî,»ù±¾ÔÀíºÍ·½·¨ºÜÓаïÖú.µ«ÊÇNachosµÄÔËÐл·¾³±ØÐëÊÇUNIXµÄ¹¤×÷Õ¾,Ó²¼þƽ̨
ΪDEC MIPS,SUN SPARC ,HP PA-RISC»òIntel386.Èç¹ûʹÓÃÆäÍøÂ粿·Ö,»¹±ØÐ뽫¹¤×÷
Õ¾ÁªÍø.ÒªÈôóÁ¿Í¬Ñ§ÔÚÔÚÕâÑùµÄÈíÓ²¼þ»·¾³ÉÏÍê³ÉNachos¿Î³ÌÉè¼Æ,¶Ô¹úÄڴ󲿷ָß
УÀ´Ëµ,ÊǺÜÀ§ÄѵÄ.ÎÒÃǸù¾Ý¹úÄڴ󲿷ָßУµÄʵ¼ÊÇé¿ö,½«NachosϵͳÒÆÖ²µ½¹ã·ºÊ¹
ÓõÄDOS²Ù×÷ϵͳÉÏ,ÒÆÖ²ºóµÄNachosÖ»ÒªIntel386΢»úºÍDOS²Ù×÷ϵͳ¼´¿ÉʹÓÃ,Èç¹û
ҪʹÓÃNachosµÄÍøÂ粿·Ö,Ö»ÐèÔÙ¼ÓÒ»¸öDOSµÄ¶àÈÎÎñ¹ÜÀíÆ÷,ÈçDOSSHELL»òWindows.Õâ
ЩÈíÓ²¼þÒªÇóÔÚ¹úÄÚ´ó¶àÊý¸ßУÖж¼¿ÉÒԵõ½Âú×ã.ÉõÖÁѧÉú×Ô¼º¹ºÂòµÄ΢»úÉϴ󲿷Ö
Ò²ÓÐÉÏÊö»·¾³.ÕâÑùÒÆÖ²ºóµÄNachos¾Í¿ÉÒÔ±»¹ã·ºµØʹÓÃÁË.
ÔÚNachosµÄÒÆÖ²¹ý³ÌÖÐ,ÎÒÃÇ×öÁËÒÔϼ¸¸ö¹¤×÷:
1.ÔÚ8086ÉÏʵÏÖNachosµÄÁ½¸ö½ø³ÌÇл»º¯Êý.
2.ÓÃ×Ô¶¨ÒåµÄÊý¾ÝÀàÐ͸ÄдNachosÖÐÊý¾ÝµÄÊý¾ÝÀàÐÍ,ʹÆäÄܹ»ÓÃDOSµÄ16λ
±àÒëÆ÷±àÒë.
3.½«Ò»Ð©UNIX¿âº¯ÊýÒÆÖ²µ½DOS.
4.NachosµÄÓ¦ÓóÌÐò½âÊÍÆ÷ÔÀ´ÔËÐеÄÓ¦ÓóÌÐòÊÇÓÃMIPS»úÆ÷Ö¸ÁîдµÄ,ÏÖ¸Ä
ΪÔËÐÐ8086»úÆ÷Ö¸ÁîµÄÓ¦ÓóÌÐò.
Ò».½ø³ÌÇл»º¯ÊýµÄÒÆÖ².
NachosÊÇÒ»¸öÕæÕýµÄ¶à½ø³Ìϵͳ,ËüµÄ¶à½ø³Ì²»ÊÇÒÀ¿¿ËÞÖ÷»ú²Ù×÷ϵͳÉϵĶà½ø³Ì
»úÖÆʵÏÖµÄ.´ÓËÞÖ÷»ú²Ù×÷ϵͳµÄ½Ç¶ÈÀ´¿´,NachosÖ»ÊÇÒ»¸öÓ¦ÓóÌÐò,Ö»ÓÐÒ»¸ö½ø³ÌÔÚ
ÔËÐÐ,µ«ÊÇNachosÄÚ²¿Êµ¼ÊÉÏ¿ÉÒÔÔËÐжà¸öNachos×Ô¼ºÊµÏֵĽø³Ì.ÕâЩ½ø³Ì¿ÉÒÔ¶¯Ì
µØÉú³ÉºÍÏûÍö,²¢ÇÒÂÖÁ÷Õ¼Óô¦Àí»úÔËÐÐ.ÓÉÓÚNachosµÄÕâÖÖÉè¼Æ·½·¨²»ÒÀÀµÓÚUNIXµÄ
¶à½ø³Ì»úÖÆ,ËùÒÔÔÚ½«ËüÒÆÖ²µ½DOS»·¾³Ê±,²»ÓÃÔÚDOSÉÏÄ£ÄâUNIXµÄ¶à½ø³Ì¹¦ÄÜ,´ó´ó¼ò
»¯ÁËÒÆÖ²¹¤×÷.
Nachos½ø³Ì¹ÜÀíϵͳµÄÒÆÖ²ÖÐ,¸Ä¶¯ºÜ´óµÄÓÐÁ½¸öº¯Êý:SWITCHºÍThreadRoot.ÕâÁ½
¸öº¯Êý¶¼ÊÇÓÃÀ´ÊµÏÖ½ø³ÌÕýÎÄÇл»µÄ.´ËÀ๤×÷Óë¾ßÌåµÄ´¦Àí»ú½á¹¹¼°º¯Êýµ÷ÓøñʽÃÜ
ÇÐÏà¹Ø.NachosËäȻҲΪIntel386ʵÏÖÁËÕâÁ½¸öº¯Êý,µ«ÊÇËüʵÏÖÕâÁ½¸öº¯ÊýËùÓõĻã
±àÓïÑÔÓëDOSϵĻã±àÓïÑÔ´óÏྶͥ,²¢ÇÒÊǹ©32λ±àÒëÆ÷Éú³ÉµÄ³ÌÐòµ÷ÓõÄ,µ÷Óøñʽ
ÓëDOSµÄ16λ±àÒëÆ÷²»Ò»ÖÂ,ËùÒÔÔÓÐʵÏÖÎÞ·¨ÔÚDOSÏÂʹÓÃ,ÎÒÃÇÖØбàдÁËÕâÁ½¸öº¯Êý.
SWITCHº¯ÊýÊÇÓÃÀ´ÔÚ½ø³ÌÇл»Ê±±£»¤ÀϽø³ÌͼÏóºÍ»Ö¸´Ð½ø³ÌͼÏóµÄ.½ø³ÌͼÏó°ü
À¨´¦Àí»ú¼Ä´æÆ÷״̬ºÍ¶ÑÕ».ËüÓÐÁ½¸ö²ÎÊý:Thread* oldThread;Thread* newThread,
·Ö±ðÖ¸ÏòÀϽø³ÌºÍнø³ÌµÄ¶ÔÏó.¸Äд¹ýµÄSWITCHº¯ÊýÓëÔÀ´µÄÓкܴó²»Í¬.Ê×ÏÈ,еÄ
SWITCHº¯ÊýÊÇÓÃC++ÓïÑÔÖÐǶÈë»ã±àÓïÑÔ(¼´ÐÐÄÚ»ã±à)±àдµÄ,¶øÀϵÄSWITCHÈ«²¿ÓÉ»ã
±àÓïÑÔ±àд.Ö®ËùÒÔÓÃÐÐÄÚ»ã±à,ÊÇÓÉÓÚÔÚ½ø³ÌÇл»Ê±,ÐèÒª°ÑCPU¸÷¼Ä´æÆ÷µÄÖµ±£´æµ½
ÀϽø³Ì¶ÔÏóµÄmachineStateÊý¾Ý³ÉÔ±ÖÐ,¶øDOSϵıàÒëÆ÷ÈçBorland C++,MicroSoft
C++µÈ,¶Ô¶ÔÏóÖÐÊý¾Ý³ÉÔ±µÄÄÚ´æµØַûÓÐÃ÷È·µÄ¹æ¶¨,Èç¹ûʹ·´»ã±à»òÆäËü·½·¨Ç¿ÐÐÕÒ
³öÊý¾Ý³ÉÔ±µÄλÖÃ,»á´øÀ´Ðí¶àÎÊÌâ.ÀýÈ粻ͬµÄ±àÒëÆ÷·ÅÖÃÊý¾Ý³ÉÔ±µÄλÖò¢²»Ò»Ñù,
µ±ÏµÍ³µÄÒÆÖ²µ½ÆäËü±àÒëÆ÷ʱ,ÒªÖØÐÂÕÒ³öÕâ¸öλÖÃ,ºÜ²»·½±ã.¼´Ê¹Ö»Ê¹ÓÃÒ»ÖÖ±àÒë
Æ÷,¿ÉÒÔÈ·¶¨Êý¾Ý³ÉÔ±µÄλÖÃ,µ«ÊÇÔÚÉÔÉԸĶ¯½ø³Ì¶ÔÏóµÄ½á¹¹ºó,Õâ¸öλÖû᲻»á¸Ä±ä
ÄØ?ûÓÐÈËÄÜ×÷³ö¿Ï¶¨µÄ»Ø´ð.Òª±£Ö¤Õâ¸öλÖò»·¢Éú±ä»¯,¾Í±ØÐëÔÚÿ´Î¸Ä¶¯ºóÖØвé
¿´Õâ¸öÊý¾Ý³ÉÔ±µÄÄÚ´æλÖÃ,¿ÉÒÔÏëÏó,Õ⽫¸øNachosµÄÓû§--ѧÉú´øÀ´¶à´óµÄÂé·³.ÎÒ
ÃÇʹÓÃÐÐÄÚ»ã±à,Ö±½ÓÓÃC++ÓïÑÔ´æÈ¡¶ÔÏóµÄÊý¾Ý³ÉÔ±,Õâ¸öÎÊÌâ¾ÍÓÈжø½âÁË.
ʹÓÃÐÐÄÚ»ã±àÒ²ÓÐÆäȱµã,ÄǾÍÊdzÌÐòÔ±²»ÄÜÍêÈ«¿ØÖƼĴæÆ÷,һЩC++Óï¾ä,Ìرð
ÊÇÓйشæÈ¡Êý×éµÄÓï¾ä»áʹÓú͸ıä¼Ä´æÆ÷µÄÄÚÈÝ.ÎÒÃǽâ¾öÕâ¸öÎÊÌâµÄ·½·¨ÊÇ,ÔÚ¼Ä
´æÆ÷µÄֵδ±»ÐÞ¸Äʱ½«ÆäѹÈë¶ÑÕ»,ÒªÓÃʱÔÙ´Ó¶ÑÕ»Öе¯³ö,ÕâÑù¾ÍÍòÎÞһʧÁË.
SWITCHº¯ÊýµÄÖ´Ðйý³ÌΪ:
1.½«SP,SS,AX,BX,CX,DX,SI,DI,BP¼Ä´æÆ÷µÄֵ˳ÐòѹÈë¶ÑÕ».ÒòΪÔÚѹջµÄ¹ý
³ÌÖÐ,Õ»¶¥¼Ä´æÆ÷SP»á¸Ä±ä,ËùÒÔÊ×ÏȽ«SPѹÈë¶ÑÕ».
2.CÓïÑÔµ÷Óú¯ÊýµÄѹջ¹æÔòÊÇ:ÏȽ«²ÎÊý´ÓÓÒÏò×óѹÈë¶ÑÕ»,ÔٰѺ¯ÊýµÄ·µ»Ø
µØַѹÈë¶ÑÕ».¸ù¾ÝÕâ¸ö¹æÔò,¿ÉÒÔ´ÓÕ»ÉÏÕÒµ½SWITCHº¯ÊýµÄ·µ»ØµØ
Ö·,È¡³öÕâ¸öµØÖ··ÅÈëÒ»¸öÁÙʱ±äÁ¿Öб£´æ.
3.´ÓÕ»Öзֱ𵯳öÏÈÇ°±£´æµÄ¸÷¼Ä´æÆ÷Öµ,·ÅÈëÀϽø³ÌµÄmachineStateÖÐ,ÒÔ
´ïµ½±£»¤ÏÖ³¡µÄÄ¿µÄ.
4.½«SWITCHº¯ÊýµÄ·µ»ØµØÖ·Ò²±£´æµ½ÀϽø³ÌÖÐ.
5.½«newThreadµÄmachineStateÖб£´æµÄÕ»¶¥¼Ä´æÆ÷SPºÍÕ»¶Î¼Ä´æÆ÷SS¶ÁÈëDX,
CX¼Ä´æÆ÷,¹©ÏÂÃæÇ뻶ÑջʱʹÓÃ.
6.½«newThreadµÄÖµ¶ÁÈëAX,BX¼Ä´æÆ÷(¸ß16λ·ÅÈëAX,µÍ16λ·ÅÈëBX).ÕâÊÇÒò
ΪnewThreadÊÇSWITCHº¯ÊýµÄ²ÎÊý,ËüÊÇ·ÅÔÚ¶ÑÕ»ÉϵÄ,Ç뻶ÑÕ»ºó¾Í
ÕÒ²»µ½ËüÁË,ËùÒÔÏÈ°ÑËü¶ÁÈë¼Ä´æÆ÷ÖÐ.
7.½«CXµÄÖµ¸³¸øÕ»¶Î¼Ä´æÆ÷SS,DXµÄÖµ¸³¸øÕ»¶¥¼Ä´æÆ÷SP,´ïµ½Ç뻶ÑÕ»µÄÄ¿
µÄ.ÏÖÔÚ½ø³ÌÔÚеĶÑÕ»ÉÏÔËÐÐÁË.
8.ÓÃAX,BX¼Ä´æÆ÷µÄÖµÖØÐÂ×°ÅänewThreadÖ¸Õë.
9.½«Ð½ø³Ì±£´æµÄSWITCHº¯ÊýµÄ·µ»ØµØÖ··ÅÈëжÑÕ».ÕâÑùSWITCHº¯Êý½áÊø·µ
»Øºó,»á´Óнø³ÌµÄ¶Ïµã¼ÌÐøÔËÐÐÏÂÈ¥.
10.´ÓnewThreadµÄmachineStateÖÐÈ¡³öÒÔÇ°±£´æµÄBP,DI,SI,DX,CX,BX,AX¼Ä
´æÆ÷µÄÖµ,²¢°ÑËüÃÇѹÈë¶ÑÕ».
11.´Ó¶ÑÕ»Öзֱ𵯳öµÚ10²½Ñ¹ÈëµÄÖµ,²¢·ÅÈëÏàÓ¦µÄ¼Ä´æÆ÷.²»Ö±½ÓÔÚµÚ10²½
Öн«newThreadÖб£´æµÄÖµ·ÅÈë¼Ä´æÆ÷µÄÔÒòÓë×öµÚ1²½ºÍµÚ3²¿µÄÔ
ÒòÒ»Ñù,¶¼ÊÇÒòΪ´æÈ¡½ø³Ì¶ÔÏóÖб£´æµÄ¼Ä´æÆ÷ÄÚÈÝʱ,ҪʹÓÃһЩ
ͨÓüĴæÆ÷,ËùÒÔÏȵðѼĴæÆ÷µÄÄÚÈÝѹÈë¶ÑÕ»±£´æ.
ÎÒÃÇÔÚÒÆÖ²½ø³ÌÇл»µÄÁíÒ»¸öº¯ÊýThreadRootʱ,¶ÔËü×öÁËһЩ¼ò»¯.ThreadRoot
´ú±í½ø³ÌÔËÐеÄÈ«¹ý³Ì,¼È°üÀ¨Óû§¶¨ÒåµÄ½ø³Ìº¯Êý,ÓÖ°üÀ¨½ø³ÌµÄ³õʼ»¯º¯ÊýºÍ½ø³Ì
µÄ½áÊøº¯Êý.ThreadRootÓÐËĸö²ÎÊý,ËüÃÇÊÇ:
InitialPC,InitialArg,Óû§¶¨ÒåµÄ¹¤×÷º¯Êý¼°Æä²ÎÊý;
StartupPC,½ø³ÌµÄ³õʼ»¯º¯Êý;
WhenDonePC½ø³ÌµÄ½áÊøº¯Êý.
¾¹ý·ÖÎö,ÎÒÃÇ·¢ÏÖÔÚNachosÖÐÖ»ÐèÓÐÒ»¸ö³õʼ»¯º¯ÊýºÍÒ»¸ö½áÊøº¯Êý,ËùÒÔûÓÐ
±ØҪͨ¹ý²ÎÊý´«ÈëÕâÁ½¸öº¯Êý,ÎÒÃÇÖ±½ÓÔÚThreadRootº¯ÊýÖе÷ÓÃÕâÁ½¸öº¯Êý.
ThreadRootµÄÁíÁ½¸ö²ÎÊý²¢²»ÊÇÓɶÑÕ»´«ÈëµÄ,¶øÊÇ·ÅÔÚAX,BX,CX,DXËĸö¼Ä´æÆ÷
Öд«ÈëµÄ(ÕâÁ½¸ö²ÎÊý¶¼ÊÇ32λÊý,AXµÈͨÓüĴæÆ÷Ö»ÓÐ16λ,ËùÒÔÓÃ4¸ö¼Ä´æÆ÷´«2¸ö²Î
Êý).ThreadRootµÄÖ´Ðйý³ÌÈçÏÂ:
1.½«AX,BX,CX,DX¼Ä´æÆ÷µÄֵѹÈë¶ÑÕ».
2.ÔËÐнø³Ì³õʼ»¯º¯Êý.
3.´Ó¶ÑÕ»Öе¯³ö¼Ä´æÆ÷µÄÖµ,×°Åä³ÉÁ½¸ö²ÎÊý.
4.ÔËÐеÚ3²½×°ÅäµÄ½ø³Ì¹¤×÷º¯Êý.
5.ÔËÐнø³Ì½áÊøº¯Êý.
ThreadRootº¯ÊýµÄÌØÊâµÄ²ÎÊý´«Èë·½·¨,½«ÒªÇóÆäËü³ÌÐòÔÚµ÷ÓÃËüʱҪ×öһЩ¶îÍâ
µÄ¹¤×÷,Õâ²»ÊÇÌ«¶àÓàÁËÂð?ÊÂʵÉÏ,ϵͳÖÐûÓÐÒ»¸öµØ·½ÏÔʽµØµ÷ÓÃThreadRootº¯Êý,
¶øÇÒThreadRootº¯Êý¸ù±¾¾Í²»ÄܽáÊø·µ»Ø(ÕâÒ»µãÔÚ½ø³Ì¹ÜÀíÒ»ÕÂÖÐÒÑ×÷ÁËÏêϸ½éÉÜ).
ÄÇôThreadRootº¯ÊýÓÐʲôÓô¦ÄØ?´ÓÇ°ÃæµÄ½éÉÜÖÐÎÒÃÇÖªµÀÔÚ½ø³ÌÇл»Ê±SWITCHº¯Êý
»á·µ»Øµ½Ð½ø³ÌÒÔÇ°µÄ¶Ïµã´¦,µ«ÊÇнø³ÌÊ״α»µ÷¶ÈÉÏCPUÔËÐÐʱ,²¢Ã»ÓÐÒÔÇ°µÄ¶Ï
µã,ÄÇôËü½«·µ»Øµ½ÄÄÀïÄØ?ΪÁ˽â¾öÕâ¸öÎÊÌâ,ÎÒÃÇÔÚÉú³ÉÒ»¸öнø³ÌµÄʱºò,½«
ThreadRootº¯ÊýµÄµØÖ··ÅÈëнø³Ì¶ÑÕ»Öзŷµ»ØµØÖ·µÄλÖÃ,²¢ÇÒÔÚ´æ·ÅAX,BX,CX,DX
¼Ä´æÆ÷ÖµµÄmachineStateÊý×éÖзÅÈëThreadRootÐèÒªµÄÁ½¸ö²ÎÊý.ÕâÑù,µ±Ð½ø³ÌÊ×´Î
Õ¼Óô¦Àí»úʱ,¾Í¿ÉÒÔÔËÐÐThreatRootº¯ÊýÁË.
¶þ.ÔÚ16λ±àÒëÆ÷ÉϱàÒëNachos.
NachosÔÀ´Ê¹ÓÃGNU C++±àÒëÆ÷±àÒëµÄ,ËüÊÇÒ»¸ö32λµÄ±àÒëÆ÷,¶øDOSϳ£Óõıà
ÒëÆ÷,ÈçMicroSoft C++,Borland C++¶¼ÊÇ16λ±àÒëÆ÷.32λ±àÒëÆ÷Óë16λ±àÒëÆ÷µÄÖ÷Òª
²»Í¬ÔÚÓÚÕûÐÍ(int)µÄ³¤¶È²»Ò»Ñù,32λ±àÒëÆ÷ÖÐÕûÐͳ¤¶ÈΪ32λ,Õ¼4¸ö×Ö½Ú.¶ø16λ±à
ÒëÆ÷ÖÐÕûÐͳ¤¶ÈΪ16λ,Õ¼2¸ö×Ö½Ú.NachosÖдóÁ¿ÕûÐÍÊý¾ÝµÄÖµ²»ÄÜÓÃ2¸ö×Ö½Ú´æ·Å.Àý
ÈçÔÚNachos´úÂëÖÐ,ÏòÒ»¸öº¯Êý´«µÝδ֪ÀàÐ͵IJÎÊýʱ,¶¼½«²ÎÊý¶¨ÒåΪÕûÐÍ,È»ºóÔÚº¯
ÊýÄÚ²¿ÔÙ¸ù¾Ý¾ßÌåÐèÒª,¶Ô²ÎÊý½øÐÐÀàÐÍת»».ÕâЩ²ÎÊýÍùÍù±»×ª»»ÎªÖ¸ÏòÒ»¸ö¶ÔÏóµÄ
ÄÚ´æÖ¸Õë,ÄÚ´æÖ¸ÕëÓÐ32λ,ÐèÒªÓÃ4¸ö×Ö½Ú±íʾ,Õâ¾ÍÒªÇóÕûÐͱØÐëÓÐ4¸ö×Ö½Ú.ΪÁËÔÚ
DOSÏÂÕýÈ·µØ±àÒëNachos´úÂë,ÎÒÃDz»µÃ²»ÊÖ¹¤¸ÄдÕâЩÕûÐÍÊý¾ÝµÄÀàÐÍ.´ËÍâ,ÎÒÃÇ»¹
¿¼Âǵ½½«À´¸÷·½ÃæÌõ¼þ¸ÄÉÆÁË,NachosÓÖ»áÓÃ32λ±àÒëÆ÷ÖØбàÒë,ÒÔ±ãÒÆÖ²µ½¸ü¸ß¼¶
µÄÓ²¼þÉÏ.¾¡¹ÜÏÖÓеÄNachosÒѾÊÇ32λµÄ,Ëƺõ²»ÐèÒªÔÙ°ÑNachos for DOSÒÆÖ²µ½32
λ,µ«ÊÇÎÒÃǽñºó´óÁ¿¹¤×÷¶¼ÊÇÔÚNachos for DOSÉϽøÐеÄ,Nachos for DOS½«±ÈÏÖÓÐ
µÄNachos¸ü¼ÓÍêÉÆ,Èç¹ûÎÒÃDz»Ïë·ÅÆúÕâЩ±¦¹óµÄ¹¤×÷³É¹û, ¾ÍÖ»ÓаÑNachos for DOS
ÒÆÖ²µ½32λ»ò¸ü¸ßµÄϵͳÉÏ.ÄÇôÈçºÎʹNachosµÄÊý¾ÝÀàÐÍת»»¹¤×÷ͬʱÂú×ãÉÏÊöÁ½·½
ÃæµÄÒªÇóÄØ?ÎÒÃÇ·¢ÏÖWindowsµÄAPI(Ó¦ÓóÌÐò½Ó¿Ú)Ò²Óöµ½ÓëÎÒÃÇͬÑùµÄÎÊÌâ,¼´ÐèÒª
¾¡¿ÉÄÜ·½±ãµØÒÆÖ²µ½²»Í¬µÄ±àÒëÆ÷ÉÏ,WindowsµÄAPIÔÚÉè¼ÆµÄʱºò¾Í×¢Òâµ½Õâ¸öÎÊÌâ,
ËùÒÔËüûÓÐʹÓó£¹æµÄCÓïÑԵĻù±¾Êý¾ÝÀàÐÍÀ´¶¨ÒåÊý¾Ý,¶øÊÇ×Ô¼º¶¨ÒåÁËÒ»Ì×Êý¾ÝÀà
ÐÍ,È»ºóÓÃCÓïÑÔµÄdefineºÍtypedefÁ½ÖÖÓï¾ä½«×Ô¶¨ÒåµÄÊý¾ÝÀàÐͶÔÓ¦µ½CÓïÑÔµÄÊý¾Ý
ÀàÐÍ.ÕâÑù,Èç¹ûCÓïÑÔµÄÊý¾ÝÀàÐÍÒò±àÒëÆ÷µÄ²»Í¬¶ø¸Ä±äʱ,Ö»Òª¸Ä¶¯ÉÙÁ¿µÄdefineºÍ
typedef¾Í¿ÉÒÔ±£³Ö²»±ä.ÕâÖÖ·½·¨·Ç³£·½±ãÁé»î.ÎÒÃǽè¼øÁËWindows APIµÄ·½·¨,¶¨Òå
ÁËÏÂÁм¸ÖÖÊý¾ÝÀàÐÍ:
1.BYTE ,Õ¼1¸ö×Ö½Ú.
2.WORD ,Õ¼2¸ö×Ö½Ú.
3.DWORD,Õ¼4¸ö×Ö½Ú.
ÒòΪCÓïÑÔ±ê×¼¿âº¯ÊýµÄ²ÎÊýºÍ·µ»ØÖµµÄÀàÐÍΪCÓïÑԵıê×¼Êý¾ÝÀàÐÍ,ËùÒÔÎÒÃǶ¨
ÒåÁËINTºÍCHARÁ½ÖÖÀàÐÍ,·Ö±ðÓëCÓïÑÔÖеÄintºÍcharÏà¼æÈÝ.
ÕâЩ×Ô¶¨ÒåµÄÊý¾ÝÀàÐÍ·ÅÔÚPUBLIC.HÖÐ,PUBLIC.H±»NachosÔÓеÄÒ»¸öÍ·Îļþ
COPYRIGH.H°üº¬,ÒòΪCOPYRIGH.H±»Ã¿Ò»¸öNachosµÄC++Îļþ°üº¬,ËùÒÔPUBLIC.HÒ²¾Í±»
È«²¿C++Îļþ°üº¬ÁË.ÎÒÃÇÔÚͨ¶ÁNachosÔ´´úÂëµÄ»ù´¡ÉÏ,½«NachosÔÓеÄchar,intÀàÐÍ
µÄÊý¾Ý¸ù¾ÝÆäËùÐè¿Õ¼äµÄ´óСºÍÓÃ;,¸ÄΪ×Ô¶¨ÒåµÄÀàÐÍ.ÔÚ¸ÄдµÄ¹ý³ÌÖÐ,ÎÒÃǾ¡¿ÉÄÜ
ÓÃDWORDÀ´¸Äдint ÀàÐ͵ıäÁ¿,¸ø½«À´À©Õ¹ÏµÍ³´øÀ´·½±ã.
Èý.UNIX¿âÏòDOSµÄÒÆÖ².
DOSÖÐûÓеÄUNIX¿âº¯Êý¿É·ÖΪÁ½Àà,µÚÒ»Àà¿ÉÒÔÓÃÆäËü¿âº¯ÊýÖ±½ÓÀ´ÊµÏÖÏàͬµÄ¹¦
ÄÜ.Èçbcopy¿ÉÒÔÓÃmemcpyÀ´´úÌæ,ÒÆֲʱֻҪÖØбàдÕâЩº¯Êý¼´¿É.
ÁíÒ»ÀàÎÞ·¨Ö±½ÓÒÆÖ²µ½DOSÏÂ,ËüÃÇÖ÷Òª¼¯ÖÐÔÚÍøÂ粿·Ö.NachosʹÓÃUNIXµÄÌ×½Ó¿Ú
(socket)»úÖÆÀ´ÊµÏÖ²»Í¬¹¤×÷Õ¾ÉϵÄNachosϵͳ֮¼äµÄÍøÂçͨѶ.DOSÖÐûÓÐÀàËƹ¦ÄÜ,
¶øÇÒ¹úÄÚ²¿·Ö¸ßУÉÐδʵÏÖÁªÍø,¿¼Âǵ½ÕâЩʵ¼ÊÇé¿ö,ÎÒÃǾö¶¨ÔÚµ¥»úÉÏÓÃÒ»¸öÎļþ
À´Ä£ÄâÍøÂç.¾ßÌåµÄ·½·¨ÊÇÔÚWindowsÏÂÆô¶¯Á½¸öDOS·ÂÕæ³ÌÐò(ÔËÐÐWindows µÄProgram
ManagerÖеÄDOS PROMPT³ÌÐò),ÕâÁ½¸öDOS·ÂÕæ³ÌÐò·Ö±ðÔËÐÐÒ»¸öNachos,ÕâÁ½¸öNachos
³ÌÐòÒ»¸ö°Ñ±¨ÎÄдÈ뱨ÎÄÎļþ,ÁíÒ»¸ö°Ñ±¨ÎÄ´Ó±¨ÎÄÎļþÖжÁ³ö.ÕâÑù¾Í¿ÉÒÔÄ£ÄâÍøÂç
µÄÐÅÏ¢½»»»¹¦ÄÜÁË.ÕâÖÖ·½·¨²»½öÊÊÓÃÓÚÄ£Äâµ¥»úÉÏ,Á½¸öNachos³ÌÐòÖ®¼äµÄÍøÂçͨѶ,
»¹¿ÉÒÔÀ©Õ¹µ½¶à¸öNachos³ÌÐòÖ®¼äµÄÍøÂçͨѶ.Ö»ÒªÄÚ´æ×ã¹»´ó,Windows¾Í¿ÉÒÔÔËÐжà
¸öDOS·ÂÕæ³ÌÐò,ÿ¸öDOS·ÂÕæ³ÌÐòÉÏÔËÐÐÒ»¸öNachos,ÿ¸öNachosϵͳ¶¼ÓÐÒ»¸ö±êÖ¾ºÅ.
ÍøÂ籨ÎÄÖк¬Óз¢ËÍ·½ºÍ½ÓÊÕ·½µÄ±êÖ¾ºÅ,Nachos³ÌÐòÖ»½ÓÊÕ·¢¸ø×Ô¼ºµÄ±¨ÎÄ.ÕâÑù¾Í
¿ÉÒÔÄ£ÄâÒ»¸ö¶à½ÚµãµÄÍøÂçÁË.´ËÍâ,Èç¹ûÄúÊÇÔÚÒ»¸öÕæÕýµÄÍøÂçÉϹ¤×÷,Ò²¿ÉÒ԰ѱ¨ÎÄ
Îļþ·ÅÔÚÍøÂçµÄÎļþ·þÎñÆ÷ÉÏ,Èù¤×÷×éµÄ³ÉÔ±¿ÉÒÔÔÚ²»Í¬µÄ¿Í»§»úÉÏ´æÈ¡Õâ¸öÎļþ,
ÕâÑù¾ÍʵÏÖÁ˲»Í¬¿Í»§»úÉÏÔËÐеÄNachoÖ®¼äÄ£ÄâÍøÂçͨѶ.
ÍøÂçÄ£ÄâµÄ¾ßÌåʵÏÖΪ:ÔÚNachos¿ªÊ¼ÔËÐÐʱ,Óù²Ïí·½Ê½´ò¿ª±¨ÎÄÎļþ,Æä¹²ÏíÊô
ÐÔÉèΪSH_DENYNO,ËüÔÊÐíÔÚ±¨ÎÄÎļþ´ò¿ªÊ±,ÆäËü³ÌÐò¶ÔËü½øÐжÁд²Ù×÷.ÔÚNachosÔË
ÐÐÆڼ䱨ÎÄÎļþÒ»Ö±´¦ÓÚ´ò¿ª×´Ì¬.Nachos½áÊøʱ,²Å¹Ø±Õ±¨ÎÄÎļþ.ÎÒÃÇÖªµÀ,Èç¹ûÓÐ
Á½¸ö³ÌÐòͬʱ¶Ô±¨ÎÄÎļþ½øÐжÁд»áÒýÆð¶ÁдµÄ»ìÂÒ.ΪÁ˱ÜÃâÕâ¸öÎÊÌâ,ÔÚµ¥»úÔËÐÐ
NachosʱÏÈÔËÐÐDOSÌṩµÄSHARE.EXE³ÌÐò,Ëü¿ÉÒÔ¿ØÖÆÎļþµÄ¶Áд,±ÜÃâ¶à¸ö³ÌÐòÖ®¼ä
µÄ¶Áд³åÍ».ÔÚÍøÂçÔËÐÐNachosʱ,Îļþ·þÎñÆ÷»áÌṩÎļþ¶Áд»¥³âµÄ·þÎñ.ËùÒÔÎÞÂÛÔÚ
µ¥»úÉÏ,»¹ÊÇÔÚÍøÂçÉÏʵÏÖÍøÂçÄ£Äâʱ,¶¼²»»á³öÏÖ¶ÁдÎļþ»ìÂÒµÄÇé¿ö.
Óû§Í¨¹ýÄ£ÄâÍøÂç·¢Ëͱ¨ÎĵĹý³ÌΪ:
1.±£´æ±¨ÎÄÎļþµÄµ±Ç°Îļþ¶ÁдָÕëλÖÃ
2.½«±¨ÎÄÎļþµÄµ±Ç°Îļþ¶ÁдָÕëÒƵ½Îļþβ.
3.°Ñ±¨ÎÄдÈ뱨ÎÄÎļþ.
4.°Ñ±¨ÎÄÎļþµÄµ±Ç°Îļþ¶ÁдָÕëÒÆ»ØÔÏȵÄλÖÃ.
Óû§²é¿´±¨ÎÄÎļþÖÐÊÇ·ñÓз¢¸ø×Ô¼ºµÄ±¨ÎĵĹý³ÌΪ:
¡ý
©¥©¥©¥©¥©¥©¥
±¨ÎÄÒÑÊÕµ½ Y
±ê־ΪÕæ ©¥©¥©¥©¥©·
©¥©¥©¥©¥©¥©¥ ©§
©§ ¡ý
©³©¥©¥©¥©¥©¥¡ú ©§ N ©³©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ ¡ý ©§ ·µ»ØTRUE ©§
©§ ©¥©¥©¥©¥©¥©¥ ©»©¥©¥©¥©¥©¥©¥©¥©¥©¿
©§ ÒѶÁµ½±¨ÎÄ Y
©§ Îļþβ²¿ ©¥©¥©¥©¥©·
©§ ©¥©¥©¥©¥©¥©¥ ©§
©§ ©§ ¡ý
©§ ©§N ©³©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ ¡ý ©§ ·µ»ØFALSE ©§
©§ ©³©¥©¥©¥©¥©¥©¥©¥©¥©·©»©¥©¥©¥©¥©¥©¥©¥©¥©¿
©§ ©§ °ÑÒ»Ìõ±¨ÎĶÁ ©§
©§ ©§ È뱨ÎÄ»º³åÇø ©§
©§ ©»©¥©¥©¥©¥©¥©¥©¥©¥©¿
©§ ©§
©§ ©§
©§ ¡ý
©§ ©¥©¥©¥©¥©¥©¥©¥
©§ N ´Ë±¨ÎĵĽÓÊÕ
©»©¥©¥ ·½Îª±¾½Úµã
©¥©¥©¥©¥©¥©¥©¥
©§
©§Y
¡ý
©³©¥©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ Öñ¨ÎÄÒÑÊÕµ½±êÖ¾ ©§
©»©¥©¥©¥©¥©¥©¥©¥©¥©¥©¿
©§
©§
¡ý
©³©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ ·µ»ØTRUE ©§
©»©¥©¥©¥©¥©¥©¥©¥©¥©¿
Óû§¶ÁÈ¡±¨ÎĵĹý³ÌΪ:
1.µ÷Óñ¨ÎIJ鿴º¯Êý,Èç¹ûËüµÄ·µ»ØֵΪ¼Ù,Ôò·µ»Ø.
2.½«±¨ÎÄ´Ó±¨ÎÄ»º³åÇøÖп½±´µ½µ÷ÓÃÕßÌṩµÄÄÚ´æÇø.
3.Ç屨ÎÄÒÑÊÕµ½±êÖ¾.
ËÄ.NachosÓ¦ÓóÌÐò½âÊÍÆ÷µÄÒÆÖ².
´ó¶àÊýÄ£Äâ²Ù×÷ϵͳµÄÓ¦ÓóÌÐòʹÓõĻúÆ÷Ö¸ÁîÊÇÄ£Äâ²Ù×÷ϵͳ×Ô¼ºÉè¼ÆµÄ,²»ÊÇ
ËÞÖ÷»úµÄ»úÆ÷Ö¸Áî.Õâ¾ÍÒªÇóÓ¦ÓóÌÐò±ØÐëÓÃÄ£ÄâϵͳÌØÓеĻã±àÓïÑÔ±àд,ΪÁ˱ÜÃâ
¸øѧÉú²¼ÖÃÌ«¶àµÄ¹¤×÷,ÕâЩӦÓóÌÐò¶¼ÊǺܼòµ¥,ºÜ¶ÌСµÄ,ºÜÄÑÓÃÀ´³ä·Ö²âÊÔ²Ù×÷ϵ
ͳµÄ¹¦ÄÜ.NachosÍ»ÆÆÁËÕâÒ»ÏÞÖÆ,ËüµÄÓ¦ÓóÌÐò¿ÉÒÔÓÃC»òC++ÓïÑÔ±àд,ͨ¹ý±àÒëÉú³É
ËÞÖ÷»úµÄ»úÆ÷Ö¸Áî,NachosÄܹ»½âÊÍÖ´ÐÐÕâЩ»úÆ÷Ö¸Áî,ÕâÑù¾Í´ó´ó¼õÇáÁ˱àдӦÓóÌ
ÐòµÄ¹¤×÷Ç¿¶È.
NachosÔÓеıàÒëÆ÷ÊÇGNU C++,ËüÉú³ÉµÄÊÇMIPSµÄ»úÆ÷Ö¸Áî,µ«ÊÇͬѧÃǶÔMIPSµÄ
»úÆ÷Ö¸Á̫ÊìϤ,ÔÚ¸ú×ÙÓ¦ÓóÌÐòÖ´Ðйý³ÌÖлáÓöµ½À§ÄÑ,ÁíÒ»·½Ãæ,DOS»·¾³ÏÂÒ²²»
ÄÜÔËÐÐGNU C++±àÒëÆ÷,ËùÒÔÎÒÃǾö¶¨ÓÃBorland C++ »òMicroSoft C++±àÒëÓ¦ÓóÌÐò.
ÕâÑù¾ÍÓÐÈýÏîÒÆÖ²¹¤×÷Òª×ö:
1.DOS±àÒëÆ÷Éú³ÉµÄÊÇ8086µÄ»úÆ÷Ö¸Áî,ÐèÒª°ÑÔÀ´µÄMIPSÖ¸Áî½âÂëºÍ½âÊÍÖ´
Ðв¿·Ö¸ÄдΪ8086Ö¸ÁîµÄ½âÂëºÍ½âÊÍÖ´ÐÐ.
2.½«DOS±àÒëÆ÷Éú³ÉµÄ¿ÉÖ´ÐÐÎļþÖеĵ÷ÓÃDOSϵͳ¹¦ÄܵÄÖ¸ÁîÈ¥µô.ÒòΪӦÓÃ
³ÌÐòÊÇÔÚNachos²Ù×÷ϵͳÉÏÔËÐеÄ,²»Ó¦µ÷ÓÃDOSϵͳ¹¦ÄÜ.
3.½«DOS±àÒëÆ÷Éú³ÉµÄ¿ÉÖ´ÐÐÎļþ,°´NachosÒªÇóµÄ¸ñʽ½øÐиÄд,²¢ÒƵ½
NachosµÄÎļþϵͳÖÐÈ¥.
¶Ô8086»úÆ÷Ö¸ÁîµÄ·ÖÎöÖ´ÐзÖΪÁ½²½,µÚÒ»²½¶Á³ö»úÆ÷Ö¸Áî½øÐнâÂë,½«½âÂë½á¹û
·ÅÈëÖ¸ÁîÐÅÏ¢Êý¾Ý½á¹¹ÖÐ,¹©ÏÂÒ»²½Ê¹ÓÃ.
8086Öпɹ©³ÌÐòԱʹÓõÄÓÐ14¸ö16λ¼Ä´æÆ÷,ËüÃÇÊÇ8¸öͨÓüĴæÆ÷AX,BX,CX,DX,
SP,BP,SI,DI,ÆäÖÐAX,BX,CX,DXµÄ¸ß8λºÍµÍ8λ»¹¿ÉÒÔ·Ö±ð×÷Ϊһ¸ö¼Ä´æÆ÷ʹÓÃ.ÀýÈç
AX¾Í¿ÉÒÔ·ÖΪAHºÍAL.Ö¸Áî¼Ä´æÆ÷IPÖ¸ÏòÖ¸ÁîµØÖ·µÄ¶ÎÄÚµØÖ·Æ«ÒÆÁ¿.±êÖ¾¼Ä´æÆ÷FRÖÐ
ÓÐ6¸ö״̬λ,3¸ö¿ØÖÆλ.״̬λ·Ö±ðΪ½øλ±êÖ¾,Ææż±êÖ¾,¸¨Öú½øλ±êÖ¾,Áã±êÖ¾,·û
ºÅ±êÖ¾,Òç³ö±êÖ¾.ÕâЩ±êÖ¾·´Ó³ËãÊõ»òÂß¼ÔËËã½á¹ûµÄijЩÐÔÖÊ.¿ØÖÆλÓÐ:·½Ïò±êÖ¾,
ÖжÏÔÊÐí±êÖ¾,¸ú×Ù±êÖ¾.ËüÃÇÓÃÀ´¿ØÖƳÌÐòµÄÔËÐÐ.8086»¹ÓÐ4¸ö¶Î¼Ä´æÆ÷,·Ö±ðÖ¸Ïò¸÷
¶ÎµÄ»ùÖ·.ËüÃÇÊÇ:´úÂë¶Î¼Ä´æÆ÷CS,¶ÑÕ»¶Î¼Ä´æÆ÷SS,Êý¾Ý¶Î¼Ä´æÆ÷DS,¸½¼Ó¶Î¼Ä´æÆ÷ES.
8086µÄÑ°Ö··½Ê½±È½Ï¸´ÔÓ,Ëü·ÖΪÁ¢¼´Ñ°Ö·,¼Ä´æÆ÷Ñ°Ö·,´æ´¢Æ÷Ñ°Ö·,´®²Ù×÷Ñ°Ö·,ÍâÉè
I/OÑ°Ö·ºÍ³ÌÐòתÒƲÙ×÷Ñ°Ö·.ÆäÖб仯×î´óµÄÊÇ´æ´¢Æ÷Ñ°Ö·.ÕâÖÖÑ°Ö··½Ê½ÓÖ¿É·ÖΪֱ
½ÓÑ°Ö·,¼Ä´æÆ÷¼ä½ÓÑ°Ö·,»ùÖ·Ñ°Ö·,±äÖ·Ñ°Ö·,ÒÔ¼°»ùÖ·±äÖ·Ñ°Ö·.¸ù¾ÝÑ°Ö··½Ê½¼ÆËã¶ø
µÃµÄµØÖ·Ö»ÊǶÎÄÚÆ«ÒƵØÖ·,»¹ÐèÓëËùÔڶεĶλùÖ·×éºÏ²ÅÊÇ20λµÄÎïÀíµØÖ·.
8086²ÉÓñä×Ö½Ú³¤Ö¸Áî,ÓÉ1µ½6¸ö×Ö½Ú×é³É,Æä¸ñʽÈçÏÂ:
µÚÒ»×Ö½Ú µÚ¶þ×Ö½Ú µÚÈýµ½Áù×Ö½Ú
©³©¥©¥©¥©¥©¥©¥©¥©¥©×©¥©¥©¥©¥©¥©¥©¥©¥©×©¥©¥©¥©¥©¥©¥©¥©·
©§ 7 6 5 4 3 2 1 0©§7 6 5 4 3 2 1 0 ©§ ©§
©»©¥©¥©¥©¥©¥©¥©¥©¥©ß©¥©¥©¥©¥©¥©¥©¥©¥©ß©¥©¥©¥©¥©¥©¥©¥©¿
²Ù×÷Âë D W MOD REG R/M µØַλÒÆÁ¿»òÁ¢¼´Êý
µÚÒ»×ֽڵĸß6λΪ²Ù×÷Âë,Ö¸³öÖ¸ÁîµÄ²Ù×÷ÀàÐÍ.DΪ·½Ïòλ,µ±D=0ʱ,±íʾREG×Ö
¶ÎÖ¸³öµÄ¼Ä´æÆ÷ΪԴ²Ù×÷Êý¼Ä´æÆ÷;µ±D=1ʱ,±íʾREG×Ö¶ÎÖ¸³öµÄ¼Ä´æÆ÷ΪĿµÄ²Ù×÷Êý
¼Ä´æÆ÷,ÓÃÀ´´æ·ÅÔËËã½á¹û.WΪ²Ù×÷λ,µ±W=0ʱ,±íʾ²Î¼ÓÔËËãµÄ²Ù×÷ÊýΪ×Ö½Ú²Ù×÷Êý;
µ±W=1ʱ,Ϊ×Ö²Ù×÷Êý.
µÚ¶þ×Ö½ÚÖ¸³öËùÓòÙ×÷Êý´æ·ÅÔںδ¦(´æ´¢Æ÷»¹ÊǼĴæÆ÷),ÒÔ¼°´æ´¢Æ÷²Ù×÷ÊýÓÐЧ
µØÖ·µÄ¼ÆËã·½·¨.7,6Á½Î»ÎªMOD(·½Ê½)×Ö¶Î,Ö¸³öÊÇ´æ´¢Æ÷²Ù×÷Êý»¹ÊǼĴæÆ÷²Ù×÷Êý;
5~3λΪREG(¼Ä´æÆ÷)×Ö¶Î,Ö¸³ö¼Ä´æÆ÷µÄ±àºÅ;2~0λΪR/M(¼Ä´æÆ÷/´æ´¢Æ÷)×Ö¶Î,ÊÜMOD
×ֶοØÖÆ,Ö¸³öµÚ¶þ¸ö²Ù×÷ÊýËùÔڵļĴæÆ÷µÄ±àºÅ(µ±MOD=11ʱ),»òÖ¸³ö´æ´¢Æ÷²Ù×÷Êý
µÄÓÐЧµØÖ·µÄ¼ÆËã·½·¨.
µÚÈýµ½Áù×Ö½Ú¸ù¾ÝÖ¸ÁîµÄ²»Í¬¶ø¾ö¶¨È¡Éá,Ò»°ãÓÉÆäÖ¸³ö´æ´¢Æ÷²Ù×÷ÊýµØÖ·µÄλÒÆ
Á¿»òÁ¢¼´Êý.
µÚ¶þ×Ö½ÚÖÐMOD×ֶεıàÂë±íÈçÏÂ:
©³©¥©¥©¥©¥©×©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ MOD ©§ ·½ ʽ ©§
©Ç©¥©¥©¥©¥©ï©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©Ï
©§ 00 ©§ ´æ´¢Æ÷·½Ê½,ÎÞλÒÆÁ¿ ©§
©§ 01 ©§ ´æ´¢Æ÷·½Ê½,ÓÐ8λλÒÆÁ¿ ©§
©§ 10 ©§ ´æ´¢Æ÷·½Ê½,ÓÐ16λλÒÆÁ¿ ©§
©§ 11 ©§ ¼Ä´æÆ÷·½Ê½,ÎÞλÒÆÁ¿ ©§
©»©¥©¥©¥©¥©ß©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¿
REG×ֶεıàÂë±íÈçÏÂ:
©³©¥©¥©¥©×©¥©¥©¥©¥©¥©¥©¥©¥©×©¥©¥©¥©¥©¥©¥©¥©¥©·
©§ REG ©§ W=0(×Ö½Ú²Ù×÷) ©§ W=1(×Ö²Ù×÷) ©§
©Ç©¥©¥©¥©ï©¥©¥©¥©¥©¥©¥©¥©¥©ï©¥©¥©¥©¥©¥©¥©¥©¥©Ï
©§ 000 ©§ AL ©§ AX ©§
©§ 001 ©§ CL ©§ CX ©§
©§ 010 ©§ DL ©§ DX ©§
©§ 011 ©§ BL ©§ BX ©§
©§ 100 ©§ AH ©§ SP ©§
©§ 101 ©§ CH ©§ BP ©§
©§ 110 ©§ DH ©§ SI ©§
©§ 111 ©§ BH ©§ DI ©§
©»©¥©¥©¥©ß©¥©¥©¥©¥©¥©¥©¥©¥©ß©¥©¥©¥©¥©¥©¥©¥©¥©¿
½âÂë¹ý³Ì·ÖÎö¶þ½øÖƵĻúÆ÷Ö¸Áî,½«Ö¸ÁîËùÕ¼×Ö½ÚÊý,²Ù×÷ÂëÀàÐÍ,Ô´Ä¿²Ù×÷ÊýµÄÑ°
Ö··½Ê½·ÅÈëÖ¸ÁîÐÅÏ¢½á¹¹ÖÐ.µÚ¶þ²½¸ù¾ÝÖ¸ÁîÐÅÏ¢½á¹¹µÄÄÚÈÝ,´Ó·ÂÕæ8086»úÆ÷µÄ¼Ä´æ
Æ÷»òÄÚ´æÖÐÈ¡³ö²Ù×÷Êý,¸ù¾Ý²Ù×÷ÂëÖ¸Ã÷µÄ¹¦ÄÜÔËËãºó,½«½á¹û·Å»Ø·ÂÕæ»úÆ÷ÖÐ.
8086µÄ»ã±à¼¶Ö¸ÁîÓÐ106Ìõ(ÒÔÖú¼Ç·û¼Æ),¿É·ÖΪÊý¾Ý´«ËÍÖ¸Áî.ËãÊõÖ¸Áî,λ´¦Àí
Ö¸Áî,×Ö·û´®Ö¸Áî,³ÌÐòתÒÆÖ¸ÁîÒÔ¼°´¦Àí»ú¿ØÖÆÖ¸ÁîµÈ6´óÀà.ÆäÖÐÓÐ5ÌõÖ¸Áî²»ÄÜÄ£
Äâ.Ò»ÀàÊǶÔÍâÉè¶Ë¿Ú½øÐжÁдµÄÖ¸ÁîIN,OUT.ÕâÊÇÒòΪ·ÂÕæ»úÉϲ¢Ã»ÓÐÄ£ÄâÍâÉè¶Ë¿Ú.
ÁíÒ»ÀàÊÇÖжÏÖ¸ÁîINT,INTO,IRET,ÖжÏÖ¸ÁîÊÇÓÃÀ´µ÷ÓÃDOSÌṩµÄϵͳ¹¦ÄܵÄ,ËùÒÔ
NachosÓ¦ÓóÌÐò²»Ó¦Ê¹ÓÃÕâЩָÁî.
ÔÚÓ¦ÓóÌÐòÖгöÏÖI/O¶Ë¿ÚÖ¸ÁîºÍÖжÏÖ¸ÁîµÄÔÒòÓÐÁ½¸ö,Ò»ÊÇÓû§µ÷ÓÃÁËһЩ°ü
º¬ÕâЩָÁîµÄCÓïÑԿ⺯Êý.ËùÒÔÔÚ±àдӦÓóÌÐòʱ,Ö»ÄÜʹÓÃÒ»²¿·ÖCÓïÑԿ⺯Êý,Èç
strcpy,ÐèÒªµ÷ÓòÙ×÷ϵͳ¹¦ÄÜʱ,±ØÐëʹÓÃÎÒÃÇÌṩµÄ¿âº¯Êý,¶ø²»ÄÜÓÃCÓïÑԿ⺯Êý,
ÀýÈç,´ò¿ªÎļþʱ,ÓÃÎÒÃÇÌṩµÄOpenº¯Êý,¶ø²»ÄÜÓñê×¼¿âÖеÄopenº¯Êý.
ÔÚÓ¦ÓóÌÐòÖгöÏÖI/O¶Ë¿ÚÖ¸ÁîºÍÖжÏÖ¸ÁîµÄÁíÒ»¸öÔÒòÊDZàÒëÆ÷Á´½ÓµÄʱºò»áÔÚ
¿ÉÖ´ÐÐÎļþÖмÓÈëһЩ³õʼ»¯³ÌÐòÒÔ°ïÖúÓ¦ÓóÌÐò×°ÈëÄÚ´æ.ÕâЩ³ÌÐò´óÁ¿µ÷ÓÃÁËDOS
ÖжÏ,ÎÒÃÇÒÆÖ²µÄʱºòҪȥµôÕâЩ³ÌÐò.±àÒëÆ÷µÄÎĵµÐ´Ã÷,ÕâЩ³õʼ»¯³ÌÐò·ÅÔÚC0S.OBJ
ÎļþÀï,±àÒëʱ±»Á´Èë¿ÉÖ´ÐгÌÐò,ÓÚÊÇÎÒÃÇÖØиÄдÁËC0S³ÌÐò,È¥µôÁËËùÓеÄDOSÖжÏ
µ÷ÓÃ.
Nachos²»ÄÜÖ±½ÓÔËÐбàÒëÆ÷Éú³ÉµÄ¿ÉÖ´ÐгÌÐò.±ØÐ뽫¿ÉÖ´ÐгÌÐòµÄÍ·²¿×ª»»³É
NachosÒªÇóµÄ¸ñʽ.È»ºó°ÑËü¿½ÈëNachosµÄÎļþϵͳ.ÕâÑùNachos²ÅÄÜÔËÐÐÕâЩ³ÌÐò.
Nachos¿ÉÖ´ÐÐÎļþµÄÍ·²¿°üº¬µÄÐÅÏ¢ÓгÌÐòÖÐÓм¸¸öÊý¾Ý¶Î,´úÂë¶ÎºÍÕ»¶Î,ÿ¶ÎµÄ³¤
¶È¼°ÔÚÎļþÖеÄλÖÃ,Ö¸ÁîÖ¸ÕëºÍ´úÂë¶Î¼Ä´æÆ÷µÄ³õÖµ.ÕâЩÐÅÏ¢¶¼¿ÉÒÔÔÚ±àÒëÆ÷Éú³É
µÄ¿ÉÖ´ÐÐÎļþÖÐÕÒµ½.
--
m¡ù À´Ô´:£®¹ÄÀËÌýÌÎÕ¾ bbs.xmu.edu.cn£®[FROM: mysu@JingXian.xmu.ed] m
--
m;32m¡ù ת¼Ä:£®»ªÄÏÍøľÃÞÕ¾ bbs.gznet.edu.cn£®[FROM: mtlab.hit.edu.cn]
--
Enjoy Linux!
-----It's FREE!-----
¡ù À´Ô´:£®×Ï ¶¡ Ïã bbs.hit.edu.cn£®[FROM: mtlab.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º210.746ºÁÃë