{"id":506,"date":"2026-03-07T19:59:02","date_gmt":"2026-03-07T11:59:02","guid":{"rendered":"http:\/\/8.129.82.128\/?p=506"},"modified":"2026-03-07T19:59:02","modified_gmt":"2026-03-07T11:59:02","slug":"8086%e6%b1%87%e7%bc%9611","status":"publish","type":"post","link":"http:\/\/8.129.82.128\/?p=506","title":{"rendered":"8086\u6c47\u7f16#11"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>\u7b2c\u5341\u4e00\u7ae0 \u6807\u5fd7\u5bc4\u5b58\u5668 &#8211; \u6c47\u7f16\u8bed\u8a00\u63d0\u7eb2<\/title>\n    <style>\n        #asm-wrapper {\n            all: initial;\n            display: block;\n            width: 100%;\n            min-height: 100vh;\n            margin: 0;\n            padding: 30px 25px;\n            box-sizing: border-box;\n            font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Microsoft YaHei\", sans-serif !important;\n            line-height: 1.8;\n            background: linear-gradient(180deg, #d4ecf7 0%, #a8e6cf 50%, #88d8b0 100%) !important;\n            color: #2c3e50 !important;\n        }\n        #asm-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }\n        #asm-wrapper h1 { text-align: center; color: #1a5276 !important; font-size: 1.8em; border-bottom: 3px solid #27ae60 !important; padding-bottom: 15px; }\n        #asm-wrapper h2 { color: #1e8449 !important; border-left: 4px solid #27ae60 !important; padding-left: 15px; margin-top: 30px; }\n        #asm-wrapper h3 { color: #196f3d !important; margin-top: 20px; }\n        #asm-wrapper p { margin: 10px 0; }\n        #asm-wrapper ul, #asm-wrapper ol { margin: 10px 0; padding-left: 25px; }\n        #asm-wrapper li { margin: 5px 0; }\n        #asm-wrapper strong { color: #e74c3c !important; font-weight: 700 !important; }\n        #asm-wrapper pre { background: #1e3d2f !important; color: #a8e6cf !important; padding: 15px 20px; border-radius: 8px; overflow-x: auto; font-size: 0.85em; line-height: 1.6; margin: 15px 0; border: 2px solid #27ae60; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }\n        #asm-wrapper pre code { background: none !important; padding: 0; color: inherit !important; border: none; }\n        #asm-wrapper table { width: 100%; border-collapse: collapse; margin: 15px 0; font-size: 0.9em; }\n        #asm-wrapper th, #asm-wrapper td { border: 1px solid #7f8c8d; padding: 10px 12px; text-align: left; }\n        #asm-wrapper th { background: #27ae60 !important; color: white !important; }\n        #asm-wrapper tr:nth-child(even) { background: #d5f5e3 !important; }\n        #asm-wrapper img { max-width: 100%; height: auto; display: block; margin: 25px 0; padding: 15px; background: white !important; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); border: 2px solid #27ae60; }\n        #asm-wrapper hr { border: none; border-top: 2px dashed #27ae60; margin: 30px 0; }\n<\/style>\n<\/head>\n<body>\n    <div id=\"asm-wrapper\">\n        <h1>\u7b2c\u5341\u4e00\u7ae0 \u6807\u5fd7\u5bc4\u5b58\u5668<\/h1>\n        \u7b2c\u5341\u4e00\u7ae0 <![endif]><strong>\u6807\u5fd7\u5bc4\u5b58\u5668<\/strong><strong><\/strong><\/p>\n<p><img decoding=\"async\" width=\"349\"  height=\"69\"  src=\"http:\/\/8.129.82.128\/wp-content\/uploads\/2026\/03\/asm202405\u7248\u63d0\u7eb261110.png\"  align=\"left\"  hspace=\"12\" >11.0 \u7eea\u8bba<\/p>\n<p><strong>\u6807\u5fd7\u5bc4\u5b58\u5668<\/strong>\u7684\u4f5c\u7528:<\/p>\n<p><![if !supportLists]>(1) <![endif]><strong>\u5b58\u50a8\u76f8\u5173\u6307\u4ee4\u7684\u6267\u884c\u7ed3\u679c<\/strong><strong><\/strong><\/p>\n<p><![if !supportLists]>(2) <![endif]><strong>\u4e3aCPU\u6267\u884c\u76f8\u5173\u6307\u4ee4\u63d0\u4f9b\u884c\u4e3a\u4f9d\u636e<\/strong><strong><\/strong><\/p>\n<p><![if !supportLists]>(3) <![endif]><strong>\u63a7\u5236CPU\u7684\u76f8\u5173\u5de5\u4f5c\u65b9\u5f0f<\/strong><strong><\/strong><\/p>\n<p>\u6807\u5fd7\u5bc4\u5b58\u5668(flag)\u4e2d\u5b58\u50a8\u7684\u4fe1\u606f\u53eb\u505a<strong>\u7a0b\u5e8f\u72b6\u6001\u5b57<\/strong>(PSW)<\/p>\n<p>flag\u6309\u4f4d\u8d77\u4f5c\u7528,\u7ed3\u6784\u5982\u56fe11.1<\/p>\n<p>\u5176\u4e2d\u76841\u30013\u30015\u300112\u300113\u300114\u300115\u4f4d\u57288086CPU\u4e2d\u4e0d\u8d77\u4f5c\u7528<\/p>\n<p>11.1~11.5 \u6807\u5fd7\u5bc4\u5b58\u5668\u7684\u5404\u4e2a\u6807\u5fd7\u4f4d<\/p>\n<p>1.<strong>ZF\u6807\u5fd7(zero flag,\u96f6\u6807\u5fd7\u4f4d)<\/strong><strong><\/strong><\/p>\n<p><u>\u8bb0\u5f55\u76f8\u5173\u6307\u4ee4\u6267\u884c\u540e,\u7ed3\u679c\u662f\u5426\u4e3a0<\/u><u><\/u><\/p>\n<p><u>\u5982\u679c\u4e3a0,\u90a3\u4e48zf=1<\/u><u><\/u><\/p>\n<p><u>\u5982\u679c\u4e0d\u4e3a0,\u90a3\u4e48zf=0<\/u><u><\/u><\/p>\n<p>(\u6ce8:\u5728\u8ba1\u7b97\u673a\u4e2d1\u8868\u793a\u903b\u8f91\u771f(TRUE),0\u8868\u793a\u903b\u8f91\u5047(FALSE))<\/p>\n<pre><code>add sub mul div inc or and \u7b49<u>\u8fd0\u7b97\u6307\u4ee4\u5f71\u54cd\u6807\u5fd7\u5bc4\u5b58\u5668<\/u>\nmov push pop \u7b49<u>\u4f20\u9001\u6307\u4ee4\u4e0d\u5f71\u54cd\u6807\u5fd7\u5bc4\u5b58\u5668<\/u><\/code><\/pre>\n<p><strong>2.PF\u6807\u5fd7(parity flag,\u5947\u5076\u6807\u5fd7\u4f4d)<\/strong><strong><\/strong><\/p>\n<p><u>\u8bb0\u5f55\u76f8\u5173\u6307\u4ee4\u6267\u884c\u540e,\u5176\u7ed3\u679c\u4e2d\u7684\u6240\u6709bit\u4f4d\u4e2d1\u7684\u4e2a\u6570\u662f\u5426\u4e3a\u5076\u6570<\/u><u><\/u><\/p>\n<p><u>\u82e51\u7684\u4e2a\u6570\u4e3a\u5076\u6570,pf=1<\/u><u><\/u><\/p>\n<p><u>\u82e51\u7684\u4e2a\u6570\u4e3a\u5947\u6570,pf=0<\/u><u><\/u><\/p>\n<p><strong>3.SF\u6807\u5fd7(sign flag,\u7b26\u53f7\u6807\u5fd7\u4f4d)<\/strong><strong><\/strong><\/p>\n<p>\u9644\u6ce82 \u8865\u7801\u603b\u7ed3\u3001\u539f\u7801\u53cd\u7801\u8865\u7801<\/p>\n<p>\u6ce8:\u6b64\u65f6\u8981\u6307\u540d\u6709\u7b26\u53f7\u6570\u7684\u957f\u5ea6(byte\/word\/dword\/qword)<\/p>\n<p><![if !supportLists]>1. <![endif]>\u7528\u6570\u636e\u7684\u6700\u9ad8\u4f4d\u4f5c\u4e3a\u7b26\u53f7\u4f4d,0\u8868\u793a\u6b63\u6570,1\u8868\u793a\u8d1f\u6570<\/p>\n<p><![if !supportLists]>2. <![endif]>\u5c06\u6570\u5728\u673a\u5668\u4e2d\u7684\u7f16\u7801\u79f0\u4e3a\u673a\u5668\u6570(\u598210000001),\u5c06\u539f\u6765\u4e00\u822c\u7684\u4e66\u5199\u65b9\u5f0f\u8868\u793a\u7684\u6570\u79f0\u4e3a\u771f\u503c(\u5982-0000001).<\/p>\n<p><![if !supportLists]>3. <![endif]>\u539f\u7801:\u539f\u672c\u7684\u6570\u5b57\u4e0d\u53d8,\u6700\u9ad8\u4f4d\u4f5c\u4e3a\u7b26\u53f7\u4f4d<\/p>\n<p>\u5982(\u5f53\u957f\u5ea6\u4e3abyte\u65f6)1100110\u7684\u539f\u7801=01100110,-1100110\u7684\u539f\u7801=11100110<\/p>\n<p>\u539f\u7801\u4e2d0\u4f1a\u51fa\u73b0\u91cd\u7801(00000000(+0)\u548c10000000(-0))<\/p>\n<p><![if !supportLists]>4. <![endif]>\u53cd\u7801:\u6b63\u6570\u7684\u53cd\u7801\u5c31\u662f\u5b83\u672c\u8eab,\u8d1f\u6570\u7684\u53cd\u7801\u662f\u5c06\u539f\u7801\u9664\u4e86\u7b26\u53f7\u4f4d\u4ee5\u5916\u6bcf\u4e2a\u4e3a\u6309\u4f4d\u53d6\u53cd<\/p>\n<p>\u5982(\u5f53\u957f\u5ea6\u4e3abyte\u65f6)1100110\u7684\u53cd\u7801=01100110,-1100110\u7684\u53cd\u7801=10011001<\/p>\n<p>\u53cd\u7801\u4e2d0\u4f1a\u51fa\u73b0\u91cd\u7801(00000000(+0)\u548c11111111(-0))<\/p>\n<p><![if !supportLists]>5. <![endif]>\u8865\u7801:\u6b63\u6570\u7684\u8865\u7801\u5c31\u662f\u5b83\u672c\u8eab\uff0c\u8d1f\u6570\u7684\u8865\u7801\u662f\u5c06\u53cd\u7801\u52a01<\/p>\n<p>\u5982(\u5f53\u957f\u5ea6\u4e3abyte\u65f6)1100110\u7684\u8865\u7801=01100110,-1100110\u7684\u8865\u7801=10011010<\/p>\n<pre><code>\u8865\u7801\u4e2d\u6bcf\u4e2a\u6570\u90fd\u662f\u552f\u4e00\u7684<\/code><\/pre>\n<p>*\u8d1f\u6570\u8865\u7801\u4e5f\u53ef\u4ee5\u75280\u5411\u4e00\u4e2a&#8221;\u5047\u60f3\u7684\u6700\u9ad8\u4f4d\u7684\u524d\u4e00\u4f4d&#8221;\u501f1,\u4e0e\u81ea\u5df1\u76f8\u53cd\u6570\u7684\u8865\u7801\u76f8\u51cf\u5f97\u5230<\/p>\n<p>\u5982(\u5f53\u957f\u5ea6\u4e3abyte\u65f6)-1100110\u7684\u8865\u7801=(1)00000000-01100110=10011010<\/p>\n<p>\u6700\u9ad8\u4f4d\u7684\u524d\u4e00\u4f4d\u770b\u4f5c1<\/p>\n<p><![if !supportLists]>6. <![endif]>\u6b63\u6570\u7684\u8865\u7801\u53d6\u53cd\u52a01\u540e\uff0c\u4e3a\u5176\u5bf9\u5e94\u7684\u8d1f\u6570\u7684\u8865\u7801,\u8d1f\u6570\u7684\u8865\u7801\u53d6\u53cd\u52a01\u540e\u4e3a\u5176\u7edd\u5bf9\u503c<\/p>\n<p><![if !supportLists]>7. <![endif]>n\u4f4d\u4e8c\u8fdb\u5236\u6570\u7684\u5404\u4e2a\u7f16\u7801\u80fd\u8868\u793a\u7684\u6709\u7b26\u53f7\u6570\u7684\u8303\u56f4\u5982\u4e0b:<\/p>\n<p>\u539f\u7801 -2^(n-1)-1~2^(n-1)-1<\/p>\n<p>\u53cd\u7801 -2^(n-1)-1~2^(n-1)-1<\/p>\n<p>\u8865\u7801 -2^(n-1)~2^(n-1)-1<\/p>\n<p>\u8bb0\u5f55\u76f8\u5173\u6307\u4ee4\u6267\u884c\u540e\u7ed3\u679c\u662f\u5426\u4e3a\u8d1f(<u>\u6b64\u65f6\u5c06\u7ed3\u679c\u770b\u4f5c<\/u><strong><u>\u6709\u7b26\u53f7<\/u><\/strong><u>\u6570<\/u>),<\/p>\n<p>\u5982\u679c\u4e3a\u8d1fsf=1<\/p>\n<p>\u5982\u679c\u4e3a\u975e\u8d1f\u6570,sf=0<\/p>\n<p>\u5bf9\u4e8e\u540c\u4e00\u4e8c\u8fdb\u5236\u6570,\u53ef\u4ee5\u5f53\u4f5c\u6709\u7b26\u53f7\u6570\u8ba1\u7b97\uff0c\u4e5f\u53ef\u4ee5\u5f53\u4f5c\u65e0\u7b26\u53f7\u6570\u8ba1\u7b97<\/p>\n<p>\u5728\u5c06\u7ed3\u679c\u5f53\u4f5c\u65e0\u7b26\u53f7\u6570\u65f6,sf\u7684\u503c\u6ca1\u6709\u610f\u4e49<\/p>\n<p>\u68c0\u6d4b\u70b911.1<\/p>\n<p>\u5199\u51fa\u4e0b\u9762\u6bcf\u6761\u6307\u4ee4\u6267\u884c\u540e\uff0cZF\u3001PF\u3001SF\u3001\u7b49\u6807\u5fd7\u4f4d\u7684\u503c\u3002 <\/p>\n<pre><code>sub al,al     al=0h        ZF=1        PF=1        SF=0  \nmov al,1      al=1h        ZF=1        PF=1        SF=0  \npush ax       ax=1h        ZF=1        PF=1        SF=0  \npop bx        bx=1h        ZF=1        PF=1        SF=0  \nadd al,bl     al=2h        ZF=0        PF=0        SF=0  \nadd al,10     al=12h       ZF=0        PF=1        SF=0  \nmul al        ax=144h      ZF=0        PF=1        SF=0<\/code><\/pre>\n<p><strong>4.<\/strong><strong>CF\u6807\u5fd7(carry flag,\u8fdb\u4f4d\u6807\u5fd7\u4f4d)<\/strong><strong><\/strong><\/p>\n<p><u>\u5728\u8fdb\u884c<\/u><strong><u>\u65e0\u7b26\u53f7\u6570<\/u><\/strong><u>\u8fd0\u7b97\u65f6<\/u>,\u5b83<u>\u8bb0\u5f55\u4e86\u8fd0\u7b97\u7ed3\u679c\u7684\u6700\u9ad8\u6709\u6548\u4f4d\u5411\u66f4\u9ad8\u4f4d\u7684\u8fdb\u4f4d\u503c(\u6216\u501f\u4f4d\u503c)<\/u><\/p>\n<p><img decoding=\"async\" width=\"401\"  height=\"96\"  src=\"http:\/\/8.129.82.128\/wp-content\/uploads\/2026\/03\/asm202405\u7248\u63d0\u7eb262872.png\"  align=\"left\"  hspace=\"12\" >\u5982:1111 1111B+1B=1 00000000B<\/p>\n<p>\u7ed3\u679c\u4e2d\u76841\u5c31\u5728\u5047\u60f3\u7684\u6700\u9ad8\u4f4d,\u5373CF\u6807\u5fd7\u4f4d\u4e2d<\/p>\n<p>\u5982\u679c\u662f97H-98H\uff0c\u5219\u5411CF\u501f\u4f4d,cf=1,\u8fd0\u7b97\u53d8\u4e3a197H-98H=FFH<\/p>\n<p>\u6709\u8fdb\u4f4d\u6216\u501f\u4f4d\u65f6cf=1,\u5417\uff0c\u6ca1\u6709\u5219cf=0<\/p>\n<p><strong>5.<\/strong><strong>OF\u6807\u5fd7(overflow flag\uff0c\u6ea2\u51fa\u6807\u5fd7\u4f4d)<\/strong><strong><\/strong><\/p>\n<p>\u5728<u>\u8fdb\u884c<\/u><strong><u>\u6709\u7b26\u53f7<\/u><\/strong><u>\u6570\u8fd0\u7b97<\/u>\u65f6,\u82e5\u7ed3\u679c\u8d85\u8fc7\u4e86\u673a\u5668\u6240\u80fd\u8868\u793a\u7684\u8303\u56f4\u53eb\u505a\u6ea2\u51fa<\/p>\n<p>\u598299+98=197>127\uff0c\u8d85\u8fc7\u4e868\u4f4d\u6709\u7b26\u53f7\u6570\u7684\u8303\u56f4,\u4fbf\u662f\u6ea2\u51fa<\/p>\n<p><u>\u6ea2\u51fa\u65f6of=1,\u6ca1\u6709\u6ea2\u51faof=0<\/u><u><\/u><\/p>\n<p>\u6ce8\u610f:\u8981\u5206\u6e05\u5224\u65ad\u5bf9\u8c61\u662f\u6709\u7b26\u53f7\u6570\u8fd8\u662f\u65e0\u7b26\u53f7\u6570<\/p>\n<p>\u68c0\u6d4b\u70b911.2<\/p>\n<p>\u5199\u51fa\u4e0b\u9762\u6bcf\u6761\u6307\u4ee4\u6267\u884c\u540e\uff0cZF\u3001PF\u3001SF\u3001CF\u3001OF\u7b49\u6807\u5fd7\u4f4d\u7684\u503c\u3002 <\/p>\n<pre><code>              al                 CF    OF    SF    ZF    PF\nsub al,al     0h\/0000 0000b      0     0     0     1     1\nmov al,10h    10h\/0010 0000b     0     0     0     1     1\nadd al,90h    a0h\/1010 0000b     0     0     1     0     1\nmov al,80h    80h\/1000 0000b     0     0     1     0     1\nadd al,80h    0h\/0000 0000b      1     1     0     1     1\nmov al,0fch   0fch\/1111 1100b    1     1     0     1     1\nadd al,05h    1h\/0000 0001b      1     0     0     0     0\nmov al,7dh    7dh\/1111 1101b     1     0     0     0     0\nadd al,0bh    88h\/1000 1000b     0     1     1     0     1<\/code><\/pre>\n<p>11.6 adc\u6307\u4ee4<\/p>\n<p>adc\u4e3a<strong>\u5e26\u8fdb\u4f4d\u52a0\u6cd5\u6307\u4ee4<\/strong>,\u5229\u7528\u4e86cf\u4f4d\u4e0a\u8bb0\u5f55\u7684\u8fdb\u4f4d\u503c<\/p>\n<p><u>\u683c\u5f0f adc oper1,oper2<\/u><u><\/u><\/p>\n<p><u>\u529f\u80fd oper1=oper1+oper2+CF<\/u><u><\/u><\/p>\n<p>\u4f7f\u7528:\u8fdb\u884c\u5927\u6570\u76f8\u52a0,\u53ef\u4ee5\u5c06\u52a0\u6cd5\u5206\u4e3a\u4e24\u6b65:(1)\u4f4e\u4f4d\u76f8\u52a0;(2)\u9ad8\u4f4d\u76f8\u52a0\u518d\u52a0\u4e0a\u4f4e\u4f4d\u76f8\u52a0\u7684\u8fdb\u4f4d\u503c<\/p>\n<p>\u4f8b1:32\u4f4d\u52a0\u6cd5:\u8ba1\u7b971EF000H+201000H,\u7ed3\u679c\u5728ax(\u9ad816\u4f4d),bx(\u4f4e16\u4f4d)<\/p>\n<pre><code>mov ax,001EH\nmov bx,0F000H\nadd bx,1000H<\/code><\/pre>\n<p>adc ax,0020H<\/p>\n<p>adc\u6307\u4ee4\u6267\u884c\u540e\u53ef\u80fd\u4ea7\u751f\u8fdb\u4f4d\u8bbe\u7f6ecf<\/p>\n<p>\u4f8b2:\u7f16\u5199\u5b50\u7a0b\u5e8f,\u8fdb\u884c128\u4f4d\u52a0\u6cd5<\/p>\n<p>\u540d\u79f0:add128<\/p>\n<p>\u529f\u80fd:\u4e24\u4e2a128\u4f4d\u6570\u636e\u76f8\u52a0<\/p>\n<p>\u53c2\u6570:ds:si\u6307\u5411\u5b58\u50a8\u7b2c\u4e00\u4e2a\u6570\u7684\u7a7a\u95f4(\u6b64\u65f6\u9700\u89818\u4e2a\u5b57\u5355\u5143),\u7531\u4f4e\u5730\u5740\u5230\u9ad8\u5730\u5740\u4f9d\u6b21\u5b58\u653e128\u4f4d\u6570\u636e\u7531\u4f4e\u5230\u9ad8\u7684\u5404\u4e2a\u5b57\uff0c\u8fd0\u7b97\u7ed3\u679c\u5b58\u50a8\u5728\u7b2c\u4e00\u4e2a\u6570\u7684\u5b58\u50a8\u7a7a\u95f4\u4e2d\u3002<\/p>\n<p>ds:di\u6307\u5411\u5b58\u50a8\u7b2c\u4e8c\u4e2a\u6570\u7684\u5185\u5b58\u7a7a\u95f4<\/p>\n<p>Program 11-1 ADD128\u7a0b\u5e8f<\/p>\n<p>add128:<\/p>\n<pre><code>push ax\npush cx\npush si\npush di\nsub ax,ax;\u5c06cf\u8bbe\u4e3a0\nmov cx,8\ns:mov ax,[si]\nadc ax,[di]\nmov [si],ax\ninc si\ninc si\ninc di\ninc di \nloop s\npop di\npop si\npop cx\npop ax\nret<\/code><\/pre>\n<p><strong>inc\u548cloop\u6307\u4ee4\u4e0d\u5f71\u54cdcf\u4f4d<\/strong>\uff0c\u4e0a\u9762\u76844\u4e2ainc\u6307\u4ee4\u4e0d\u80fd\u7528add\u4ee3\u66ff\uff0c\u56e0\u4e3aadd\u5f71\u54cdcf\u4f4d,\u4f1a\u7834\u574f\u8fd0\u884c\u7ed3\u679c<\/p>\n<p>11.7 sbb\u6307\u4ee4<\/p>\n<p>sbb\u662f<strong>\u5e26\u501f\u4f4d\u51cf\u6cd5\u6307\u4ee4<\/strong>,\u5229\u7528\u4e86cf\u8bb0\u5f55\u7684\u501f\u4f4d\u503c<\/p>\n<p><u>\u683c\u5f0f sbb oper1,oper2<\/u><u><\/u><\/p>\n<p><u>\u529f\u80fd oper1=oper1-oper2-cf<\/u><u><\/u><\/p>\n<p>\u5e94\u7528\u601d\u8def\u4e0eadc\u7c7b\u4f3c<\/p>\n<p>11.8~11.9 cmp\u6307\u4ee4\u548c\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4<\/p>\n<p><![if !supportLists]>1. <![endif]>cmp\u4e3a<strong>\u6bd4\u8f83\u6307\u4ee4<\/strong>\uff0c<u>\u529f\u80fd\u76f8\u5f53\u4e8e\u51cf\u6cd5\u6307\u4ee4,\u4e0d\u4fdd\u5b58\u7ed3\u679c\u4f46\u5bf9\u6807\u5fd7\u5bc4\u5b58\u5668\u4ea7\u751f\u5f71\u54cd<\/u><\/p>\n<pre><code><u>\u683c\u5f0f cmp oper1,oper2<\/u><u><\/u><\/code><\/pre>\n<p><u>\u529f\u80fd \u8ba1\u7b97oper1-oper2,\u4e0d\u4fdd\u5b58\u7ed3\u679c,\u4ec5\u4ec5\u8bbe\u7f6eflag<\/u><u><\/u><\/p>\n<p>2.&#9650;&#9650;&#9650;cmp\u6307\u4ee4\u6bd4\u8f83\u7ed3\u679c\u901a\u8fc7\u6807\u5fd7\u5bc4\u5b58\u5668\u4f4d\u7684\u53cd\u9988:\u6267\u884ccmp ax,bx<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=143  valign=top ><p><strong>\u6bd4\u8f83\u5185\u5bb9<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>cmp\u6307\u4ee4\u7ed3\u679c<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>flag\u5bc4\u5b58\u5668\u76f8\u5173\u4f4d\u7684\u5185\u5bb9<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)==(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)==0<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>zf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)!=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)!=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>zf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)<(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)<0 \u4ea7\u751f\u501f\u4f4d<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>cf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)>=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)>=0 \u4e0d\u501f\u4f4d\u4f46\u7ed3\u679c\u53ef\u80fd\u4e3a0<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>cf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)>(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)>0 \u4e0d\u501f\u4f4d\u7ed3\u679c\u4e5f\u4e0d\u4e3a0<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>cf=0\u4e14zf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=143  valign=top ><p><strong>(ax)<=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><td width=290  valign=top ><p><strong>(ax)-(bx)<=0\u53ef\u80fd\u501f\u4f4d\u4e5f\u53ef\u80fd\u7ed3\u679c\u4e3a0<\/strong><strong><\/strong><\/p>\n<\/td><td width=223  valign=top ><p><strong>cf=1\u6216zf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>3.\u65e0\u7b26\u53f7\u6570\u7684\u6bd4\u8f83:\u6267\u884ccmp ax,bx<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=224  valign=top ><p><strong>\u6807\u5fd7\u5bc4\u5b58\u5668<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>\u7ed3\u8bba<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>zf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)==(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>zf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)!=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>cf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)<(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>cf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)>=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>cf=0\u4e14zf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)>(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=224  valign=top ><p><strong>cf=1\u6216zf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=432  valign=top ><p><strong>(ax)<=(bx)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>4.\u6709\u7b26\u53f7\u6570\u7684\u6bd4\u8f83:\u6267\u884ccmp ah,bh<\/p>\n<p>\u8981\u6ce8\u610f\u6709\u6ca1\u6709\u6ea2\u51fa,\u6ca1\u6709\u6ea2\u51fa\u65f6\u5b9e\u9645\u7ed3\u679c\u7684\u6b63\u8d1f\u548c\u6570\u5b66\u8fd0\u7b97\u4e0a(\u6570\u5b66\u8fd0\u7b97\u65f6\u6ca1\u6709\u6ea2\u51fa)\u7684\u6b63\u8d1f\u624d\u4e00\u81f4,\u82e5\u6ea2\u51fa\u4e86\u8bf4\u660e\u4e0d\u4e00\u81f4<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=146  valign=top ><p><strong>\u6807\u5fd7\u5bc4\u5b58\u5668<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>\u7ed3\u8bba<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>zf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)==(bh)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>zf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)!=(bh)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>of=0\u4e14sf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)<(bh)<\/strong><strong><\/strong><\/p>\n<p><strong>\u8fd9\u65f6\u6ca1\u6709\u6ea2\u51fa\uff0c\u8bf4\u660e(ah)<(bh)\u5728\u6570\u5b66\u8ba1\u7b97\u4e0a\u786e\u5b9e\u662f\u8d1f\u6570<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>of=1\u4e14sf=1<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)>(bh)<\/strong><strong><\/strong><\/p>\n<p><strong>\u6ea2\u51fa\u5bfc\u81f4\u4e86\u5b9e\u9645\u7ed3\u679c\u4e3a\u8d1f,\u8bf4\u660e\u5728\u6570\u5b66\u8ba1\u7b97\u4e0a(\u4e0d\u8003\u8651\u6ea2\u51fa)\u7ed3\u679c\u4e3a\u6b63<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>of=1\u4e14sf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)<(bh)<\/strong><strong><\/strong><\/p>\n<p><strong>\u6ea2\u51fa\u5bfc\u81f4\u4e86\u5b9e\u9645\u7ed3\u679c\u4e3a\u6b63,\u8bf4\u660e\u5728\u6570\u5b66\u8ba1\u7b97\u4e0a(\u4e0d\u8003\u8651\u6ea2\u51fa)\u7ed3\u679c\u4e3a\u8d1f<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=146  valign=top ><p><strong>of=0\u4e14sf=0<\/strong><strong><\/strong><\/p>\n<\/td><td width=510  valign=top ><p><strong>(ah)>=(bh)<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>5.\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4\u7684\u7528\u6cd5<\/p>\n<p><strong>\u5957\u8def:<\/strong><strong><\/strong><\/p>\n<pre><code><strong>cmp oper1,oper2<\/strong><strong><\/strong><\/code><\/pre>\n<p><strong>jxxx \u6807\u53f7<\/strong><strong><\/strong><\/p>\n<p>6.\u6839\u636e\u65e0\u7b26\u53f7\u6570\u7684\u6bd4\u8f83\u7ed3\u679c\u8fdb\u884c\u8f6c\u79fb<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=218  valign=top ><p><strong>\u6307\u4ee4<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u542b\u4e49<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u68c0\u6d4b\u7684\u6807\u5fd7\u4f4d<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>je\/jz<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u7b49\u4e8e\u5219\u8f6c\u79fb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>zf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jne\/jnz<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4e0d\u7b49\u4e8e\u5219\u8f6c\u79fb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>zf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jnae\/jc\/jb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4f4e\u4e8e\u5219\u8f6c\u79fb(\u5c0f\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>cf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jae\/jnc\/jnb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4e0d\u4f4e\u4e8e\u5219\u8f6c\u79fb(\u5927\u4e8e\u7b49\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>cf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>ja\/jnbe<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u9ad8\u4e8e\u5219\u8f6c\u79fb(\u5927\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>cf=0\u4e14zf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jna\/jbe<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4e0d\u9ad8\u4e8e\u5219\u8f6c\u79fb(\u5c0f\u4e8e\u7b49\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>cf=1\u6216zf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>7.\u6839\u636e\u6709\u7b26\u53f7\u6570\u7684\u6bd4\u8f83\u7ed3\u679c\u8f6c\u79fb<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=218  valign=top ><p><strong>\u6307\u4ee4<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u542b\u4e49<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u68c0\u6d4b\u7684\u6807\u5fd7\u4f4d<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jl\/jnge<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u5c0f\u4e8e\u5219\u8f6c\u79fb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=1\u4e14of=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jnl\/jge<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4e0d\u5c0f\u4e8e\u5219\u8f6c\u79fb(\u5927\u4e8e\u7b49\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=0\u4e14of=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jle\/jng<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u5c0f\u4e8e\u7b49\u4e8e\u5219\u8f6c\u79fb<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=0\u6216of=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jnle\/jg<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u4e0d\u5c0f\u4e8e\u7b49\u4e8e\u5219\u8f6c\u79fb(\u5927\u4e8e)<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=1\u4e14of=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>8.\u6839\u636e\u5355\u4e2a\u6807\u5fd7\u4f4d\u8f6c\u79fb<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=218  valign=top ><p><strong>\u6307\u4ee4<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u542b\u4e49<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u68c0\u6d4b\u7684\u6807\u5fd7\u4f4d<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>js<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u7ed3\u679c\u4e3a\u8d1f<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jns<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u7ed3\u679c\u4e3a\u975e\u8d1f<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>sf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jo<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u7ed3\u679c\u6ea2\u51fa<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>of=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jno<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u7ed3\u679c\u4e0d\u6ea2\u51fa<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>of=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jp<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u5947\u5076\u4f4d\u4e3a1<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>pf=1<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p><strong>jnp<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>\u5947\u5076\u4f4d\u4e3a0<\/strong><strong><\/strong><\/p>\n<\/td><td width=219  valign=top ><p><strong>pf=0<\/strong><strong><\/strong><\/p>\n<\/td><\/tr><\/table><p>*\u4ee5\u4e0a\u6307\u4ee4\u4e2d\u6bcf\u4e2a\u5b57\u6bcd\u7684\u542b\u4e49:<\/p>\n<pre><code>j=jump,e=euqal,n=not,b=below(\u4f4e\u4e8e),a=above(\u9ad8\u4e8e),l=less(\u5c0f\u4e8e),g=greater(\u5927\u4e8e),s=sign,c=carry,<\/code><\/pre>\n<p>p=parity,o=overflow,z=zero<\/p>\n<p>\u68c0\u6d4b\u70b911.3 <\/p>\n<p>(1)\u8865\u5168\u4e0b\u9762\u7684\u7a0b\u5e8f\uff0c\u7edf\u8ba1F000:0\u590432\u4e2a\u5b57\u8282\u4e2d\uff0c\u5927\u5c0f\u5728[32,128]\u7684\u6570\u636e\u4e2a\u6570\u3002<\/p>\n<pre><code>mov ax,0f000h\nmov ds,ax\nmov bx,0;ds:bx\u6307\u5411\u7b2c\u4e00\u4e2a\u5b57\u8282\nmov dx,0;\u521d\u59cb\u5316\u7d2f\u52a0\u5668\nmov cx,32\ns: mov al,[bx]\ncmp al,32;\u548c32\u8fdb\u884c\u6bd4\u8f83\njb s0     <\/u>;\u5982\u679c\u4f4e\u4e8eal\u8f6c\u5230s0,\u7ee7\u7eed\u5faa\u73af\ncmp al,128;\u548c128\u8fdb\u884c\u6bd4\u8f83\nja s0     <\/u>;\u5982\u679c\u9ad8\u4e8eal\u8f6c\u5230s0,\u7ee7\u7eed\u5faa\u73af\ninc dx\ns0:inc bx\nloop s<\/code><\/pre>\n<p>[32,128]\u662f\u95ed\u533a\u95f4\uff0c\u5305\u62ec\u4e24\u7aef\u70b9\u7684\u503c <\/p>\n<p>(32,128)\u662f\u5f00\u533a\u95f4\uff0c\u4e0d\u5305\u62ec\u4e24\u7aef\u70b9\u7684\u503c<\/p>\n<p>\u68c0\u6d4b\u70b911.3 <\/p>\n<p>(2)\u8865\u5168\u4e0b\u9762\u7684\u7a0b\u5e8f\uff0c\u7edf\u8ba1F000:0\u590432\u4e2a\u5b57\u8282\u4e2d\uff0c\u5927\u5c0f\u5728(32,128)\u7684\u6570\u636e\u4e2a\u6570\u3002<\/p>\n<pre><code>mov ax,0f000h\nmov ds,ax\nmov bx,0;ds:bx\u6307\u5411\u7b2c\u4e00\u4e2a\u5b57\u8282\nmov dx,0;\u521d\u59cb\u5316\u7d2f\u52a0\u5668\nmov cx,32\ns: mov al,[bx]\ncmp al,32;\u548c32\u8fdb\u884c\u6bd4\u8f83<\/code><\/pre>\n<p>jna s0     <\/u>;\u5982\u679c\u4e0d\u9ad8\u4e8eal\u8f6c\u5230s0,\u7ee7\u7eed\u5faa\u73af<\/p>\n<pre><code>cmp al,128;\u548c128\u8fdb\u884c\u6bd4\u8f83<\/code><\/pre>\n<p>jnb s0    <\/u>;\u5982\u679c\u4e0d\u4f4e\u4e8eal\u8f6c\u5230s0,\u7ee7\u7eed\u5faa\u73af<\/p>\n<pre><code>inc dx\ns0:inc bx\nloop s<\/code><\/pre>\n<p>11.10 <strong>DF\u6807\u5fd7(direction flag,\u65b9\u5411\u6807\u5fd7\u4f4d)\u548c\u4e32\u4f20\u9001\u6307\u4ee4<\/strong><\/p>\n<p>1.<u>DF\u6807\u5fd7\u5728\u5904\u7406\u6307\u4ee4\u4e2d\u63a7\u5236\u6bcf\u6b21\u64cd\u4f5c\u540esi\u3001di\u7684\u589e\u51cf<\/u><u><\/u><\/p>\n<p><u>df=0,\u6bcf\u6b21\u64cd\u4f5c\u540esi\u3001di\u9012\u589e<\/u><u><\/u><\/p>\n<p><u>df=1,\u6bcf\u6b21\u64cd\u4f5c\u540esi\u3001di\u9012\u51cf<\/u><\/p>\n<p><![if !supportLists]>2. <![endif]>\u4e32\u4f20\u9001\u6307\u4ee4<\/p>\n<p>\u683c\u5f0f:<strong>movsb<\/strong><\/p>\n<p>\u529f\u80fd:<u>\u5c06ds:si\u6307\u5411\u7684\u5185\u5b58\u5355\u5143\u4e2d\u7684\u5b57\u8282\u9001\u5165es:di\u4e2d,\u518d\u6839\u636edf\u7684\u503c\u5c06si\u548cdi\u9012\u589e\u6216\u9012\u51cf<\/u>,\u5373<\/p>\n<pre><code>mov es:[di],byte ptr ds:[si];8086\u4e0d\u652f\u6301\u8be5\u6307\u4ee4\uff0c\u6b64\u5904\u7528\u4f5c\u529f\u80fd\u63cf\u8ff0\uff0c\u662f\u4f2a\u4ee3\u7801<\/code><\/pre>\n<p>if(df==0):<\/p>\n<pre><code>inc si\ninc di<\/code><\/pre>\n<p>if(df==1):<\/p>\n<pre><code>dec si\ndec di<\/code><\/pre>\n<p>\u683c\u5f0f:<strong>movsw<\/strong><\/p>\n<p>\u529f\u80fd:<u>\u4e0emovsb\u7c7b\u4f3c\uff0c\u4e0d\u8fc7\u4f20\u9001\u7684\u662f\u5b57<\/u>,\u5373<\/p>\n<pre><code>mov es:[di],word ptr ds:[si];8086\u4e0d\u652f\u6301\u8be5\u6307\u4ee4\uff0c\u6b64\u5904\u7528\u4f5c\u529f\u80fd\u63cf\u8ff0\uff0c\u662f\u4f2a\u4ee3\u7801<\/code><\/pre>\n<p>if(df==0):<\/p>\n<pre><code>add si,2\nadd di,2<\/code><\/pre>\n<p>if(df==1):<\/p>\n<pre><code>sub si,2\nsub di,2<\/code><\/pre>\n<p>\u4e00\u822cmovsb\u548cmovsw\u4e0erep\u914d\u5408\u4f7f\u7528,\u683c\u5f0f:rep movsb\u6216rep movsw<\/p>\n<p>\u76f8\u5f53\u4e8e:<\/p>\n<p>s:movsb<\/p>\n<pre><code>loop s<\/code><\/pre>\n<p><strong>rep\u6839\u636ecx\u7684\u503c\u91cd\u590d\u6267\u884c\u4e32\u4f20\u9001\u6307\u4ee4<\/strong><strong><\/strong><\/p>\n<p>\u8bbe\u7f6edf\u4f4d\u7684\u65b9\u6cd5:<\/p>\n<p><![if !supportLists]>(1) <![endif]><strong>cld\u6307\u4ee4(clean):\u5c06df\u7f6e\u4e3a0\uff1b(2)std\u6307\u4ee4(setup):\u5c06df\u7f6e\u4e3a1<\/strong><strong><\/strong><\/p>\n<pre><code><strong>11.11 pushf\u5c06\u6807\u5fd7\u5bc4\u5b58\u5668\u7684\u503c\u538b\u6808,popf\u4ece\u6808\u4e2d\u5f39\u51fa\u6570\u636e\u9001\u5165\u6807\u5fd7\u5bc4\u5b58\u5668<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u68c0\u6d4b\u70b911.4 <\/p>\n<p>\u4e0b\u9762\u6307\u4ee4\u6267\u884c\u540e\uff0c(ax)=<u> 45h <\/u><\/p>\n<pre><code>mov ax,0 \npush ax \npopf \nmov ax,0fff0h \nadd ax,0010h \npushf \npop ax \nand al,11000101B \nand ah,00001000B \n\u63a8\u7b97\u8fc7\u7a0b\uff1a\npopf\u540e\uff0c\u6807\u5fd7\u5bc4\u5b58\u5668\u4e2d\uff0c\u672c\u7ae0\u8282\u4ecb\u7ecd\u7684\u90a3\u4e9b\u6807\u5fd7\u4f4d\u90fd\u4e3a0\uff08\u4f46\u662f\u6b64\u65f6\u6807\u5fd7\u5bc4\u5b58\u5668\u5e76\u4e0d\u662f\u6240\u6709\u4f4d\u7f6e\u90fd\u4e3a0\uff0c\u6ca1\u5b66\u8fc7\u7684\u4f4d\u7f6e\u7528*\u5148\u4ee3\u66ff\uff09\uff0c\u5411\u4e0b\u8fdb\u884c\uff0c\u90a3\u4e48pushf\u5c06\u8ba1\u7b97\u540e\u7684\u5f53\u65f6\u72b6\u6001\u7684\u6807\u5fd7\u5bc4\u5b58\u5668\u5165\u6808\uff0c\u7136\u540epop\u7ed9ax\uff0c\u8fd9\u662fax\u662f\u5bc4\u5b58\u5668\u7684\u503c\uff08\u8fd9\u4e2a\u503c\u4e2d\u5305\u542b\u4e86\u6211\u4eec\u7684*\u53f7\uff09\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u5bf9\u90a3\u4e9b\u6ca1\u6709\u5b66\u8fc7\u7684\u6807\u5fd7\u4f4d\u7684\u5c4f\u853d\u64cd\u4f5c\uff0c\u8fd9\u5c31\u662f\u6700\u540e\u4e24\u6761\u6307\u4ee4\u7684\u610f\u4e49\u6240\u5728\uff0c\u5c06\u4e0d\u786e\u5b9a\u7684\u4f4d\u7f6e\u90fd\u5f520\uff0c\u90a3\u4e48\u53ea\u5269\u4e0b\u6211\u4eec\u80fd\u591f\u786e\u5b9a\u7684\u4f4d\u7f6e\u4e86\uff0c\u6240\u4ee5\uff0c\u7ed3\u679c\u5c31\u53ef\u4ee5\u63a8\u7406\u51fa\u6765\u4e86\u3002\nmov ax,0   \npush ax   \npopf   \nmov ax,0fff0h   \nadd ax,0010h   \npushf \npop ax               0  0  0  0  of df if tf sf zf 0  af 0  pf 0  cf \n                     0  0  0  0  0  0  *  *  0  1  0  *  0  1  0  1 \n                     ax=flag=000000** 010*0101b \nand al,11000101B     al=01000101b=45h \nand ah,00001000B     ah=00000000b=0h<\/code><\/pre>\n<p>11.12\u6807\u5fd7\u5bc4\u5b58\u5668\u5728debug\u4e2d\u7684\u663e\u793a<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=218  valign=top ><p>\u6807\u5fd7<\/p>\n<\/td><td width=219  valign=top ><p>\u503c\u4e3a1\u7684\u6807\u8bb0<\/p>\n<\/td><td width=219  valign=top ><p>\u503c\u4e3a0\u7684\u6807\u8bb0<\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p>of<\/p>\n<\/td><td width=219  valign=top ><p>OV,overflow<\/p>\n<pre><code><\/td><td width=219  valign=top ><p>NV,not overflow<\/code><\/pre>\n<\/td><\/tr><tr><td width=218  valign=top ><p>sf<\/p>\n<\/td><td width=219  valign=top ><p>NG,negative<\/p>\n<\/td><td width=219  valign=top ><p>PL,positive<\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p>zf<\/p>\n<\/td><td width=219  valign=top ><p>ZR,zero<\/p>\n<pre><code><\/td><td width=219  valign=top ><p>NZ,not zero<\/code><\/pre>\n<\/td><\/tr><tr><td width=218  valign=top ><p>pf<\/p>\n<\/td><td width=219  valign=top ><p>PE,even<\/p>\n<\/td><td width=219  valign=top ><p>PO,odd<\/p>\n<\/td><\/tr><tr><td width=218  valign=top ><p>cf<\/p>\n<\/td><td width=219  valign=top ><p>CY,carry<\/p>\n<pre><code><\/td><td width=219  valign=top ><p>NC,not carry<\/code><\/pre>\n<\/td><\/tr><tr><td width=218  valign=top ><p>df<\/p>\n<\/td><td width=219  valign=top ><p>DN,down<\/p>\n<\/td><td width=219  valign=top ><p>UP<\/p>\n<\/td><\/tr><\/table><p>\u5b9e\u9a8c11 \u7f16\u5199\u5b50\u7a0b\u5e8f<\/p>\n<p>\u5b9e\u9a8c11\uff08letterc\u5b50\u7a0b\u5e8f\uff09\u5c0f\u5199\u6539\u6210\u5927\u5199<\/p>\n<p>\u7f16\u5199\u4e00\u4e2a\u5b50\u7a0b\u5e8f\uff0c\u5c06\u5305\u542b\u4efb\u610f\u5b57\u7b26\uff0c\u4ee50\u7ed3\u5c3e\u7684\u5b57\u7b26\u4e32\u7684\u5c0f\u5199\u5b57\u6bcd\u8f6c\u53d8\u6210\u5927\u5199\u5b57\u6bcd\u3002<\/p>\n<p><strong>Program ex-11-1 \u81ea\u4e3b\u89e3\u6cd5<\/strong><strong><\/strong><\/p>\n<pre><code>assume cs<strong>:<\/strong>codesg<br>datasg segment<br>    db <strong>\"Beginner's All-purpose Symbolic Instruction Code.\"<\/strong>,0<br>datasg ends<br>stack segment<br>    db 64 dup<strong>(<\/strong>0<strong>)<\/strong><strong><br><\/strong>stack ends<br>codesg segment<br>begin<strong>:<\/strong><strong><br><\/strong>    <strong>mov<\/strong> ax,datasg<br>    <strong>mov<\/strong> ds,ax<br>    <strong>mov<\/strong> si,0               <i>;ds:si\u6307\u5411\u7b2c\u4e00\u4e2a\u5b57\u8282<\/i><i><br><\/i>    <strong>mov<\/strong> ax,stack<br>    <strong>mov<\/strong> ss,ax<br>    <strong>mov<\/strong> sp,64<br>    <strong>call<\/strong> letterc<br>    <strong>mov<\/strong> ax,4c00h<br>    <strong>int<\/strong> 21h<br>letterc<strong>:<\/strong><strong><br><\/strong>    <strong>push<\/strong> ax<br>    <strong>push<\/strong> si<br>letc_start<strong>:<\/strong><strong><br><\/strong>    <strong>mov<\/strong> al,[si]<br>    <i>;if(al==0)<\/i><i><br><\/i>    <strong>cmp<\/strong> al,0<br>    <strong>je<\/strong> ok<br>    <i>;if(97<=al &#038;&#038; al<=122)<\/i><i><br><\/i>    <i>;\u6d4b\u8bd5\u7b2c\u4e00\u4e2a\u6761\u4ef6<\/i><i><br><\/i>    <strong>cmp<\/strong> al,97<br>    <strong>jae<\/strong> s1<br>    <i>;else<\/i><i><br><\/i>    <strong>jmp<\/strong> next<br>    <i>;\u6d4b\u8bd5\u7b2c\u4e8c\u4e2a\u6761\u4ef6<\/i><i><br><\/i>s1<strong>:<\/strong> <strong>cmp<\/strong> al,122<br>    <strong>jbe<\/strong> s2<br>    <i>;else<\/i><i><br><\/i>    <strong>jmp<\/strong> next<br>s2<strong>:<\/strong><i>;\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6,\u8fdb\u884c\u8f6c\u6362<\/i><i><br><\/i>    <strong>sub<\/strong> al,32<br>    <strong>mov<\/strong> [si],al<br>    <strong>jmp<\/strong> next<br>next<strong>:<\/strong><i>;\u4e0b\u4e00\u4e2a<\/i><i><br><\/i>    <strong>inc<\/strong> si<br>    <strong>jmp<\/strong> letc_start<br><br>ok<strong>:<\/strong>    <strong>pop<\/strong> si<br>    <strong>pop<\/strong> ax<br>    <strong>ret<\/strong>        <br>codesg ends<br>end begin<\/code><\/pre>\n<p><strong>Program ex-11-<\/strong><strong>2<\/strong><strong> <\/strong><strong>\u53c2\u8003\u89e3\u6cd5<\/strong><strong><\/strong><\/p>\n<pre><code>assume cs:codesg\ndatasg segment\ndb \"Seginner's All-purpose Symbolic Instruction Code.\",'0'\ndatasg ends\ncodesg segment\nbegin:\nmov ax,datasg\nmov ds,ax\nmov si,0;ds:si\u6307\u5411\u7b2c\u4e00\u4e2a\u5b57\u8282\ncall letterc<\/code><\/pre>\n<p> <\/p>\n<pre><code>mov ax,4c00h\nint 21h<\/code><\/pre>\n<p> <\/p>\n<p>;\u540d\u79f0\uff1aletterc<\/p>\n<p>;\u529f\u80fd\uff1a\u5c06\u4ee50\u7ed3\u5c3e\u7684\u5b57\u7b26\u4e2d\u7684\u5c0f\u5199\u5b57\u6bcd\u8f6c\u53d8\u6210\u5927\u5199\u5b57\u6bcd<\/p>\n<p>;\u53c2\u6570\uff1ads:si\u6307\u5411\u5b57\u7b26\u4e32\u9996\u5730\u5740<\/p>\n<pre><code>letterc:push ax\npush si\nlet:cmp byte ptr [si],0;\u548c0\u8fdb\u884c\u6bd4\u8f83\nje let0;\u5982\u679c\u7b49\u4e8e0\u5219\u8f6c\u5230let0\uff0c\u7ed3\u675f\ncmp byte ptr [si],61h;\u548c61h\u8fdb\u884c\u6bd4\u8f83\njb let1;\u5982\u679c\u4f4e\u4e8e60h\u5219\u8f6c\u5230let1\uff0c\u7ee7\u7eed\u5faa\u73af\ncmp byte ptr [si],86h;\u548c86h\u8fdb\u884c\u6bd4\u8f83\nja let1;\u5982\u679c\u9ad8\u4e8e86h\u5219\u8f6c\u5230let1\uff0c\u7ee7\u7eed\u5faa\u73af\nmov al,[si]\nsub al,20h;\u8f6c\u4e3a\u5927\u5199\u5b57\u6bcd\nmov [si],al\nlet1:\ninc si\njmp let\nlet0:\npop si\npop ax\nret\ncodesg ends\nend begin<\/code><\/pre>\n<p><![if !supportLists]>\n    <\/div>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u5341\u4e00\u7ae0 \u6807\u5fd7\u5bc4\u5b58\u5668 &#8211; \u6c47 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18,9,8],"tags":[],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-assembly","category-9","category-8"],"_links":{"self":[{"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=506"}],"version-history":[{"count":1,"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts\/506\/revisions"}],"predecessor-version":[{"id":507,"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts\/506\/revisions\/507"}],"wp:attachment":[{"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}