¸ñʽ£º 1)SCAS DST£» 2)SCASB(×Ö½Ú)£» 3)SCASW(×Ö) Ö´ÐеIJÙ×÷£º ×Ö½Ú²Ù×÷£º((AL))-(DI)£¬(DI)¡û(DI)¡À1 ×Ö²Ù×÷£º ((AX))-(DI)£¬(DI)¡û(DI)¡À2 Ö¸Áî°ÑAL(»òAX)µÄÄÚÈÝÓëÓÉ(DI)Ö¸¶¨µÄÔÚ¸½¼Ó¶ÎÖеÄÒ»¸ö×Ö½Ú(»ò×Ö)½øÐбȽϣ¬²¢²»±£´æ½á¹û£¬Ö»¸ù¾Ý½á¹ûÖÃÌõ¼þÂë¡£Ö¸ÁîµÄÆäËûÌØÐÔºÍMOVSµÄ¹æ¶¨Ïàͬ¡£ 4.3.5 ¿ØÖÆתÒÆÖ¸Áî Ò»°ãÇé¿öÏÂÖ¸ÁîÊÇ˳ÐòµØÖðÌõÖ´Ðеģ¬µ«Êµ¼ÊÉϳÌÐò²»¿ÉÄÜÈ«²¿Ë³ÐòÖ´Ðжø¾³£ÐèÒª¸Ä±ä³ÌÐòµÄÖ´ÐÐÁ÷³Ì£¬¿ØÖÆתÒÆÖ¸Áî·Ö³ÉÎÞÌõ¼þתÒÆÖ¸ÁîºÍÌõ¼þתÒÆÖ¸ÁîÁ½´óÀà¡£ 1.ÎÞÌõ¼þתÒÆÖ¸Áî ÎÞÌõ¼þµØתÒƵ½Ö¸ÁîÖ¸¶¨µÄµØÖ·È¥Ö´ÐдӸõØÖ·¿ªÊ¼µÄÖ¸ÁתÒÆ¿ÉÒÔ·Ö³ÉÁ½Àࣺ¶ÎÄÚתÒƺͶμäתÒÆ¡£¶ÎÄÚתÒÆÊÇÖ¸ÔÚͬһ¶ÎµÄ·¶Î§Ö®ÄÚ½øÐÐתÒÆ£¬´ËʱֻÐè¸Ä±äIP¼Ä´æÆ÷µÄÄÚÈÝ£¬¼´ÓÃеÄתÒÆÄ¿±êµØÖ·´úÌæÔÓеÄIPµÄÖµ¾Í¿É´ïµ½×ªÒƵÄÄ¿µÄ¡£¶Î¼äתÒÆÔòÊÇҪתµ½ÁíÒ»¸ö¶ÎÈ¥Ö´ÐгÌÐò£¬´Ëʱ²»½öÒªÐÞ¸ÄIP¼Ä´æÆ÷µÄÄÚÈÝ£¬»¹ÐèÒªÐÞ¸ÄCS¼Ä´æÆ÷µÄÄÚÈݲÅÄܴﵽĿµÄ£¬Òò´Ë£¬´ËʱµÄתÒÆÄ¿±êµØÖ·Ó¦ÓÉеĶεØÖ·ºÍÆ«ÒƵØÖ·Á½²¿·Ö×é³É¡£ 1) Ö±½Ó¶ÌתÒÆ£º ¸ñʽ£ºJMP SHORT OPR Ö´ÐеIJÙ×÷£º(IP)<--(IP)+8λλÒÆÁ¿ ÆäÖÐ8λλÒÆÁ¿ÊÇÓÉÄ¿±êµØÖ·OPR È·¶¨µÄ¡£×ªÒƵÄÄ¿±êµØÖ·ÔÚ»ã±à¸ñʽÖпÉÖ±½ÓʹÓ÷ûºÅµØÖ·£¬¶øÔÚ»úÆ÷Ö´ÐÐʱÔòÊǵ±Ç°µÄIP Öµ(¼´JMPÖ¸ÁîµÄÏÂÒ»ÌõÖ¸ÁîµÄµØÖ·)ÓëÖ¸ÁîÖÐÖ¸¶¨µÄ8λתÒƸñʽֻÔÊÐíÔÚ-128µ½+127×ֽڵķ¶Î§ÄÚתÒÆ¡£ 2) ¶ÎÄÚÖ±½Ó½üתÒÆ£º ¸ñʽ£ºJMP NEAR RTP OPR Ö´ÐеIJÙ×÷£º(IP)<-- (IP)+16λλÒÆÁ¿ ¿ÉÒÔ¿´³ö³ýλÒÆÁ¿Î»16λÍ⣬ËüºÍ¶ÎÄÚ¶ÌתÒÆÒ»Ñù£¬Ò²²ÉÓÃÏà¶ÔÑ°Ö··½Ê½£¬ÔÚ»ã±à¸ñʽÖÐOPRÒ²Ö»ÐèҪʹÓ÷ûºÅµØÖ·¡£ÓÉÓÚλÒÆÁ¿Î»16룬Ëü¿ÉÒÔתÒƵ½¶ÎÄÚµÄÈÎÒ»¸öλÖᣠ3) ¶ÎÄÚ¼ä½ÓתÒÆ£º ¸ñʽ£ºJMP WORD PRT OPR Ö´ÐеIJÙ×÷£º(IP)<- (EA) ÓÉÓÚÓÐЧµØÖ·EAÖµÓÉOPRµÄÑ°Ö··½Ê½È·¶¨¡£Ëü¿ÉÒÔʹÓóýÁ¢¼´Êý·½Ê½ÒÔÍâµÄÈÎÒ»ÖÖÑ°Ö··½Ê½£¬Èç¹ûÖ¸¶¨µÄÊÇ16λ¼Ä´æÆ÷µÄÄÚÈÝË͵½IP¼Ä´æÆ÷ÖУ»Èç¹ûÖ¸¶¨µÄÊÇ´æ´¢Æ÷ÖеÄÒ»¸ö×Ö£¬Ôò°Ñ¸Ã´æ´¢µ¥ÔªµÄÄÚÈÝË͵½IP¼Ä´æÆ÷ÖÐÈ¥¡£ÔÚ4.1.3½ÚÖÐÎÒÃÇÒѾ˵Ã÷£¬ÕâÀï²»ÔÙϸÊö¡£ 4) ¶Î¼äÖ±½Ó(Ô¶)תÒÆ£º ¸ñʽ£ºJMP WORD PTR OPR Ö´ÐеIJÙ×÷£º(IP)<- OPR µÄ¶ÎÄÚÆ«ÒƵØÖ· (CS)<- OPR ËùÔڶεĶεØÖ· ÔÚÕâÀïʹÓõÄÊÇÖ±½ÓÑ°Ö··½Ê½¡£ÔÚ»ã±à¸ñʽÖÐOPR¿ÉʹÓ÷ûºÅµØÖ·£¬¶ø»úÆ÷ÓïÑÔÖÐÔòÒªÖ¸¶¨×ªÏòµØÖ·µÄÆ«ÒƵØÖ·ºÍ¶ÎµØÖ·¡£ 5) ¶Î¼ä¼ä½ÓתÒÆ£º ¸ñʽ£º JMP DWORD PTR OPR Ö´ÐеIJÙ×÷£º(IP)<- (EA) (CS)<-- EA+2)
13
ÆäÖÐEAÓÉOPRµÄÑ°Ö··½Ê½È·¶¨£¬Ëü¿ÉÒÔʹÓóýÁ¢¼´Êý¼°¼Ä´æÆ÷·½Ê½ÒÔÍâµÄÈκδ洢Æ÷Ñ°Ö··½Ê½£¬¸ù¾ÝÑ°³¶·½Ê½Çó³öEAºó£¬°ÑÖ¸¶¨´æ´¢µ¥ÔªµÄµÚÒ»¸ö×ÖµÄÄÚÈÝË͵½IP¼Ä´æÆ÷£¬²¢°ÑÏÂÒ»¸ö×ÖµÄÄÚÈÝË͵½CS¼Ä´æÆ÷£¬ÕâÑù¾ÍʵÏÖÁ˶μäÌøת¡£ ×îºó˵Ã÷һϣ¬JMPÖ¸Áî²»Ó°ÏìÌõ¼þÂë¡£ 2.Ìõ¼þתÒÆÖ¸Áî Ìõ¼þתÒÆÖ¸Áî¸ù¾ÝÉÏÒ»ÌõÖ¸ÁîËùÉèÖõÄÌõ¼þÂëÀ´Åбð²âÊÔÌõ¼þ£¬Ã¿Ò»ÖÖÌõ¼þתÒÆÓÐËüµÄ²âÊÔÌõ¼þ£¬Âú×ã²âÊÔÌõ¼þÔòתÒƵ½ÓÉÖ¸ÁîÖ¸³öµÄתÏòµØÖ·È¥Ö´ÐÐÄÇÀïµÄ³ÌÐò£»Èç²»Âú×ãÌõ¼þÔò˳ÐòÖ´ÐÐÏÂÒ»ÌõÖ¸Áî¡£Òò´Ë£¬µ±Âú×ãÌõ¼þʱ£º(IP)<-- (IP)+·ûºÅÀ©Õ¹µ½16λºóµÄλÒÆÁ¿D8£¬Èç²»Âú×ã²âÊÔÌõ¼þÔò(IP)²»±ä¡£¿É¼ûÌõ¼þתÒÆÖ¸ÁîʹÓÃÁËÏà¶ÔÑ°Ö··½Ê½£¬ÔÚ»ã±à¸ñʽÖÐOPRÓ¦Ö¸¶¨Ò»¸öÄ¿±êµØÖ·£¬Õâ¸öÄ¿±êµØÖ·Ó¦ÔÚ±¾ÌõתÒÆÖ¸ÁîÏÂÒ»ÌõÖ¸ÁîµØÖ·µÄ-128µ½+127¸ö×ֽڵķ¶Î§Ö®ÄÚ¡£ÁíÍ⣬ËùÓеÄÌõ¼þתÒÆÖ¸Á²»Ó°ÏìÌõ¼þÂë¡£ÏÂÃæÎÒÃÇ°ÑÌõ¼þתÒÆÖ¸Áî·ÖΪËÄ×éÀ´ÌÖÂÛ¡£ 1)¸ù¾Ýµ¥¸öÌõ¼þé˵ÄÉèÖÃÇé¿öתÒÆ¡£Õâ×é°üÀ¨10ÖÖÖ¸Áî¡£ËüÃÇÒ»°ãÊÊÓÃÓÚ²âÊÔijһ´ÎÔËËãµÄ½á¹û²¢¸ù¾ÝÆ䲻ͬÌØÕ÷²úÉú³ÌÐò·ÖÖ§×÷²»Í¬´¦ÀíµÄÇé¿ö¡£ ¢Ù JZ(»òJE)(Jump if zero,or equal)½á¹ûΪÁã(»òÏàµÈ)ÔòתÒÆ¡£ ¸ñʽ£ºJZ(»òJE) OPR ²âÊÔÌõ¼þ£ºZF=1 ¢Ú JNZ(»òJNE)(Jump if zero,or equal)½á²»ÎªÁã(»ò²»ÏàµÈ)ÔòתÒÆ¡£ ¸ñʽ£ºJNZ(»òJNE) OPR ²âÊÔÌõ¼þ£ºZF=0 ¢Û JS(Jump if sign)½á¹ûΪ¸ºÔòתÒÆ ¸ñʽ£ºJS OPR ²âÊÔÌõ¼þ£ºSF=1 ¢Ü JNS(Jump if not sign)½á¹ûΪÕýÔòתÒÆ ¸ñʽ£ºJNS OPR ²âÊÔÌõ¼þ£ºSF=0 ¢Ý JO (Jump if overflow)Òç³öÔòתÒÆ ¸ñʽ£ºJO OPR ²âÊÔÌõ¼þ£ºOF=1 ¢Þ JNO(Jump if not overflow)²»Òç³öÔòתÒÆ ¸ñʽ£ºJNO OPR ²âÊÔÌõ¼þ£ºOF=0 ¢ß JP(»òJPE)(Jump if parity, or parity even)ÆæżλΪ1ÔòתÒÆ¡£ ¸ñʽ£ºJP(»òJPE) OPR ²âÊÔÌõ¼þ£ºPF=1 ¢à JNP(»òJPO)(Jump if not parity, or parity odd)ÆæżλΪ0ÔòתÒÆ ¸ñʽ£ºJNP(»òJPO) OPR ²âÊÔÌõ¼þ£ºPF=0 ¢á JB(»òJNAE£¬JC)(Jump if below,or not above or equal,or carry)µÍÓÚ£¬»òÕß²»¸ßÓÚ»òµÈÓÚ£¬»ò½øλΪ1ÔòתÒÆ¡£ ¸ñʽ£ºJB(»òJNAE£¬»òJC) OPR ²âÊÔÌõ¼þ£ºCF=1 ¢â JNB(»òJAE£¬»òJNC)(Jump if not below,or above or equal ,or ont carry)²»µÍÓÚ£¬»òÕ߸ßÓÚ»òµÈÓÚ£¬»ò½øλΪÁãÔòתÒÆ
14
¸ñʽ£ºJNB(»òJAE£¬»òJNC) OPR ²âÊÔÌõ¼þ£ºCF=0 Àý4.3.16: ±È½ÏÁ½¸öÊýÊÇ·ñÏàµÈ£¬ÈçÏàµÈ×ö¶¯×÷1£¬·ñÔò×ö¶¯×÷2.¿É±àд³ÌÐòΪ£º ? CMP AX£¬BX JE ACTION_2 ? }ACTION_1 ACTION_2: ? }ACTION_2 »òÕߣº ? CMP AX£¬BX JNZ ACTION_2 ? }ACTION_1 ACTION_1 ? }ACTION_2 2) ±È½ÏÁ½¸öÎÞ·ûºÅÊý£¬²¢¸ù¾Ý±È½ÏµÄ½á¹ûתÒÆ¡£ ¢Ù JB(»òJNAE£¬JC)µÍÓÚ£¬»òÕß²»¸ßÓÚ»òµÈÓÚ£¬»ò½øλΪ1ÔòתÒÆ¡£ ¢Ú JNB(»òJAE£¬»òJNC)²»µÍÓÚ£¬»òÕ߸ßÓÚ»òµÈÓÚ£¬»ò½øλΪÁãÔòתÒÆ ÒÔÉÏÁ½ÖÖÖ¸ÁîÓëÉÏÒ»×éÖ¸ÁîÖеÄ×îºóÁ½ÖÖÍêÈ«Ïàͬ¡£ ¢Û JBE(»òJNA£¬(Jump if below or equal,or not above )µÍÓÚ»òµÈÓÚ£¬»ò²»¸ßÓÚÔòתÒÆ¡£ ¸ñʽ£ºJBE(»òJNA) OPR ²âÊÔÌõ¼þ£ºCF V ZF=0 3) ±È½ÏÁ½¸ö´ø·ûºÅÊý£¬²¢¸ù¾Ý±È½Ï½á¹ûתÒÆ¡£ ¢Ù JL»ò(JNGE)(Jump if not less ,or not greater or equal )СÓÚ£¬»òÕß²»´óÓÚ»òÕßµÈÓÚÔòתÒÆ¡£ ¸ñʽ£º JL(»òJNGE) OPR ²âÊÔÌõ¼þ£ºCF V ZF=0 ¢Ú JNL»ò(JGE)(Jump if not less ,or greater or equal)²»Ð¡ÓÚ£¬»òÕß²»´óÓÚ»òÕßµÈÓÚÔòתÒÆ¡£ ¸ñʽ£ºJNL(»òJGE) OPR ²âÊÔÌõ¼þ£ºCF V ZF=0 ¢Û JLE»ò(JNG)(Jump if not less ,or not greater)СÓÚ»òµÈÓÚ£¬»òÕß²»´óÓÚÔòתÒÆ¡£ ¸ñʽ£ºJLE(»òJNG) OPR ²âÊÔÌõ¼þ£º(SF OF) V ZF=1 ¢Ü JNLE»ò(JG)(Jump if not less or equal,or greater)²»Ð¡ÓÚ»òµÈÓÚ£¬»òÕß´óÓÚÔòתÒÆ¡£ ¸ñʽ£º JNLE(»òJG) OPR ²âÊÔÌõ¼þ£º(SF OF) V ZF=0 4) ²âÊÔCXµÄֵΪ0ÔòתÒÆÖ¸Áî JCXZ(Jump if CX register is zero) CX¼Ä´æÆ÷µÄÄÚÈÝΪÁãÔòתÒÆ¡£
15
¸ñʽ£ºJCXZ OPR ²âÊÔÌõ¼þ£º(CX)=0 CX¼Ä´æÆ÷¾³£ÓÃÀ´ÉèÖüÆÊýÖµ£¬ËùÒÔÕâÌõÖ¸Áî¿ÉÒÔ¸ù¾ÝCX¼Ä´æÆ÷ÄÚÈݵÄÐÞ¸ÄÇé¿öÀ´²úÉúÁ½¸ö²»Í¬³ÌÐò·ÖÖ§¡£ 3.Ñ»·Ö¸Áî (1) LOOP(LOOP)Ñ»·Ö¸Áî ¸ñʽ£ºLOOP OPR ²âÊÔÌõ¼þ£º(CX)¡Ù0 (2) LOOPZ/LOOPE(Loop while zero£¬or equal)µ±ÎªÁã»òÏàµÈʱѻ·Ö¸Áî ¸ñʽ£ºLOOPZ(»òLOOPE) OPR ²âÊÔÌõ¼þ£ºZF=1ÇÒ(CX)¡Ù0 (3) LOOPNZ/LOOPNE(loop while nonzero£¬or not equal)µ±²»ÎªÁã»ò²»ÏàµÈʱѻ·Ö¸Áî ¸ñʽ£ºLOOPNZ(»òLOOPNE) OPR ²âÊÔÌõ¼þ£ºZF=0ÇÒ(CX)¡Ù0 ÕâÈýÌõÖ¸ÁîµÄÖ´Ðв½ÖèÊÇ£º 1) (CX)¡´--(CX) - 1 2) ¼ì²éÊÇ·ñÂú×ã²âÊÔÌõ¼þ£¬ÈçÂú×ãÔò(IP)¡´--(IP)+D8µÄ·ûºÅÀ©Õ¹¡£ ¿É¼ûÕâÀïʹÓõÄÊÇÏà¶Ô·½Ê½£¬ÔÚ»ã±à¸ñʽÖÐOPR±ØÐëÖ¸¶¨Ò»¸ö±íʾתÏòµØÖ·µÄ±êºÅ(·ûºÅµØÖ·)£¬¶øÔÚ»úÆ÷Ö¸ÁîÀïÔòÓÃ8λλÒÆÁ¿D8À´±íʾתÏòµØÖ·Ó뵱ǰIPÖµµÄ²î¡£ÓÉÓÚλÒÆÁ¿Ö»ÓÐ8룬ËùÒÔתÏòµØÖ·±ØÐëÔÚ¸ÃÑ»·Ö¸ÁîµÄÏÂÒ»ÌõÖ¸ÁîµØÖ·µÄ-128~+127×ֽڵķ¶Î§Ö®ÄÚ¡£µ±Âú×ã²âÊÔÌõ¼þ¾ÍתÏòµØÖ·È¥Ö´ÐУ¬¼´ÊµÐÐÑ»·£¬Èç²»Âú×ã²âÊÔÌõ¼þÔòIPÖµ²»±ä£¬¼´Í˳öÑ»·£¬³ÌÐò¼ÌÐø˳ÐòÖ´ÐС£ Ñ»·Ö¸Áî²»Ó°ÏìÌõ¼þÂë¡£ ³ýLOOPÖ¸ÁîÍâÁíÍâÁ½ÌõLOOPZºÍLOOPNZÖ¸ÁîÌṩÁËÌáÇ°½áÊøÑ»·µÄ¿ÉÄÜÐÔ¡£ÓÐʱÐèÒªÔÚ×Ö·û´®ÖвéÕÒÒ»¸ö×Ö·û£¬ÔÚÕÒµ½ºó¾Í¿ÉÌáÇ°½áÊøÑ»·¶ø²»ÐèÒªÒ»Ö±²éÕÒµ½µ×ÁË¡£´Ëʱ¾ÍLOOPZ»òLOOPNZÀ´´¦Àí¡£ 4.×Ó³ÌÐò ×Ó³ÌÐò½á¹¹Ï൱Óڸ߼¶ÓïÑÔÖеĹý³Ì¡£±ãÓÚÄ£¿é»¯³ÌÐòÉè¼Æ£¬ÍùÍù°Ñ³ÌÐòÖÐijЩ¾ßÓжÀÁ¢¹¦ÄܵIJ¿·Ö±àд³É¶ÀÁ¢µÄ³ÌÐòÄ£¿é£¬³Æ֮Ϊ×Ó³ÌÐò.³ÌÐòÖпÉÓɵ÷ÓóÌÐò(»ò³ÆÖ÷³ÌÐò)µ÷ÓÃÕâЩ×Ó³ÌÐò£¬¶øÔÚ×Ó³ÌÐòÖ´ÐкóÓÖ·µ»Øµ÷ÓóÌÐò¼ÌÐøÖ´ÐС£ÎªÊµÏÖÕâÒ»¹¦ÄÜ£¬IBM-PC»úÌṩÁËÒÔÏÂÖ¸Á (1) CALL(call)µ÷ÓÃÖ¸Áî 1) ¶ÎÄÚÖ±½Óµ÷Óà ¸ñʽ£ºCALL DST Ö´ÐеIJÙ×÷£º1) (SP)¡´-- (SP)-2£» ((SP)+1£¬(SP))¡´-- (IP) 2) (IP)¡´-- (IP)+D16 ¿ÉÒÔ¿´³ö£¬ÕâÌõÖ¸ÁîµÄµÚÒ»²½²Ù×÷ÊÇ°Ñ×Ó³ÌÐòµÄ·µ»ØµØÖ·(¼´µ÷ÓóÌÐòCALLÖ¸ÁîµÄÏÂÒ»ÌõÖ¸ÁîµÄµØÖ·)´æÈë¶ÑÕ»ÖУ¬ÒÔ±ã×Ó³ÌÐò·µ»ØÖ÷³ÌÐòʱʹÓᣵڶþ²½²Ù×÷ÔòÊÇתÒƵ½×Ó³ÌÐòµÄÈë¿ÚµØÖ·¼ÌÐøÖ´ÐС£Ö¸ÁîÖÐDST¸ø³öתÏòµØÖ·(¼´×Ó³ÌÐòµÄÈë¿ÚµØÖ·£¬Ò²¾ÍÊÇ×Ó³ÌÐòµÄµÚÒ»ÌõÖ¸ÁîµÄµØÖ·)£¬D16¼´Îª»úÆ÷Ö¸ÁîÖеÄλÒÆÁ¿£¬ËüÊÇתÏòµØÖ·ºÍ·µ»ØµØÖ·Ö®¼äµÄ²îÖµ¡£ 2) ¶ÎÄÚ¼ä½Óµ÷Óà ¸ñʽ£ºCALL DST Ö´ÐеIJÙ×÷£º1) (SP)¡´-- (SP)-2£» ((SP)+1£¬(SP))¡´-- (IP) 2) (IP)¡´-- (EA)
16