{"id":502,"date":"2026-03-07T19:56:44","date_gmt":"2026-03-07T11:56:44","guid":{"rendered":"http:\/\/8.129.82.128\/?p=502"},"modified":"2026-03-07T19:56:44","modified_gmt":"2026-03-07T11:56:44","slug":"8086%e6%b1%87%e7%bc%969","status":"publish","type":"post","link":"http:\/\/8.129.82.128\/?p=502","title":{"rendered":"8086\u6c47\u7f16#9"},"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\u4e5d\u7ae0 \u8f6c\u79fb\u6307\u4ee4\u7684\u539f\u7406 &#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\u4e5d\u7ae0 \u8f6c\u79fb\u6307\u4ee4\u7684\u539f\u7406<\/h1>\n        \u7b2c\u4e5d\u7ae0 \u8f6c\u79fb\u6307\u4ee4\u7684\u539f\u7406<\/strong><strong><\/strong><\/p>\n<p>9.0 \u7eea\u8bba<\/p>\n<p>1.\u53ef\u4ee5<u>\u4fee\u6539IP\u3002\u6216\u8005\u540c\u65f6\u4fee\u6539CS\u548cIP<\/u>\u7684\u6307\u4ee4\u7edf\u79f0\u4e3a<strong>\u8f6c\u79fb\u6307\u4ee4<\/strong><\/p>\n<p>2.\u8f6c\u79fb\u7684\u5206\u7c7b<\/p>\n<p>&#183;\u53ea\u4fee\u6539IP\u65f6\uff0c\u53eb\u505a<strong>\u6bb5\u5185\u8f6c\u79fb<\/strong><\/p>\n<p>&#183;\u540c\u65f6\u4fee\u6539CS\u548cIP\uff0c\u53eb\u505a<strong>\u6bb5\u95f4\u8f6c\u79fb<\/strong><\/p>\n<pre><code><![if !supportLists]>2. <![endif]>\u6bb5\u5185\u8f6c\u79fb\u5206\u4e3a:<\/code><\/pre>\n<p><strong>&#183;<\/strong><strong>\u77ed\u8f6c\u79fb<\/strong><strong>:IP\u7684\u4fee\u6539\u8303\u56f4\u4e3a-128~127<\/strong><strong><\/strong><\/p>\n<p><strong>&#183;<\/strong><strong>\u8fd1\u8f6c\u79fb<\/strong><strong>:IP\u7684\u4fee\u6539\u8303\u56f4\u4e3a-32768~32767<\/strong><strong><\/strong><\/p>\n<p>3.8086\u8f6c\u79fb\u6307\u4ee4\u7684\u5206\u7c7b<\/p>\n<p>&#183;<strong>\u65e0\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4<\/strong>(\u5982:jmp)<\/p>\n<p>&#183;<strong>\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4<\/strong><strong><\/strong><\/p>\n<p>&#183;<strong>\u5faa\u73af\u6307\u4ee4<\/strong>(\u5982loop)<\/p>\n<p>&#183;<strong>\u8fc7\u7a0b<\/strong><\/p>\n<p>&#183;<strong>\u4e2d\u65ad<\/strong><\/p>\n<p>9.1\u64cd\u4f5c\u7b26offset<\/p>\n<pre><code><![if !supportLists]>1. <![endif]>\u529f\u80fd:\u7531\u7f16\u8bd1\u5668\u5904\u7406,\u53d6\u5f97\u6807\u53f7\u7684\u504f\u79fb\u5730\u5740\n<![if !supportLists]>2. <![endif]><strong><u>\u7528\u6cd5:offset \u6807\u53f7<\/u><\/strong><strong><u><\/u><\/strong><\/code><\/pre>\n<p>\u95ee\u98989.1<\/p>\n<p>\u6709\u5982\u4e0b\u7684\u7a0b\u5e8f\u6bb5\uff0c\u6dfb\u52a0\u4e24\u6761\u6307\u4ee4,\u4f7f\u5f97\u8fd0\u884c\u4e2d\u8be5\u7a0b\u5e8f\u5c06s\u5904\u7684\u4e00\u6761\u6307\u4ee4\u590d\u5236\u5230s0\u5904<\/p>\n<pre><code><strong>Program 9-Problem-1<\/strong><strong><\/strong>\n<strong>assume cs:coding<\/strong><strong><\/strong>\n<strong>codesg segment<\/strong><strong><\/strong>\n<strong>s:<\/strong><strong>mov ax,bx<\/strong><strong><\/strong>\n<strong>mov si,offset s<\/strong><strong><\/strong>\n<strong>mov di,offset s0<\/strong><strong><\/strong>\n<strong>______________<\/strong><strong><\/strong>\n<strong>______________<\/strong><strong><\/strong>\n<strong>s0:<\/strong><strong>nop<\/strong><strong><\/strong>\n<strong>nop<\/strong><strong><\/strong>\n<strong>codesg ends<\/strong><strong><\/strong>\n<strong>end<\/strong><strong><\/strong>\n\u6ce8:nop\u7684\u673a\u5668\u7801\u5360\u4e00\u4e2a\u5b57\u8282,\u6b64\u5904\u4e3a\u5360\u4f4d\u4f5c\u7528\u3002\u7b54\u6848:\nmov cx,cs;[si]\nmov cs:[di],cx<\/code><\/pre>\n<p>9.2~9.6 jmp\u6307\u4ee4<\/p>\n<p>1.jmp\u4e3a\u65e0\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4,\u53ef\u4ee5\u53ea\u4fee\u6539IP,\u4e5f\u53ef\u4ee5\u540c\u65f6\u4fee\u6539CS\u548cIP<\/p>\n<p>2.jmp\u6307\u4ee4\u8981\u7ed9\u51fa\u7684\u4e24\u6761\u4fe1\u606f:<\/p>\n<p><u>(1)\u8f6c\u79fb\u7684\u76ee\u7684\u5730\u5740<\/u><u><\/u><\/p>\n<p><u>(2)\u8f6c\u79fb\u7684\u8ddd\u79bb(\u6bb5\u95f4\u8f6c\u79fb,\u6bb5\u5185\u77ed\u8f6c\u79fb\uff0c\u6bb5\u5185\u8fd1\u8f6c\u79fb)<\/u><u><\/u><\/p>\n<p>3.\u4f9d\u636e\u4f4d\u79fb\u8fdb\u884c\u8f6c\u79fb\u7684jmp\u6307\u4ee4<\/p>\n<pre><code><strong>&#183;jmp short \u6807\u53f7(\u8f6c\u5230\u6807\u53f7\u5904\u6267\u884c\u6307\u4ee4)<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u8be5\u683c\u5f0f\u7684\u6307\u4ee4\u8fdb\u884c\u6bb5\u5185\u77ed\u8f6c\u79fb,\u5bf9IP\u7684\u4fee\u6539\u8303\u56f4\u4e3a-128~127,\u5373\u5411\u524d\u8f6c\u79fb\u6700\u591a\u8d8a\u8fc7128\u4e2a\u5b57\u8282\uff0c\u5411\u540e\u8f6c\u79fb\u6700\u591a\u53ef\u4ee5\u8d8a\u8fc7127\u4e2a\u5b57\u8282<\/p>\n<p>\u5728debug\u4e0b\u663e\u793a\u4e3ajmp xxxx,\u4f46\u673a\u5668\u7801\u4e2d\u4e0d\u5305\u542b\u8f6c\u79fb\u7684\u76ee\u7684\u5730\u5740\uff0c\u56e0\u4e3aCPU\u5728\u6267\u884cjmp\u6307\u4ee4\u65f6\u4e0d\u9700\u8981\u76ee\u7684\u5730\u5740\uff0c\u800c\u9700\u8981\u4f4d\u79fb\u3002<\/p>\n<p>\u529f\u80fd:<u>(IP)=(IP)+8\u4f4d\u4f4d\u79fb<\/u><u><\/u><\/p>\n<p><strong><u>(1)8\u4f4d\u4f4d\u79fb=\u6807\u53f7\u5904\u7684\u5730\u5740-jmp\u6307\u4ee4\u540e\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u5730\u5740<\/u><\/strong><\/p>\n<pre><code><![if !supportLists]>(2) <![endif]>short\u6307\u540d\u4e3a8\u4f4d\u4f4d\u79fb\n<![if !supportLists]>(3) <![endif]>\u4f4d\u79fb\u7528<strong>\u8865\u7801<\/strong>\u8868\u793a\n<![if !supportLists]>(4) <![endif]>\u4f4d\u79fb\u5728\u7f16\u8bd1\u65f6\u7b97\u51fa\n<strong>&#183;jmp near ptr \u6807\u53f7<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u8be5\u6307\u4ee4\u5b9e\u73b0\u6bb5\u5185\u8fd1\u8f6c\u79fb,\u4e0ejmp short \u6807\u53f7 \u76f8\u4f3c,\u4f46\u4e3a16\u4f4d\u4f4d\u79fb\uff0c\u8303\u56f4\u4e3a-32768~32767<\/p>\n<p>4.\u8f6c\u79fb\u7684\u76ee\u7684\u5730\u5740\u5728\u6307\u4ee4\u4e2d\u7684jmp\u6307\u4ee4<\/p>\n<pre><code><strong>&#183;jmp far ptr \u6807\u53f7<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u5b9e\u73b0\u6bb5\u95f4\u8f6c\u79fb(\u8fdc\u8f6c\u79fb),\u529f\u80fd<u>:(CS)=\u6807\u53f7\u6240\u5728\u7684\u6bb5\u5730\u5740 (IP)=\u6807\u53f7\u6240\u5728\u6bb5\u7684\u504f\u79fb\u5730\u5740<\/u><u><\/u><\/p>\n<p>\u6807\u53f7\u6307\u660e\u4e86\u6bb5\u5730\u5740\u548c\u504f\u79fb\u5730\u5740<\/p>\n<p>\u5728debug\u4e2d\u663e\u793a\u4e3ajmp xxxx:xxxx<\/p>\n<pre><code><![if !supportLists]>5. <![endif]>\u8f6c\u79fb\u6307\u4ee4\u5728\u5bc4\u5b58\u5668\u4e2d\n<strong>&#183;jmp 16\u4f4dreg<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u529f\u80fd <u>(IP)=(16\u4f4dreg)<\/u><\/p>\n<pre><code><![if !supportLists]>6. <![endif]>\u8f6c\u79fb\u5730\u5740\u5728\u5185\u5b58\u4e2d\u7684jmp\u6307\u4ee4\n<strong>&#183;jmp word ptr \u5185\u5b58\u5355\u5143\u5730\u5740(\u6bb5\u5185\u8f6c\u79fb)<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u529f\u80fd:\u4ece\u5185\u5b58\u5355\u5143\u5730\u5740\u5904<u>\u53d6\u51fa\u4e00\u4e2a\u5b57\uff0c\u4f5c\u4e3a\u8f6c\u79fb\u7684\u76ee\u7684\u5730\u5740<\/u><\/p>\n<pre><code><strong>&#183;jmp dword ptr \u5185\u5b58\u5355\u5143\u5730\u5740(\u6bb5\u95f4\u8f6c\u79fb)<\/strong><strong><\/strong><\/code><\/pre>\n<p>\u529f\u80fd:\u4ece\u5185\u5b58\u5355\u5143\u4e2d\u53d6\u51fa\u4e24\u4e2a\u5b57\uff0c\u9ad8\u5730\u5740\u5904\u7684\u5b57\u662f\u8f6c\u79fb\u7684\u76ee\u7684\u6bb5\u5730\u5740\uff0c\u4f4e\u5730\u5740\u5904\u4e3a\u8f6c\u79fb\u7684\u76ee\u7684\u504f\u79fb\u5730\u5740\u3002\u5373:<\/p>\n<p><u>(CS)=(\u5185\u5b58\u5355\u5143\u5730\u5740+2)<\/u><u><\/u><\/p>\n<p><u>(IP)=(\u5185\u5b58\u5355\u5143\u5730\u5740)<\/u><u><\/u><\/p>\n<p>\u68c0\u6d4b\u70b99.1<\/p>\n<p>\uff081\uff09\u7a0b\u5e8f\u5982\u4e0b\u3002<\/p>\n<pre><code>assume cs:code\ndata segment\n   dw 2 dup (0)\ndata ends\ncode segment\n  start: mov ax,dtat\n         mov ds,ax\n         mov bx,0\n         jmp word ptr [bx+1]\ncode ends\nend start<\/code><\/pre>\n<p>\u82e5\u8981\u4f7fjmp\u6307\u4ee4\u6267\u884c\u540e\uff0cCS:IP\u6307\u5411\u7a0b\u5e8f\u7684\u7b2c\u4e00\u6761\u6307\u4ee4\uff0c\u5728data\u6bb5\u4e2d\u5e94\u8be5\u5b9a\u4e49\u54ea\u4e9b\u6570\u636e?<\/p>\n<p> <\/p>\n<pre><code>\u7b54\u6848\u2460db 3 dup (0)\n\u7b54\u6848\u2461dw 2 dup (0)<\/code><\/pre>\n<p>\u7b54\u6848\u2462dd 0<\/p>\n<pre><code>jmp word ptr [bx+1]\u4e3a\u6bb5\u5185\u8f6c\u79fb\uff0c\u8981CS:IP\u6307\u5411\u7a0b\u5e8f\u7684\u7b2c\u4e00\u6761\u6307\u4ee4\uff0c\u5e94\u8bbe\u7f6eds:[bx+1]\u7684\u5b57\u5355\u5143(2\u4e2a\u5b57\u8282)\u5b58\u653e\u6570\u636e\u5e94\u4e3a0\uff0c\u5219(ip)=ds:[bx+1]=0<\/code><\/pre>\n<p>\u7b80\u5355\u6765\u8bf4\u5c31\u662f\uff0c\u53ea\u8981ds:[bx+1]\u8d77\u59cb\u5730\u5740\u7684\u4e24\u4e2a\u5b57\u8282\u4e3a0\u5c31\u53ef\u4ee5\u4e86<\/p>\n<p>(2)\u7a0b\u5e8f\u5982\u4e0b\u3002<\/p>\n<pre><code>assume cs:code\ndata segment\n   dd 12345678h\ndata ends\ncode segment\n  start: mov ax,data\n         mov ds,ax\n         mov bx,0\n         mov [bx],<u>  bx    <\/u>;\u6216mov [bx],<u> word ptr 0 <\/u>;\u6216mov [bx],<u> offset start <\/u>\n         mov [bx+2],<u>  cs  <\/u>;\u6216mov [bx+2],<u>  cs      <\/u>;\u6216mov [bx+2],<u> seg code   <\/u>\n         jmp dword ptr ds:[0]\ncode ends\nend start<\/code><\/pre>\n<p>\u8865\u5168\u7a0b\u5e8f\uff0c\u4f7f\u7528jmp\u6307\u4ee4\u6267\u884c\u540e\uff0cCS:IP\u6307\u5411\u7a0b\u5e8f\u7684\u7b2c\u4e00\u6761\u6307\u4ee4\u3002<\/p>\n<p> <\/p>\n<p>\u7b2c\u4e00\u683c\u53ef\u586b\u2460mov [bx],bx\u2461mov [bx],word ptr 0\u2462mov [bx],offset start\u7b49\u3002<\/p>\n<p>\u7b2c\u4e8c\u683c\u53ef\u586b\u2460mov [bx+2],cs\u2461mov [bx+2],cs\u2462mov [bx+2],seg code\u7b49\u3002<\/p>\n<pre><code>\u89e3\u6790\uff1a\njmp dword ptr ds:[0]\u4e3a\u6bb5\u95f4\u8f6c\u79fb\uff0c(cs)=(\u5185\u5b58\u5355\u5143\u5730\u5740+2),(ip)=(\u5185\u5b58\u5355\u5143\u5730\u5740)\uff0c\u8981CS:IP\u6307\u5411\u7a0b\u5e8f\u7684\u7b2c\u4e00\u6761\u6307\u4ee4\uff0c\u7b2c\u4e00\u6761\u7a0b\u5e8f\u5730\u5740cs:0\uff0c\u5e94\u8bbe\u7f6eCS:IP\u6307\u5411cs:0 <\/code><\/pre>\n<p>\u7a0b\u5e8f\u4e2d\u7684mov [bx],bx\u8fd9\u6761\u6307\u4ee4\uff0c\u662f\u5c06ip\u8bbe\u7f6e\u4e3a0  <\/p>\n<pre><code>mov [bx+2],cs\uff0c\u5c06cs\u8fd9\u4e2a\u6bb5\u5730\u5740\u653e\u5165\u5185\u5b58\u5355\u5143  <\/code><\/pre>\n<p>\u6267\u884c\u540e\uff0ccs\u5e94\u8be5\u4e0d\u53d8\uff0c\u53ea\u8c03\u6574ip\u4e3a0\uff0c(ip)=ds:[0]=0<\/p>\n<p>\uff083\uff09\u7528Debug\u67e5\u770b\u5185\u5b58\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre><code>2000:1000 BE 00 06 00 00 00 ......<\/code><\/pre>\n<p>\u5219\u6b64\u65f6\uff0cCPU\u6267\u884c\u6307\u4ee4\uff1a<\/p>\n<pre><code>mov ax,2000h\nmov es,ax\njmp dword ptr es:[1000h]<\/code><\/pre>\n<p>\u540e\uff0c(cs)=<u> 0006H <\/u>\uff0c(ip)=<u> 00BEH <\/u><u><\/u><\/p>\n<p> <\/p>\n<pre><code>\u89e3\u6790\uff1a\njmp dword ptr\u4e3a\u6bb5\u95f4\u8f6c\u79fb\uff0c\u9ad8\u4f4d\u5b58\u653e\u6bb5\u5730\u5740\uff0c\u4f4e\u4f4d\u5b58\u653e\u504f\u79fb\u5730\u5740<\/code><\/pre>\n<p>(cs)=(\u5185\u5b58\u5355\u5143\u5730\u5740+2)\uff0c(ip)=(\u5185\u5b58\u5355\u5143\u5730\u5740)<\/p>\n<p> <\/p>\n<p>\u6839\u636e\u4e66P16\uff0c\u5bf9\u4e8e\u5bc4\u5b58\u5668AX\uff0cAH\u4e3a\u9ad8\u4f4d(\u524d1\u5b57\u8282\u4e3a\u9ad8\u4f4d)\uff0cAL\u4e3a\u4f4e\u4f4d(\u540e1\u5b57\u8282\u4e3a\u4f4e\u4f4d)<\/p>\n<p>\u63a8\u7b97\u51fa(\u5185\u5b58\u5355\u5143\u5730\u5740)=00beh\uff0c(\u5185\u5b58\u5355\u5143\u5730\u5740+2)=0006h<\/p>\n<p>\u6839\u636e\u4e66P182\uff0c\u9ad8\u4f4d\u5b58\u653e\u6bb5\u5730\u5740(\u540e2\u4e2a\u5b57\u8282\u4e3a\u9ad8\u4f4d)\uff0c\u4f4e\u4f4d\u5b58\u653e\u504f\u79fb\u5730\u5740(\u524d2\u4e2a\u5b57\u8282\u4e3a\u4f4e\u4f4d)<\/p>\n<p>(cs)=(\u5185\u5b58\u5355\u5143\u5730\u5740+2)\uff0c(ip)=(\u5185\u5b58\u5355\u5143\u5730\u5740)<\/p>\n<p>\u63a8\u7b97\u51fa(cs)=0006h\uff0c(ip)=00beh<\/p>\n<p>9.7 jcxz\u6307\u4ee4<\/p>\n<p>1.jcxz\u6307\u4ee4\u4e3a\u6709\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4\uff0c\u6240\u6709\u7684\u6709\u6761\u4ef6\u8f6c\u79fb\u6307\u4ee4\u90fd\u662f\u77ed\u8f6c\u79fb\u3002\u5728\u5bf9\u5e94\u7684\u673a\u5668\u7801\u4e2d\u5305\u542b\u8f6c\u79fb\u7684\u4f4d\u79fb<\/p>\n<p>2.\u683c\u5f0f:<strong>jcxz \u6807\u53f7<\/strong>(<u>\u5982\u679c(cx)=0\u8f6c\u79fb\u5230\u6807\u53f7\u5904\u6267\u884c\u3002<\/u>)<\/p>\n<p>3\u64cd\u4f5c:\u5f53(cx)=0\u65f6,(IP)=(IP)+8\u4f4d\u4f4d\u79fb<\/p>\n<p>\u5f53(cx)!=0\u65f6,\u7a0b\u5e8f\u5411\u4e0b\u6267\u884c,jcxz\u4ec0\u4e48\u90fd\u4e0d\u505a<\/p>\n<pre><code>\u76f8\u5f53\u4e8e:if((cx)==0)jmp short \u6807\u53f7;<\/code><\/pre>\n<p>\u68c0\u6d4b\u70b99.2 <\/p>\n<p>\u8865\u5168\u7f16\u7a0b\uff0c\u5229\u7528jcxz\u6307\u4ee4\uff0c\u5b9e\u73b0\u5728\u5185\u5b582000H\u6bb5\u4e2d\u67e5\u627e\u7b2c\u4e00\u4e2a\u503c\u4e3a0\u7684\u5b57\u8282\uff0c\u627e\u5230\u540e\uff0c\u5c06\u5b83\u7684\u504f\u79fb\u5730\u5740\u5b58\u50a8\u5728dx\u4e2d\u3002<\/p>\n<pre><code>assume cs:code\ncode segment\n start: mov ax,2000h\n        mov ds,ax\n        mov bx,0\n     s:<u> mov ch,0    <\/u><u><\/u>\n       <u> mov cl,[bx] <\/u><u><\/u><\/code><\/pre>\n<p>       <u> jcxz ok     <\/u>;\u5f53cx=0\u65f6\uff0cCS:IP\u6307\u5411OK<\/p>\n<pre><code>       <u> inc bx      <\/u><u><\/u>\n        jmp short s \n    ok: mov dx,bx\n        mov ax ,4c00h\n        int 21h\ncode ends\nend start<\/code><\/pre>\n<p>9.8 loop\u6307\u4ee4<\/p>\n<p>1.loop\u4e3a\u5faa\u73af\u6307\u4ee4\uff0c<strong>\u6240\u6709\u7684\u5faa\u73af\u6307\u4ee4\u90fd\u662f\u77ed\u8f6c\u79fb<\/strong>\uff0c\u5728\u5bf9\u5e94\u7684\u673a\u5668\u7801\u4e2d\u5305\u542b\u7684\u662f\u4f4d\u79fb<\/p>\n<p>2.loop\u6807\u53f7 \u76f8\u5f53\u4e8e<\/p>\n<p>(cx)&#8211;;<\/p>\n<pre><code>if((cx)!=0)jmp short \u6807\u53f7;<\/code><\/pre>\n<p>\u68c0\u6d4b\u70b99.3<\/p>\n<p>\u8865\u5168\u7f16\u7a0b\uff0c\u5229\u7528loop\u6307\u4ee4\uff0c\u5b9e\u73b0\u5728\u5185\u5b582000H\u6bb5\u4e2d\u67e5\u627e\u7b2c\u4e00\u4e2a\u503c\u4e3a0\u7684\u5b57\u8282\uff0c\u627e\u5230\u540e\uff0c\u5c06\u5b83\u7684\u504f\u79fb\u5730\u5740\u5b58\u50a8\u5728dx\u4e2d\u3002<\/p>\n<pre><code>assume cs:code \ncode segment \nstart:  mov ax,2000h \n        mov ds,ax \n        mov bx,0\n      s:mov cl,[bx] \n        mov ch,0 \n       <u> inc cx      <\/u><u><\/u>\n        inc bx \n        loop s \n     ok:dec bx \n        mov dx,bx \n        mov ax,4c00h \n        int 21h \ncode ends \nend start\n\u6267\u884cloop s\u65f6\uff0c\u9996\u5148\u8981\u5c06(cx)\u51cf1\u3002\n\u201cloop \u6807\u53f7\u201d\u76f8\u5f53\u4e8e\ndec cx\nif((cx)\u22600) jmp short \u6807\u53f7<\/code><\/pre>\n<p>9.9 \u6839\u636e\u4f4d\u79fb\u8fdb\u884c\u8f6c\u79fb\u7684\u610f\u4e49:\u65b9\u4fbf\u7a0b\u5e8f\u6bb5\u5728\u5185\u5b58\u4e2d\u7684\u6d6e\u52a8\u88c5\u914d<\/p>\n<p>9.10\u7f16\u8bd1\u5668\u5bf9\u8f6c\u79fb\u4f4d\u79fb\u8d85\u754c\u7684\u68c0\u6d4b:\u5982\u679c\u8f6c\u79fb\u8303\u56f4\u8d85\u754c,\u7f16\u8bd1\u5668\u62a5\u9519\u3002\u5f62\u5982jmp xxxx:xxxx\u7684\u6307\u4ee4\u5728debug\u4e0b\u53ef\u7528,\u4f46\u4e0d\u80fd\u5728\u6e90\u7a0b\u5e8f\u4e2d\u5199\u51fa\u3002<\/p>\n<p>\u5b9e\u9a8c8 \u5206\u6790\u4e00\u4e2a\u5947\u602a\u7684\u7a0b\u5e8f<\/p>\n<p>\u8be5\u7a0b\u5e8f\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u8fd4\u56de?<\/p>\n<pre><code><strong>Program ex-8-1<\/strong><strong><\/strong>\n<strong>assume cs:codesg<\/strong><strong><\/strong>\n<strong>codesg segment<\/strong><strong><\/strong>\n<strong>    mov ax,4c00h<\/strong><strong><\/strong>\n<strong>    int 21h<\/strong><strong><\/strong>\n<strong>start: mov ax,0            ;ax=0<\/strong><strong><\/strong>\n<strong>    s: nop                 ;\u5360\u4e00\u5b57\u8282,\u673a\u5668\u780190<\/strong><strong><\/strong>\n<strong>       nop                 ;\u5360\u4e00\u5b57\u8282,\u673a\u5668\u780190<\/strong><strong><\/strong>\n<strong>       mov di,offset s     ;(di)=s\u504f\u79fb\u5730\u5740<\/strong><strong><\/strong>\n<strong>       mov si,offset s2    ;(si)=s2\u504f\u79fb\u5730\u5740<\/strong><strong><\/strong>\n<strong>       mov ax,cs:[si]      ;(ax)=jmp short s1\u6307\u4ee4\u5bf9\u5e94\u7684\u673a\u5668\u7801EBF6<\/strong><strong><\/strong>\n<strong>       mov cs:[di],ax      ;jmp short s1\u8986\u76d6s\u5904\u6307\u4ee42\u6761nop\u6307\u4ee4<\/strong><strong><\/strong>\n<strong>   s0: jmp short s         ;\u6267\u884cs???? \u672a\u6267\u884c\u5230\u8fd9\u91cc\uff0c\u76f4\u63a5\u8df3\u56demov ax,4c00h\u4e86<\/strong><strong><\/strong>\n<strong>   s1: mov ax,0<\/strong><strong><\/strong>\n<strong>       int 21h<\/strong><strong><\/strong>\n<strong>       mov ax,0<\/strong><strong><\/strong>\n<strong>   s2: jmp short s1       <\/strong><strong><\/strong>\n<strong>       nop<\/strong><strong><\/strong>\n<strong>codesg ends<\/strong><strong><\/strong>\n<strong>end start<\/strong><strong><\/strong>\n<img fetchpriority=\"high\" decoding=\"async\" width=\"284\"  height=\"236\"  src=\"http:\/\/8.129.82.128\/wp-content\/uploads\/2026\/03\/asm202405\u7248\u63d0\u7eb234223.png\"  align=\"left\"  hspace=\"12\" ><-debug\u4e0b\u7684\u5185\u5bb9\n\u6ce8\u610f\u5230\u6240\u8c13\u7684jmp short s\u5b9e\u9645\u4e0a\u662fEBF6\u8fd9\u6837\u7684\u6307\u4ee4,F6\u4e3a\u4f4d\u79fb\u3002\u6839\u636e\u6bcf\u6761\u6307\u4ee4\u7684\u957f\u5ea6\u8ba1\u7b97\u51fa\u88ab\u8986\u76d6\u7684nop\u6307\u4ee4\u79fb\u52a8F6\u4e2a\u5b57\u8282\u540e\u6307\u5411\u90a3\u4e00\u6761\u6307\u4ee4\u3002<\/code><\/pre>\n<p>\u5173\u4e8ejmp\u6307\u4ee4\u7684\u4f4d\u79fb\u5185\u5bb9<\/p>\n<pre><code>\u5f53\u6307\u4ee4\u6267\u884c\u5230s0:jmp short s\u65f6\uff0c\u8be5\u6307\u4ee4\u5f97\u5230\u6267\u884c\uff0c\u7f16\u8bd1\u5668\u7b97\u51fa\u7684ip\u4f4d\u79fb\u91cf\u4e3a8-18h\uff1d-16(\u8865\u7801F0)\uff0c(ip)=(ip)+\u4f4d\u79fb\u91cf=18h+(-16)=8\uff0ccs:8\u6307\u5411s\uff1b<\/code><\/pre>\n<p>\u5f53\u6307\u4ee4\u6267\u884c\u5230s\u6807\u6bb5jmp\u547d\u4ee4\u65f6\uff0c\u7b2c1\u4e2a\u5b57\u8282\u4e2d\u7684\u673a\u5668\u7801\u4e3aEBF6\uff0c\u7ed9\u51fa\u7684ip\u4f4d\u79fb\u91cf\u4e3a-10(\u8865\u7801F6)\uff0c(ip)=(ip)+\u4f4d\u79fb\u91cf=ah+(-10)=0,cs:0\u6307\u5411\u7b2c\u4e00\u6761\u6307\u4ee4\u3002<\/p>\n<p> <\/p>\n<p><strong>\u5b9e\u9a8c9 \u663e\u793a\u4e09\u884cwelcome to masm<\/strong><strong>(\u6839\u636e\u6750\u6599\u7f16\u7a0b)<\/strong><strong><\/strong><\/p>\n<p>\u7f16\u7a0b\uff1a\u5728\u5c4f\u5e55\u4e2d\u95f4\u5206\u522b\u663e\u793a\u7eff\u8272\uff0c\u7eff\u5e95\u7ea2\u8272\uff0c\u767d\u8272\u84dd\u5e95\u7684\u5b57\u7b26\u4e32\u2019welcome to masm!\u2019<\/p>\n<p><img decoding=\"async\" width=\"453\"  height=\"231\"  src=\"http:\/\/8.129.82.128\/wp-content\/uploads\/2026\/03\/asm202405\u7248\u63d0\u7eb234586.png\" > <\/p>\n<p>\u6750\u6599:80x25<strong>\u5f69\u8272\u5b57\u7b26\u6a21\u5f0f\u663e\u793a\u7f13\u51b2\u533a<\/strong>\u7684\u4ecb\u7ecd<\/p>\n<p><u>1.<\/u><u>\u7f13\u51b2\u533a\u6240\u5728\u7684\u5185\u5b58\u5730\u5740:B8000H~BFFFFH(\u517132KB)<\/u><u><\/u><\/p>\n<p><u>2.<\/u><u>\u5411\u8be5\u5730\u5740\u7a7a\u95f4\u5199\u5165\u6570\u636e,\u5199\u5165\u7684\u5185\u5bb9\u7acb\u5373\u51fa\u73b0\u5728\u663e\u793a\u5668\u4e0a\u3002<\/u><u><\/u><\/p>\n<p><u>3.<\/u><u>\u663e\u793a\u5668\u53ef\u4ee5\u663e\u793a25\u884c,\u6bcf\u884c80\u4e2a\u5b57\u7b26,\u6bcf\u4e2a\u5b57\u7b26\u53ef\u4ee5\u6709256\u4e2d\u5c5e\u6027<\/u><u><\/u><\/p>\n<p><u>4.<\/u><u>\u4e00\u4e2a\u5b57\u7b26\u5728\u663e\u793a\u7f13\u51b2\u533a\u4e2d\u5360\u4e24\u4e2a\u5b57\u8282\uff0c\u5206\u522b\u5b58\u653e\u5b57\u7b26\u7684ASCII\u7801\u548c\u5c5e\u6027,\u4f4e\u4f4d\u5b57\u8282\u5b58\u653e\u5b57\u7b26ASCII\u7801,\u9ad8\u4f4d\u5b57\u8282\u5b58\u653e\u5c5e\u6027<\/u><u><\/u><\/p>\n<p><u>5.<\/u><u>80x25\u6a21\u5f0f\u4e0b,\u4e00\u5c4f\u7684\u5185\u5bb9\u5728\u663e\u793a\u7f13\u51b2\u533a\u53604000\u4e2a\u5b57\u8282\u3002<\/u><u><\/u><\/p>\n<p><u>6.<\/u><u>\u663e\u793a\u7f13\u51b2\u533a\u51718\u9875\uff0c\u6bcf\u98754KB<\/u><u><\/u><\/p>\n<p><u>7.<\/u><u>\u663e\u793a\u5668\u53ef\u4ee5\u663e\u793a\u4efb\u610f\u4e00\u9875\u7684\u5185\u5bb9,\u4e00\u822c\u663e\u793a\u7b2c0\u9875(B8000H~B8F9FH)\u7684\u5185\u5bb9<\/u><u><\/u><\/p>\n<p>8.\u5728\u4e00\u9875\u663e\u793a\u7f13\u51b2\u533a\u4e2d:<\/p>\n<table class=MsoTableGrid  border=1  cellspacing=0 ><tr><td width=242  valign=top ><p>\u504f\u79fb<\/p>\n<\/td><td width=401  valign=top ><p>\u5bf9\u5e94\u663e\u793a\u5668\u7684\u884c\u6570<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>000~09F<\/p>\n<\/td><td width=401  valign=top ><p>1<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>0A0~13F<\/p>\n<\/td><td width=401  valign=top ><p>2<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>F00~F9F<\/p>\n<\/td><td width=401  valign=top ><p>25<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>\u5355\u5143<\/p>\n<\/td><td width=401  valign=top ><p>\u5bf9\u5e94\u663e\u793a\u5668\u7684\u5217\u6570<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>00 01<\/p>\n<\/td><td width=401  valign=top ><p>\u7b2c1\u5217<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>02 03<\/p>\n<\/td><td width=401  valign=top ><p>\u7b2c2\u5217<\/p>\n<\/td><\/tr><tr><td width=242  valign=top ><p>9E 9F<\/p>\n<\/td><td width=401  valign=top ><p>\u7b2c80\u5217<\/p>\n<\/td><\/tr><\/table><p>9.\u5728\u663e\u793a\u7f13\u51b2\u533a\u4e2d\uff0c\u5076\u5730\u5740\u5b58\u653e\u5b57\u7b26,\u5947\u5730\u5740\u5b58\u653e\u5b57\u7b26\u5c5e\u6027<\/p>\n<p><img decoding=\"async\" width=\"304\"  height=\"87\"  src=\"http:\/\/8.129.82.128\/wp-content\/uploads\/2026\/03\/asm202405\u7248\u63d0\u7eb234996.png\"  align=\"left\"  hspace=\"12\" >10.<strong>\u5c5e\u6027\u5b57\u8282<\/strong>\u7684\u683c\u5f0f<\/p>\n<p>R \u7ea2\u8272<\/p>\n<p>G \u7eff\u8272<\/p>\n<p>B \u84dd\u8272<\/p>\n<p>\u5e38\u7528:<\/p>\n<p><u>\u7ea2\u5e95\u7eff\u5b57<\/u><u>0100 0010B<\/u><u><\/u><\/p>\n<p><u>\u7ea2\u5e95\u95ea\u70c1\u7eff\u5b57<\/u><u>1100 0010B<\/u><u><\/u><\/p>\n<p><u>\u7ea2\u5e95\u9ad8\u4eae\u7eff\u5b57<\/u><u>0100 1010B<\/u><u><\/u><\/p>\n<p><u>\u9ed1\u5e95\u767d\u5b57<\/u><u>0000 0111B<\/u><u><\/u><\/p>\n<p><u>\u767d\u5e95\u84dd\u5b57<\/u><u>0111 0001B<\/u><u><\/u><\/p>\n<p>Program ex-9-1 \u81ea\u4e3b\u89e3\u6cd5<\/p>\n<pre><code>assume cs<strong>:<\/strong>code,ds<strong>:<\/strong>data,ss<strong>:<\/strong>stack<br>data segment<br>    db <strong>'<\/strong>welcome to masm!<strong>'<\/strong>    <br>    db 00000010B     <i>;\u7eff\u8272(16)<\/i><i><br><\/i>    db 00100100B    <i>;\u7eff\u5e95\u7ea2\u5b57(17)<\/i><i><br><\/i>    db 01110001B    <i>;\u767d\u5e95\u84dd\u5b57(18)<\/i><i><br><\/i>data ends<br>stack segment<br>    db 16 dup<strong>(<\/strong>0<strong>)<\/strong><strong><br><\/strong>stack ends<br>code segment<br>start<strong>:<\/strong><strong><br><\/strong>    <strong>mov<\/strong> ax,0b800h<br>    <strong>mov<\/strong> es,ax    <i>;es=\u663e\u793a\u7f13\u51b2\u533a<\/i><i><br><\/i>    <strong>mov<\/strong> di,1660    <i>;\u7b2c10\u884c\u7b2c40\u5217<\/i><i><br><\/i>    <strong>mov<\/strong> ax,data<br>    <strong>mov<\/strong> ds,ax    <i>;ds=data<\/i><i><br><\/i>    <strong>mov<\/strong> ax,stack<br>    <strong>mov<\/strong> ss,ax    <i>;ss=stack<\/i><i><br><\/i>    <strong>mov<\/strong> sp,16<br>    <strong>mov<\/strong> si,0<br>    <strong>mov<\/strong> cx,3<br>    <strong>mov<\/strong> bx,16<br>s0<strong>:<\/strong> <strong>push<\/strong> cx<br>    <strong>mov<\/strong> cx,16<br>s<strong>:<\/strong>  <strong>mov<\/strong> ax,0<br>    <strong>mov<\/strong> al,[si]<br>    <strong>mov<\/strong> es<strong>:<\/strong>[di],ax<br>    <strong>mov<\/strong> dl,[bx]<br>    <strong>mov<\/strong> es<strong>:<\/strong>[di<strong>+<\/strong>1],dl<br>    <strong>add<\/strong> di,2<br>    <strong>inc<\/strong> si<br>    <strong>loop<\/strong> s<br>    <strong>sub<\/strong> di,32<br>    <strong>add<\/strong> di,160<br>    <strong>mov<\/strong> si,0<br>    <strong>inc<\/strong> bx<br>    <strong>pop<\/strong> cx<br>    <strong>loop<\/strong> s0<br>    <strong>mov<\/strong> ax,4c00h<br>    <strong>int<\/strong> 21h<br>code ends<br>end start<\/code><\/pre>\n<p>Program ex-9-2 \u53c2\u8003<\/p>\n<pre><code>assume cs:code,ds:data\ndata segment\ndb 'welcome to masm!'\ndata ends\ncode segment\nstart:mov ax,data\nmov ds,ax\nmov bx,0;ds:bx\u6307\u5411data\u5b57\u7b26\u4e32\nmov ax,0b800h\nmov es,ax\nmov si,0;es:si\u6307\u5411\u663e\u5b58\nmov cx,16\ns:mov al,[bx];\u5b57\u7b26\u8d4b\u503cal\nmov ah,02h;\u7eff\u8272\nmov es:[si].720h,ax;\u5199\u5165\u7b2c12\u884c64\u5217\nmov ah,14h;\u7eff\u5e95\u7ea2\u8272\nmov es:[si].7c0h,ax;\u5199\u5165\u7b2c13\u884c64\u5217\nmov ah,71h;\u767d\u5e95\u84dd\u8272\nmov es:[si].860h,ax;\u5199\u5165\u7b2c14\u884c64\u5217\ninc bx;\u6307\u5411\u4e0b\u4e00\u5b57\u7b26\nadd si,2;\u6307\u5411\u4e0b\u4e00\u663e\u5b58\u5355\u5143\nloop s\nmov ax,4c00h\nint 21h\ncode ends\nend start<\/code><\/pre>\n<p><strong>\n    <\/div>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e5d\u7ae0 \u8f6c\u79fb\u6307\u4ee4\u7684\u539f\u7406 &#8211;  [&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-502","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\/502","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=502"}],"version-history":[{"count":1,"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions"}],"predecessor-version":[{"id":503,"href":"http:\/\/8.129.82.128\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions\/503"}],"wp:attachment":[{"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.129.82.128\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}