{"id":1295,"date":"2018-10-24T23:41:03","date_gmt":"2018-10-24T15:41:03","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=1295"},"modified":"2018-10-25T11:27:30","modified_gmt":"2018-10-25T03:27:30","slug":"%e6%b1%87%e7%bc%96%e4%b8%ad%e5%87%bd%e6%95%b0%e5%b1%80%e9%83%a8%e5%8f%98%e9%87%8f%e7%9a%84%e5%ae%9e%e7%8e%b0%e6%9c%ac%e8%b4%a8","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/assembler\/2018\/10\/24\/2341031295.html","title":{"rendered":"\u51fd\u6570\u8c03\u7528\u539f\u7406&#8211;\u5c40\u90e8\u53d8\u91cf\u7bc7"},"content":{"rendered":"<p>1\u3001\u53c2\u8003\u94fe\u63a5<br \/>\n1.1\u3001<a href=\"http:\/\/www.yusian.com\/blog\/assembler\/2018\/10\/24\/173913.html\">\u51fd\u6570\u8c03\u7528\u539f\u7406\u2013\u53c2\u6570\u7bc7<\/a><\/p>\n<p>2\u3001\u51fd\u6570\u9700\u8981\u89e3\u51b3\u7684\u4e09\u5927\u95ee\u9898\uff1a\u53c2\u6570\u3001\u8fd4\u56de\u503c\u3001\u5c40\u90e8\u53d8\u91cf<br \/>\n2.1\u3001\u53c2\u6570\u5728\u51fd\u6570\u6267\u884c\u524d\u538b\u6808\uff0c\u6267\u884c\u7ed3\u675f\u540e\u6062\u590d\u5185\u5e73\u6808\u6216\u5916\u5e73\u6808\u7684\u65b9\u5f0f\u6062\u590d\u6808\u9876\u4f4d\u7f6e\u91ca\u653e\u7a7a\u95f4\uff1b<br \/>\n2.2\u3001\u8fd4\u56de\u503c\u4e00\u822c\u76f4\u63a5\u5b58\u50a8\u5728\u5bc4\u5b58\u5668ax\u4e2d\uff0c\u51fd\u6570\u8fd0\u884c\u7ed3\u675f\u540e\u5728ax\u4e2d\u8bfb\u53d6<br \/>\n2.3\u3001\u51fd\u6570\u5185\u90e8\u7684\u5c40\u90e8\u53d8\u91cf\u4e5f\u662f\u901a\u8fc7\u6808\u6765\u5b58\u50a8<\/p>\n<p>3\u3001\u51fd\u6570\u5c40\u90e8\u53d8\u91cf\u9762\u4e34\u7684\u51e0\u4e2a\u95ee\u9898<br \/>\n3.1\u3001\u4e13\u7528\u7a7a\u95f4\uff0c\u4e0d\u88ab\u5176\u4ed6\u6570\u636e\u8986\u76d6\uff1b<br \/>\n3.2\u3001\u5bf9\u6808\u8fdb\u884c\u64cd\u4f5c\uff0c\u7ed3\u675f\u540e\u9700\u8981\u5bf9\u6808\u8fdb\u884c\u6062\u590d\u64cd\u4f5c\uff1b<br \/>\n3.3\u3001\u4e34\u65f6\u7a7a\u95f4\u4f7f\u7528\u7ed3\u675f\u540e\u53ca\u65f6\u91ca\u653e<\/p>\n<p>4\u3001\u57fa\u672c\u5b9e\u73b0\u601d\u8def<br \/>\n4.1\u3001\u4fdd\u5b58\u6808\u9876\u4f4d\u7f6e(sp)\uff1b<br \/>\n4.2\u3001\u5c06\u6808\u9876\u4f4d\u7f6e\u5f80\u524d\u79fb\u52a8\u4e00\u6bb5\u4f4d\u7f6e\u505a\u4e3a\u5c40\u90e8\u53d8\u91cf\u4e13\u6709\u7a7a\u95f4\uff1b<br \/>\n4.3\u3001\u901a\u8fc7\u539f\u6808\u9876+\u504f\u79fb\u4f4d\u7f6e(bp\u5bc4\u5b58\u5668)\u6765\u8bbf\u95ee\u4e13\u7528\u7684\u4e34\u65f6\u7a7a\u95f4\uff1b<br \/>\n4.4\u3001\u7ed3\u675f\u540e\u6062\u590d\u539f\u6765\u6808\u9876\u4f4d\u7f6e\uff1b<br \/>\n4.5\u3001\u8003\u8651\u5230\u51fd\u6570\u7684\u5d4c\u5957\u8c03\u7528\uff0c\u4fdd\u62a4\u548c\u6062\u590dbp\u540c\u6837\u91cd\u8981\uff01<\/p>\n<p>5.0\u3001\u6c47\u7f16\u4ee3\u7801\u5b9e\u73b0<!--more--><\/p>\n<pre lang=\"asm\" line=\"1\">assume cs:code, ds:data, ss:stack\r\n\r\nstack segment\r\n    db 20h dup(1)\r\nstack ends\r\n\r\ndata segment\r\n    db 20h dup(2)\r\ndata ends\r\n\r\ncode segment\r\nstart:\r\n    ;\u521d\u59cb\u5316\r\n    mov ax, stack\r\n    mov ss, ax\r\n    mov sp, 20h\r\n    mov ax, data\r\n    mov ds, ax  \r\n    ;\u4e1a\u52a1\u4ee3\u7801(\u51fd\u6570\u5c40\u90e8\u53d8\u91cf\u5b9e\u73b0) \r\n    push 3344h\r\n    push 4455h\r\n    call sum;\u8ba1\u7b97\u7ed3\u679c\u4fdd\u5b58\u5728ax\u4e2d\r\n    add sp, 4\r\n    ;\u9000\u51fa             \r\n    mov ah, 4ch\r\n    int 21h\r\nsum:\r\n    push bp;\u4fdd\u62a4bp\r\n    mov bp, sp;\u4fdd\u62a4sp\r\n    sub sp, 10h;\u7a7a\u51fa10\u4e2a\u5b57\u8282\u7ed9\u5c40\u90e8\u53d8\u91cf\u4f7f\u7528\r\n    ;----\u4e1a\u52a1\u4ee3\u7801------start   \r\n    ;\u53d6\u53c2\u6570\u5e76\u8ba1\u7b97\uff0c\u7531\u4e8epush bp\u5360\u7528\u4e862\u4e2a\u5b57\u8282\uff0c\u53c2\u6570\u4ecebp+4\u5f00\u59cb\r\n    mov ax, [bp+6]\r\n    add ax, [bp+4]\r\n    mov [bp-2], 2324h;\u5c40\u90e8\u53d8\u91cf1\r\n    mov [bp-4], 3435h;\u5c40\u90e8\u53d8\u91cf2  \r\n    ;----\u4e1a\u52a1\u4ee3\u7801-------end\r\n    mov sp, bp;\u6062\u590dsp\r\n    pop bp;\u6062\u590dbp\r\n    ret \r\ncode ends\r\nend start<\/pre>\n<p>6\u3001\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1-300x195.png\" alt=\"\" width=\"600\" height=\"390\" class=\"alignnone size-medium wp-image-1298\" srcset=\"https:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1-300x195.png 300w, https:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1-768x500.png 768w, https:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1-1024x667.png 1024w, https:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1-624x406.png 624w, https:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2018\/10\/func_args-1.png 1988w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>7\u3001C++\u6e90\u4ee3\u7801\u53cd\u6c47\u7f16\u7ed3\u679c<br \/>\n7.1\u3001C++\u6e90\u7801<\/p>\n<pre lang=\"cpp\" line=\"1\">\/\/ VCTest.cpp : Defines the entry point for the console application.\r\n\/\/\r\n\r\n#include \"stdafx.h\"\r\n\r\nint sum(int a, int b)\r\n{\r\n\tint c = 20;\r\n\tint d = 30;\r\n\treturn a + b;\r\n}\r\nint main(int argc, char* argv[])\r\n{\r\n\tsum(2, 3);\r\n\treturn 0;\r\n}<\/pre>\n<p>7.2\u3001\u51fd\u6570\u90e8\u5206\u53cd\u6c47\u7f16<\/p>\n<pre lang=\"asm\" line=\"1\">6:    int sum(int a, int b)\r\n7:    {\r\n0040D7E0   push        ebp;\u4fdd\u62a4bp\r\n0040D7E1   mov         ebp,esp;\u4fdd\u62a4sp\r\n0040D7E3   sub         esp,48h;\u79fb\u52a8\u6808\u9876\u4f4d\u7f6e,\u9884\u7559\u5c40\u90e8\u53d8\u91cf\u4e13\u7528\u7a7a\u95f4\r\n0040D7E6   push        ebx\r\n0040D7E7   push        esi\r\n0040D7E8   push        edi\r\n0040D7E9   lea         edi,[ebp-48h]\r\n0040D7EC   mov         ecx,12h\r\n0040D7F1   mov         eax,0CCCCCCCCh\r\n0040D7F6   rep stos    dword ptr [edi]\r\n8:        int c = 20;\r\n0040D7F8   mov         dword ptr [ebp-4],14h;\u901a\u8fc7bp\u6bb5\u504f\u79fb\u5730\u5740\u8bbf\u95ee\u4e13\u7528\u7a7a\u95f4\uff0c\u8df3\u8fc7bp\u4ecebp-4\u5f00\u59cb\r\n9:        int d = 30;\r\n0040D7FF   mov         dword ptr [ebp-8],1Eh;\u7b2c\u4e8c\u4e2a\u5c40\u90e8\u53d8\u91cf\u9012\u589ebp-8\r\n10:       return a + b;\r\n0040D806   mov         eax,dword ptr [ebp+8]\r\n0040D809   add         eax,dword ptr [ebp+0Ch];\u51fd\u6570\u8fd4\u56de\u503c\u4fdd\u5b58\u5728ax\u5bc4\u5b58\u5668\u4e2d\r\n11:   }\r\n0040D80C   pop         edi\r\n0040D80D   pop         esi\r\n0040D80E   pop         ebx\r\n0040D80F   mov         esp,ebp;\u6062\u590dsp\r\n0040D811   pop         ebp;\u6062\u590dbp\r\n0040D812   ret;\u5916\u5e73\u6808<\/pre>\n<p><strong>8\u3001\u6c47\u7f16Demo\u4e2d\u5b9e\u73b0\u4e0eVisual C++\u53cd\u6c47\u7f16\u5f97\u5230\u7684\u7ed3\u679c\u57fa\u672c\u4e00\u81f4\uff01<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u53c2\u8003\u94fe\u63a5 1.1\u3001\u51fd\u6570\u8c03\u7528\u539f\u7406\u2013\u53c2\u6570\u7bc7 2\u3001\u51fd\u6570\u9700\u8981\u89e3\u51b3\u7684\u4e09\u5927\u95ee\u9898\uff1a\u53c2\u6570\u3001\u8fd4\u56de\u503c\u3001\u5c40\u90e8\u53d8\u91cf 2.1\u3001\u53c2\u6570\u5728\u51fd\u6570\u6267\u884c\u524d\u538b\u6808\uff0c\u6267\u884c\u7ed3\u675f\u540e\u6062\u590d\u5185\u5e73\u6808\u6216\u5916\u5e73\u6808\u7684\u65b9\u5f0f\u6062\u590d\u6808\u9876\u4f4d\u7f6e\u91ca\u653e\u7a7a\u95f4\uff1b 2.2\u3001\u8fd4\u56de\u503c\u4e00\u822c\u76f4\u63a5\u5b58\u50a8\u5728\u5bc4\u5b58\u5668ax\u4e2d\uff0c\u51fd\u6570\u8fd0\u884c\u7ed3\u675f\u540e\u5728ax\u4e2d\u8bfb\u53d6 2.3\u3001\u51fd\u6570\u5185\u90e8\u7684\u5c40\u90e8\u53d8\u91cf\u4e5f\u662f\u901a\u8fc7\u6808\u6765\u5b58\u50a8 3\u3001\u51fd\u6570\u5c40\u90e8\u53d8\u91cf\u9762\u4e34\u7684\u51e0\u4e2a\u95ee\u9898 3.1\u3001\u4e13\u7528\u7a7a\u95f4\uff0c\u4e0d\u88ab\u5176\u4ed6\u6570\u636e\u8986\u76d6\uff1b 3.2\u3001\u5bf9\u6808\u8fdb\u884c\u64cd\u4f5c\uff0c\u7ed3\u675f\u540e\u9700\u8981\u5bf9\u6808\u8fdb\u884c\u6062\u590d\u64cd\u4f5c\uff1b 3.3\u3001\u4e34\u65f6\u7a7a\u95f4\u4f7f\u7528\u7ed3\u675f\u540e\u53ca\u65f6\u91ca\u653e 4\u3001\u57fa\u672c\u5b9e\u73b0\u601d\u8def 4.1\u3001\u4fdd\u5b58\u6808\u9876\u4f4d\u7f6e(sp)\uff1b 4.2\u3001\u5c06\u6808\u9876\u4f4d\u7f6e\u5f80\u524d\u79fb\u52a8\u4e00\u6bb5\u4f4d\u7f6e\u505a\u4e3a\u5c40\u90e8\u53d8\u91cf\u4e13\u6709\u7a7a\u95f4\uff1b 4.3\u3001\u901a\u8fc7\u539f\u6808\u9876+\u504f\u79fb\u4f4d\u7f6e(bp\u5bc4\u5b58\u5668)\u6765\u8bbf\u95ee\u4e13\u7528\u7684\u4e34\u65f6\u7a7a\u95f4\uff1b 4.4\u3001\u7ed3\u675f\u540e\u6062\u590d\u539f\u6765\u6808\u9876\u4f4d\u7f6e\uff1b 4.5\u3001\u8003\u8651\u5230\u51fd\u6570\u7684\u5d4c\u5957\u8c03\u7528\uff0c\u4fdd\u62a4\u548c\u6062\u590dbp\u540c\u6837\u91cd\u8981\uff01 5.0\u3001\u6c47\u7f16\u4ee3\u7801\u5b9e\u73b0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[124],"tags":[132,121],"class_list":["post-1295","post","type-post","status-publish","format-standard","hentry","category-assembler","tag-132","tag-121"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1295"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1295\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}