{"id":21670,"date":"2024-11-19T10:10:27","date_gmt":"2024-11-19T02:10:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21670\/"},"modified":"2024-11-19T10:10:27","modified_gmt":"2024-11-19T02:10:27","slug":"vscode%e6%80%8e%e4%b9%88%e8%bf%90%e8%a1%8c%e6%b1%87%e7%bc%96%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21670\/","title":{"rendered":"vscode\u600e\u4e48\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801"},"content":{"rendered":"<blockquote><p>\n  \u5728 vscode \u4e2d\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\u9700\u8981\uff1a\u5b89\u88c5 gas \u6c47\u7f16\u5668\u3002\u5b89\u88c5 vscode\u3002\u5b89\u88c5 c\/c++ \u6269\u5c55\u3002\u521b\u5efa .s \u6269\u5c55\u540d\u6587\u4ef6\u3002\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u4f7f\u7528 as \u547d\u4ee4\u7f16\u8bd1\u4ee3\u7801\u3002\u4f7f\u7528 ld \u547d\u4ee4\u94fe\u63a5\u4ee3\u7801\u3002\u4f7f\u7528 .\/ \u547d\u4ee4\u8fd0\u884c\u4ee3\u7801\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/30\/2024063021415478536.jpg\" class=\"aligncenter\" title=\"vscode\u600e\u4e48\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\u63d2\u56fe\" alt=\"vscode\u600e\u4e48\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 VSCode \u4e2d\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801<\/strong><\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u5b89\u88c5 GAS\uff08GNU \u6c47\u7f16\u5668\uff09<\/strong><\/p>\n<p>\u5728\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e2d\uff0cGAS \u90fd\u5df2\u7ecf\u9884\u88c5\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8bf7\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5b83\u3002<\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u5b89\u88c5 Visual Studio Code (VSCode)<\/strong><\/p>\n<p>\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5 VSCode\uff0c\u8fd9\u662f\u4e00\u6b3e\u514d\u8d39\u4e14\u5f00\u6e90\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u3002<\/p>\n<p><strong>\u6b65\u9aa4 3\uff1a\u5b89\u88c5 C\/C++ \u6269\u5c55<\/strong><\/p>\n<p>\u5728 VSCode \u4e2d\uff0c\u8f6c\u5230\u201c\u6269\u5c55\u201d\u9009\u9879\u5361\u5e76\u641c\u7d22\u201cC\/C++\u201d\u3002\u5b89\u88c5\u8be5\u6269\u5c55\u4ee5\u83b7\u5f97\u5bf9\u6c47\u7f16\u7684\u652f\u6301\u3002<\/p>\n<p><strong>\u6b65\u9aa4 4\uff1a\u521b\u5efa\u6c47\u7f16\u6587\u4ef6<\/strong><\/p>\n<p>\u5728 VSCode \u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\u5e76\u4ee5 .s \u6269\u5c55\u540d\u4fdd\u5b58\u5b83\u3002\u4f8b\u5982\uff0chello.s\u3002<\/p>\n<p><strong>\u6b65\u9aa4 5\uff1a\u7f16\u5199\u6c47\u7f16\u4ee3\u7801<\/strong><\/p>\n<p>\u5728 .s \u6587\u4ef6\u4e2d\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>.global _start\n_start:\n    mov     $1, %rax\n    mov     $0, %rdi\n    mov     $1, %rsi\n    mov     $4, %rdx\n    syscall\n    mov     $60, %rax\n    syscall<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 6\uff1a\u7f16\u8bd1\u6c47\u7f16\u4ee3\u7801<\/strong><\/p>\n<p>\u5728 VSCode \u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\uff1a<\/p>\n<pre>as -o hello.o hello.s<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 7\uff1a\u94fe\u63a5\u6c47\u7f16\u4ee3\u7801<\/strong><\/p>\n<p>\u5c06\u6c47\u7f16\u4ee3\u7801\u94fe\u63a5\u5230\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n<pre>ld -o hello hello.o<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 8\uff1a\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801<\/strong><\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\uff1a<\/p>\n<pre>.\/hello<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u6b65\u9aa4\u5c06\u6253\u5370\u201cHello, world!\u201d\u5230\u7ec8\u7aef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 vscode \u4e2d\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801\u9700\u8981\uff1a\u5b89\u88c5 gas \u6c47\u7f16\u5668\u3002\u5b89\u88c5 vscode\u3002\u5b89\u88c5 c\/c++ \u6269\u5c55\u3002\u521b\u5efa .s \u6269\u5c55\u540d\u6587\u4ef6\u3002\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u4f7f\u7528 as \u547d\u4ee4\u7f16\u8bd1\u4ee3\u7801\u3002\u4f7f\u7528 ld \u547d\u4ee4\u94fe\u63a5\u4ee3\u7801\u3002\u4f7f\u7528 .\/ \u547d\u4ee4\u8fd0\u884c\u4ee3\u7801\u3002 \u5982\u4f55\u5728 VSCode \u4e2d\u8fd0\u884c\u6c47\u7f16\u4ee3\u7801 \u6b65\u9aa4 1\uff1a\u5b89\u88c5 GAS\uff08GNU \u6c47\u7f16\u5668\uff09 \u5728\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e2d\uff0cGAS \u90fd\u5df2\u7ecf\u9884\u88c5\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8bf7\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5b83\u3002 \u6b65\u9aa4 2\uff1a\u5b89\u88c5 Visual Studio Code (VSCode) \u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5 VSCode\uff0c\u8fd9\u662f\u4e00\u6b3e\u514d\u8d39\u4e14\u5f00\u6e90\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u3002 \u6b65\u9aa4 3\uff1a\u5b89\u88c5 C\/C++ \u6269\u5c55 \u5728 VSCode \u4e2d\uff0c\u8f6c\u5230\u201c\u6269\u5c55\u201d\u9009\u9879\u5361\u5e76\u641c\u7d22\u201cC\/C++\u201d\u3002\u5b89\u88c5\u8be5\u6269\u5c55\u4ee5\u83b7\u5f97\u5bf9\u6c47\u7f16\u7684\u652f\u6301\u3002 \u6b65\u9aa4 4\uff1a\u521b\u5efa\u6c47\u7f16\u6587\u4ef6 \u5728 VSCode \u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\u5e76\u4ee5 .s \u6269\u5c55\u540d\u4fdd\u5b58\u5b83\u3002\u4f8b\u5982\uff0chello.s\u3002 \u6b65\u9aa4 5\uff1a\u7f16\u5199\u6c47\u7f16\u4ee3\u7801 \u5728 .s \u6587\u4ef6\u4e2d\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u4f8b\u5982\uff1a .global [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21670","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21670"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21670\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}