{"id":116752,"date":"2022-07-14T07:21:26","date_gmt":"2022-07-13T23:21:26","guid":{"rendered":"http:\/\/www.idc.net\/help\/116752\/"},"modified":"2022-07-14T07:21:26","modified_gmt":"2022-07-13T23:21:26","slug":"asm%e5%9c%a8linux%e7%b3%bb%e7%bb%9f%e4%b8%ad%e7%9a%84%e5%ba%94%e7%94%a8%ef%bc%88asmlinux%ef%bc%89","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/116752\/","title":{"rendered":"ASM\u5728Linux\u7cfb\u7edf\u4e2d\u7684\u5e94\u7528\uff08asmlinux\uff09"},"content":{"rendered":"<p>ASM\uff08Assembly language\uff09\u662f\u673a\u5668\u8bed\u8a00\u7684\u4e00\u79cd\uff0c\u5b83\u548cC \/ C ++\u7f16\u5199\u7684\u7a0b\u5e8f\u76f8\u6bd4\uff0c\u80fd\u591f\u6709\u66f4\u597d\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u56e0\u800c\u5728Linux\u7cfb\u7edf\u4e2d\u88ab\u5927\u91cf\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p>ASM\u53ef\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u5e94\u7528\u7684\u8981\u6c42\uff0c\u4e3b\u8981\u7528\u4e8e\u7f16\u5199\u7cfb\u7edf\u5185\u6838\u548c\u9a71\u52a8\uff0c\u5f00\u53d1\u5b9e\u65f6\u7cfb\u7edf\uff0c\u6a21\u62df\u5668\uff0c\u6e38\u620f\u5f00\u53d1\uff0c\u786c\u4ef6\u9a71\u52a8\u7a0b\u5e8f\u4ee5\u53ca\u56fe\u50cf\u56fe\u5f62\u5904\u7406\u7b49\u3002<\/p>\n<\/p>\n<p>Linux\u5185\u6838\u51e0\u4e4e\u5b8c\u5168\u7531ASM\u6765\u7f16\u5199\uff0c\u56e0\u4e3a\u7cfb\u7edf\u6838\u5fc3\u4ee3\u7801\u53ea\u80fd\u4f7f\u7528\u6700\u5feb\u7684\u6c47\u7f16\u8bed\u8a00\uff0c\u800c\u865a\u62df\u673a\u548c\u6a21\u62df\u5668\u4e5f\u4f1a\u4f7f\u7528ASM\u6765\u6784\u5efa\u5b83\u4eec\u7684\u5e95\u5c42\u4ee3\u7801\uff0c\u56e0\u4e3aASM\u53ef\u4ee5\u5b9e\u73b0\u6700\u4f4e\u7ea7\u522b\u7684\u5185\u90e8\u63a7\u5236\u3002<\/p>\n<\/p>\n<p>\u5728\u6e38\u620f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0cASM\u63d0\u4f9b\u4e86\u5f88\u591a\u663e\u793a\u4f4e\u7ea7\u4ee3\u7801\uff0c\u4f7f\u6e38\u620f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u4ee5\u6700\u4f4e\u7684\u8bfb\u5199\u6210\u672c\u548c\u6700\u4f73\u7684\u6027\u80fd\u66f4\u65b0\u6e38\u620f\u7684\u56fe\u5f62\u548c\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u6bb5\u7b80\u5355\u7684ASM\u4ee3\u7801\uff0c\u5b9e\u73b0\u4e00\u4e2a\u793a\u4f8b\u51fd\u6570\uff0c\u5b83\u63a5\u53d7\u4e24\u4e2a\u6574\u6570\u53c2\u6570a\u548cb\uff0c\u5e76\u8fd4\u56dea + b\u7684\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p>\/\/declare constants<\/p>\n<p>.equ A, 0x10<\/p>\n<p>.equ B, 0x11<\/p>\n<p>\/\/declare code<\/p>\n<p>.code<\/p>\n<p> \/\/start function<\/p>\n<p> adder:<\/p>\n<p> mov eax, [A]<\/p>\n<p> add eax, [B]<\/p>\n<p> ret<\/p>\n<p> \/\/end function<\/p>\n<p>.end<\/p>\n<\/p>\n<p>\u672c\u6bb5\u4ee3\u7801\u4e2d\uff0c\u5148\u901a\u8fc7.equ\u6307\u4ee4\u5c06\u53d8\u91cf\u5b9a\u4e49\u4e3a\u5e38\u91cf\uff0c\u5373A=0x10\uff0cB=0x11\u3002\u7136\u540e\u901a\u8fc7.code\u5173\u952e\u5b57\u58f0\u660e\u51fd\u6570\u4ee3\u7801\uff0c\u63a5\u7740\u7528mov\u6307\u4ee4\u628aA\u7684\u503c\u590d\u5236\u5230eax\u5bc4\u5b58\u5668\uff0c\u7136\u540e\u7528add\u6307\u4ee4\u628aB\u7684\u503c\u6dfb\u52a0\u5230eax\u4e2d\uff0c\u6700\u540e\u8fd4\u56dea+b\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p>ASM\u5728Linux\u7cfb\u7edf\u4e2d\u7684\u5e94\u7528\u662f\u65e0\u9650\u7684\uff0c\u5b83\u7684\u6027\u80fd\u548c\u7075\u6d3b\u6027\u51e0\u4e4e\u53ef\u4ee5\u5b9e\u73b0\u4efb\u4f55\u529f\u80fd\u3002\u6bd4\u8d77\u5176\u4ed6\u8bed\u8a00\uff0c\u5b83\u5177\u6709\u8f83\u5feb\u7684\u8fd0\u884c\u901f\u5ea6\uff0c\u8f83\u9ad8\u7684\u5b89\u5168\u6027\u4ee5\u53ca\u6700\u4f4e\u7684\u8d44\u6e90\u6d88\u8017\uff0c\u5b83\u4e5f\u53ef\u4ee5\u65b9\u4fbf\u7528\u6237\u672c\u5730\u8c03\u8bd5\u4ee5\u53ca\u5206\u6790\u9519\u8bef\u3002\u719f\u7ec3\u638c\u63e1ASM\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u5f00\u53d1Linux\u7cfb\u7edf\u4e0a\u7684\u5927\u91cf\u4f18\u79c0\u8f6f\u4ef6\u3002<\/p>\n<p><a href=\"http:https:\/\/idc.net\/\">\u9999\u6e2f\u670d\u52a1\u5668<\/a>\u9996\u9009\u540e\u6d6a\u4e91\uff0c2H2G\u9996\u670810\u5143\u5f00\u901a\u3002<br \/>\u540e\u6d6a\u4e91\uff08www.IDC.Net\uff09\u63d0\u4f9b\u7b80\u5355\u597d\u7528\uff0c\u4ef7\u683c\u539a\u9053\u7684\u9999\u6e2f\/\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\u548c\u72ec\u7acb\u670d\u52a1\u5668\u3002IDC+ISP+ICP\u8d44\u8d28\u3002ARIN\u548cAPNIC\u4f1a\u5458\u3002\u6210\u719f\u6280\u672f\u56e2\u961f15\u5e74\u884c\u4e1a\u7ecf\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ASM\uff08Assembly language\uff09\u662f\u673a\u5668\u8bed\u8a00\u7684\u4e00\u79cd\uff0c\u5b83\u548cC \/ C ++\u7f16\u5199\u7684\u7a0b\u5e8f\u76f8\u6bd4\uff0c\u80fd\u591f\u6709\u66f4\u597d\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-116752","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/116752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=116752"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/116752\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=116752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=116752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=116752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}