»ã±àÓïÑÔÖÐSARºÍSHRÖ¸ÁîµÄÇø±ð
1¡¢·½Ïò²»Í¬ ͨ¹ýgdb¶¯Ì¬µ÷ÊԵõ½Ã¿´ÎÑ»·µÄÖµ½øÐбȶԣ¬²Å·¢ÏÖ³öÏÖ´íÎóµÄ¾ßÌåÔÒò¡£sarÔÚ·ûºÅλΪ1ʱ£¬ÓÒÒÆʱÌî³ä1£¬·ûºÅλΪ0ʱÌî³ä0¡£¶øpythonĬÈϵÄÓÒÒÆÔËËãΪÂß¼ÓÒÒÆÔËË㣬ÓÒÒÆʱĬÈÏÌî³ä0£¬Óë·ûºÅλÎ޹ء£ 2¡¢×÷Óò»Í¬ »ã±àÓïÑÔÖÐSARºÍSHRÖ¸ÁÊÇÓÒÒÆÖ¸ÁSARÊÇËãÊýÓÒÒÆÖ¸Áshift arithmetic right£©£¬¶øSHRÊÇÂß¼ÓÒÒÆÖ¸Áshift logical right£©¡£SARÓÒÒÆʱ±£Áô²Ù×÷ÊýµÄ·ûºÅ£¬¼´Ó÷ûºÅλÀ´²¹×㣬¶øSHRÓÒÒÆʱ×ÜÊÇÓÃ0À´²¹×ã¡£ÀýÈç10000000ËãÊýÓÒÒÆһλÊÇ11000000£¬¶øÂß¼ÓÒÒÆһλÊÇ01000000¡£ 3¡¢Ë³Ðò²»Í¬ SARÊÇËãÊõÓÒÒÆ£¬±È½ÏÌØÊâ¡£ËûµÄ×î¸ßλһֱÊDz»±äµÄ¡£Èç1000 0000ËãÊõÓÒÒÆ7λºó¾Í³ÉÁË1111 1111¡£SARÓÒÒƵÄʱºò£¬×î¸ßλ²»±ä£¬×îµÍλÒÆÈëCF¡£ ²Î¿¼×ÊÁÏÀ´Ô´£º°Ù¶È°Ù¿Æ¡ª»ã±àÓïÑÔ
SHRµÄÂß¼ÓÒÒÆ
Âß¼ÓÒÒÆSHR¡¡SHRÖ¸ÁîÓ°Ïì±ê־λCFºÍOF¡£Èç¹ûÒÆλ´ÎÊýΪ1£¬ÇÒÒÆλºó·ûºÅλµÄÖµ·¢Éú±ä»¯£¬ÔòOF=1£¬·ñÔòOF=0.Èç¹ûÒÆλ´ÎÊý²»Îª1£¬ÔòOF²»È·¶¨¡£¡¾¸ñʽ¡¿£ºSHR OPR.CNT¡£ÆäÖÐOPRÓóýÁ¢¼´ÊýÍâµÄÈκÎÑ°Ö··½Ê½¡£ÒÆλ´ÎÊýÓÉCNT¾ö¶¨£¬ÔÚ8086ÖпÉÒÔÊÇ1»òCL£¬CNTΪ1ʱֻÒÆһλ¡£Èç:MOV AX,62HSHR AX,1µ±ÒÆλÊý´óÓÚ1ʱ£¬ÐèÒªÏȽ«ÒÆλÊý·Å½øCLÖÐÈ»ºóÔÙ½øÐÐÒÆλ²Ù×÷¡£¿ÉÒÔʹÓÃ8λÁ¢¼´ÊýÖ¸¶¨·¶Î§´Ó1µ½31µÄÒÆλ´ÎÊý¡£ÈçMOV AL,62HMOV CL,4SHR AL,CLËùÖ´ÐмòÒ×Àí½âÈçÏ£º01100010B ÒòΪÊÇÓÒÒƲÙ×÷£¬Ò²³ÆΪÓÒÒƲ¹0²Ù×÷£¬½«¶þ½øÖÆλÖð´ÎÔÚÓÒ±ßÈ¥µôһλȻºóÔÚ×ó±ßÌí¸ö0£¬ÒƶàÉÙλÖظ´ÉÏÊö²Ù×÷¶àÉٴΡ£4´ÎÒÆλºó½á¹ûΪ00000110B,¼´06H.¡¾Ó¦Óá¿ Âß¼ÓÒÒÆһλµÄ²Ù×÷£¬Ï൱ÓÚ½«¼Ä´æÆ÷»ò´æ´¢Æ÷µÄÎÞ·ûºÅÊý³ýÒÔ2£¬Òò´ËͬÑù¿ÉÒÔÓÃSHRÖ¸ÁîÍê³É³ýÒÔijЩ³£ÊýµÄÔËËã¡£¶øÇÒÒÆλָÁîͨ³£±È³ý·¨Ö¸ÁîʱÔËÐÐËÙ¶ÈÒª¿ìµÃ¶à¡£ ³ýSHRÍ⣬ÒÆλָÁ°üÀ¨ÒÔÏÂÃüÁSHL(shift logical left) Âß¼×óÒÆSAL(shift arithmetic left) ËãÊõ×óÒÆSAR(shift arithmetic right) ËãÊõÓÒÒÆROL(rotat left) Ñ»·×óÒÆROR(rotat right) Ñ»·ÓÒÒÆRCL(rotate left through carry) ´ø½øλѻ·×óÒÆRCR(rotate right through carry) ´ø½øλѻ·ÓÒÒÆSHLD(shift left double) Ë«¾«¶È×óÒÆSHRD(shift right double) Ë«¾«¶ÈÓÒÒÆ
΢»úÔÀíÖÐSHL SAL SHR SAR ROL RCL RCR RCL Ö¸Áîµ½µ×ÔõôÓð¡¡£¡£×Ô¼º
¿ÉÒÔ½«Õ⼸¸öÖ¸Áî·ÖΪÒÆλָÁîºÍÑ»·ÒÆλָÁÆäÖÐλÒÆÖ¸ÁîΪ:SHL¡¢SAL¡¢SHR¡¢SAR£¬Ñ»·Î»ÒÆÖ¸ÁîΪ£ºROL¡¢RCL¡¢RCR¡¢RCL£¬ËûÃǵľßÌåÓ÷¨ÈçÏ£º Ò»¡¢Î»ÒÆÖ¸Áî ¾ßÌ庬Ò壺SHL: Âß¼×óÒÆ£»SAL: ËãÊõ×óÒÆ£»SHR: Âß¼ÓÒÒÆ£»SAR: ËãÊõÓÒÒÆ ¾ßÌåÓ÷¨£ºSHR:ÿλÓÒÒÆ, µÍλ½ø CF, ¸ßλ²¹ 0£»SAR£ºÃ¿Î»ÓÒÒÆ, µÍλ½ø CF, ¸ßλ²»±ä£¬ËüÃǵĽá¹ûÓ°Ïì OF¡¢SF¡¢ZF¡¢PF¡¢ ¶þ¡¢Ñ»·ÒÆλָÁî ¾ßÌ庬Ò壺ROL:Ñ»·×óÒÆ£»ROR:Ñ»·ÓÒÒÆ£»RCL: ´ø½øλѻ·×óÒÆ£»RCR: ´ø½øλѻ·ÓÒÒÆ¡£ ¾ßÌåÓ÷¨£ºROL: Ñ»·×óÒÆ, ¸ßλµ½µÍλ²¢ËÍ CF;ROR: Ñ»·ÓÒÒÆ, µÍλµ½¸ßλ²¢ËÍ CF£»RCL: Ñ»·×óÒÆ, ½øλֵµ½µÍλ, ¸ßλ½ø CF£»RCR: Ñ»·ÓÒÒÆ, ½øλֵµ½¸ßλ, µÍλ½ø CF¡£ À©Õ¹×ÊÁÏ£º Ë«¾«¶ÈÒÆλָÁ386¼°Æäºó¼Ì»úÐÍ¿ÉʹÓñ¾×éÖ¸ÁSHLDË«¾«¶È×óÒƺÍSHRDË«¾«¶ÈÓÒÒÆ£¬¸ñʽ£ºSHLD,DST,REG,CNT¡£ Õâ×éÖ¸Áî¿ÉÒÔÈ¡Á½¸ö×Ö×÷ÒÆλ²Ù×÷¶øµÃµ½Ò»¸ö×ֵĽá¹û£¬Ò²¿ÉÒÔÈ¡Á½¸öË«×Ö×÷ÒÆλ²Ù×÷¶øµÃµ½Ò»¸öË«×ֵĽá¹û¡£ ÔÚÒÆλÖУ¬×÷ΪԴ²Ù×÷ÊýµÄ¼Ä´æÆ÷ÌṩÒÆλֵ£¬ÒÔ²¹Ä¿µÄ²Ù×÷ÊýÒòÒÆλÒýÆðµÄ¿Õȱ£¬¶øÖ¸ÁîÖ´ÐÐÍê³Éºó£¬Ö»È¡Ä¿µÄ²Ù×÷Êý×÷ΪÒÆλµÄ½á¹û£¬Ô´²Ù×÷Êý¼Ä´æÆ÷Ôò±£³ÖÖ¸ÁîÖ´ÐÐÇ°µÄÖµ²»±ä¡£
΢»úÔÀíµÃÖ¸ÁîÎÊÌâ
ͨÓÃÊý¾Ý´«ËÍÀà
Êý¾ÝתÒÆÀàMOV
¶ÑÕ»Ö¸Áî PUSH POP
½»»» XCHG
²é±í XLAT
×ÖλÀ©Õ¹ CBW CWD
I/OÖ¸ÁîÀà
ÊäÈë IN
Êä³ö OUT
µØÖ·´«ËÍÀà
È¡Æ«ÒƵØÖ· LEA LDS LES
±êÖ¾´«ËÍ
LAHF SAHF PUSHF POPF
ËãÊõÖ¸Áî
¼Ó·¨£¨²»´ø½øλºÍ´ø½ø룩 ADD ADC
+1Ö¸Áî INC
¼õ·¨ SUB SBB
-1Ö¸Áî DEC
Çó²¹ NEG
±È½Ï CMP
³Ë·¨£¨ÎÞ·ûºÅ£¬ÓзûºÅ£© MUL IMUL
³ý·¨ DIV IDIV
BCDµ÷ÕûÖ¸Áî
DAA AAA DAS AAS AAM AAD
Âß¼ÔËËãÀà
AND OR NOT XOR TEST
ÒÆλ
SAL/SHL SHR SAR ROL ROR RCL RCR
´®²Ù×÷
Öظ´Ç°×º REP REPE REPZ REPNE REPNZ
MOVS/MOVSB/MOVSW
CMPS/CMPSB/CMPSW
SCAS/SCASB/SCASW
LODS/LODSB/LODSW
STOS/SYOSB/STOSW
³ÌÐò¿ØÖÆÀà
¸÷ÖÖJMPÖ¸Á´ó¸ÅÓÐ32¸ö£¬¸÷ÖÖÐÎʽµÄ
Ñ»·¿ØÖÆ LOOP/LOOPZ/LOOPE/LOOPNZ/LOOPNE
µ÷ÓÃ CALL RET
ÖÐ¶Ï INT INTO IRET
´¦ÀíÆ÷¿ØÖÆÀà
ÔÝÍ£ HLT
¿Õ²Ù×÷ NOP
µÈ´ý WAIT
×ÜÏßËø¶¨ LOCK
´¦ÀíÆ÷½»È¨ ESC
´ó¸Å¾ÍÕâЩÀà±ð£¬×¢ÒâͬÀàÖ¸Áͬ±íʾµÄº¬Ò壬¾ßÌåÄÚÈÝÌ«¶àÁËд³öÀ´²»ÏÖʵ£¬»¹ÊÇ×Ô¼º¿´Êé¡£ÍƼö·ë²©ÇÙÖ÷±àµÄ¡¶Î¢»úÔÀíÓë½Ó¿Ú¼¼Êõ¡·
ÁíÍâ¼ÇÖ¸Áî²»ÄÑ£¬¼Çס×Öĸ±íʾµÄÒâ˼¾ÍºÜºÃ¼Ç£¬±ÈÈ磺ZÊÇZF£¬CÊÇCF£¬PÊÇPFµÈµÈ£¬N±íʾNOTµÄÒâ˼£¬EÊÇENABLE£¬BÊÇBYTE×Ö½Ú£¬WÊÇWORD×ֵȵȵȵȣ¬¼ÇסÖú¼Ç·û±íʾµÄÓ¢ÓïÒâ˼¾ÍºÜºÃ¼Ç¡£
»ã±àÓïÑÔÖÐÂß¼ÔËËã·ûÔõô¼ÆËã
»ã±àÓïÑÔÂß¼ÔËËã(and£¬or£¬xor£¬..)(°´Î») »ò(or) ¸ñʽ£ºOR OPRD1£¬OPRD2 Ö¸ÁîÖ´Ðкó£ºCF=0£¬OF=0£¬±êÖ¾PF/ZF/SF·´Ó³ÔËËã½á¹û,±ê־λAF䶨Òå¡£×÷ÓÃ:±£Ö¤Ä³Ð©Î»²»±ä£¬Ä³Ð©Î»ÉèΪ1¡£ºÍ¡°0¡±×ö»òÔËËã±£³Ö²»±ä£¬ºÍ¡°1¡±×ö»òÔËËãÉèÖÃΪ1¡£Ä³¸ö²Ù×÷Êý×ÔÉí»ò£¬Öµ²»±ä¡£ eg£ºor eax,eax £»eax=00000008 je XXXXXXXX ;ÅжÏeax£¬Îª¿Õ¾ÍÌø¡£¡£Óû§Ãû»òÃÜÂëΪ¿Õ¾ÍÌø×ß¡£¡£ £»»òÖ®ºó£¬eaxÈÔΪ00000008 2.Òì»ò£¨xor£© ¸ñʽ£ºXOR OPRD1£¬OPRD2, Òì»òÖ´ÐеĹæÔòÈçÏ£º XOR 0,0 = 0 XOR 0,1 = 1 XOR 1,0 = 1 XOR 1,1 = 0 Ö¸ÁîÖ´Ðкó£ºCF=0£¬OF=0£¬±ê־λPF,ZF,SF·´Ó³ÔËËã½á¹û£¬±ê־ΪAF䶨Òå¡£ ×÷Ó㺺͡°0¡±Òì»ò±£³Ö²»±ä£¬ºÍ¡°1¡±Òì»òÔòÈ¡·´¡£ Èç¹ûÒ»¸ö²Ù×÷ÊýXOR A,A£¬ÔòA»á±»ÖÃ0£¬CF=OF=0,ZF=1£¬PF=1£¬SF=0 3.Óë(and) ¸ñʽ£ºAND OPRD1£¬OPRD2 Ö´ÐÐÖ¸Áîºó:CF = 0£¬OF = 0£¬±ê־λPF,ZF,SF·´Ó³ÔËËã½á¹û£¬±ê־λAF䶨Òå¡£ ij¸ö²Ù×÷Êý×Ô¼ºÓë×Ô¼ºÏà¡°Ó롱£¬ÔòÖµ²»±ä£¬¿ÉʹCFÇå0 ×÷ÓãºÊÇʹ²Ù×÷ÊýÖеÄijЩΪ±£³Ö²»±ä£¬ÆäËüΪÇåÁã¡£ºÍ"1"Óë±£³Ö²»±ä£¬ºÍ¡°0¡±ÓëÇåÁã¡£ 4.·ñ(NOT) Ö¸Áî¸ñʽÈçÏ£º NOT OPRD Ö´ÐÐÖ¸Áîºó:OPRD¸÷λȡ·´£¬²Ù×÷Êý¿ÉÊÇͨÓüĴæÆ÷¿ÉÊÇ´æ´¢µ¥Ôª£¬µ«ÊDz»ÄÜÊÇÁ¢¼´ Êý¡£¶Ô±ê־λûÓÐÓ°Ïì¡£