{"id":227,"date":"2022-07-20T16:17:19","date_gmt":"2022-07-20T08:17:19","guid":{"rendered":"http:\/\/150.158.163.220\/?p=227"},"modified":"2022-12-20T11:33:05","modified_gmt":"2022-12-20T03:33:05","slug":"%e6%9d%a5%e5%ad%a6%e5%ad%a6arm%e6%b1%87%e7%bc%96-%e5%9f%ba%e6%9c%ac%e7%9f%a5%e8%af%86%e4%b8%8b","status":"publish","type":"post","link":"https:\/\/zhewana.cn\/?p=227","title":{"rendered":"\u6765\u5b66\u5b66ARM\u6c47\u7f16&#8212;-\u57fa\u672c\u77e5\u8bc6(\u4e0b)"},"content":{"rendered":"<p>\u4e66\u63a5\u4e0a\u7bc7\uff1a<a href=\"https:\/\/zhewana.cn\/archives\/389\/\">\u6765\u5b66\u5b66ARM\u6c47\u7f16----\u57fa\u672c\u77e5\u8bc6(\u4e0a)<\/a><\/p>\n<p>\u901a\u8fc7\u4e4b\u524d\u7684\u5b66\u4e60\uff0c\u7b14\u8005\u5df2\u7ecf\u5bf9\u4e8eArmv7-M\u4f53\u7cfb\u67b6\u6784\u6709\u4e86\u4e00\u4e9b\u5927\u81f4\u7684\u4e86\u89e3\uff0c\u63a5\u4e0b\u6765\u5c31\u5f00\u59cb\u771f\u6b63\u7684Arm\u6c47\u7f16\u7684\u6307\u4ee4\u7684\u5b66\u4e60\u4e86\u3002<\/p>\n<p>\u8fd8\u662f\u90a3\u53e5\u8bdd\uff0c<strong>\u5f00\u53d1\u8005\u7684\u5b66\u4e60\u5e94\u8be5\u8ffd\u6839\u6eaf\u6e90<\/strong>\uff0c\u6545\u8fd9\u90e8\u5206\u5185\u5bb9\u7684\u5b66\u4e60\u662f\u57fa\u4e8eArm\u7f16\u8bd1\u5668armasm\u7528\u6237\u624b\u518c\u8fdb\u884c\u7684\u3002<\/p>\n<h2>\u6e90\u4ee3\u7801\u884c\u8bed\u6cd5<\/h2>\n<p>\u6bcf\u884c\u6c47\u7f16\u4ee3\u7801\u90fd\u5177\u6709\u5982\u4e0b\u7684\u4e00\u822c\u683c\u5f0f\uff1a<\/p>\n<p><code>{symbol} {instruction|directive|pseudo-instruction} {;comment}<\/code><\/p>\n<p>\u6bcf\u884c\u4ee3\u7801\u4e2d\uff0c\u4ee5\u4e0a\u4e09\u4e2a\u90e8\u5206\u90fd\u662f\u53ef\u9009\u7684\u3002<\/p>\n<p><strong>symbol<\/strong>\u901a\u5e38\u662f\u4e00\u4e2a\u6807\u7b7e\uff0c\u5728<strong>instruction<\/strong>\u548c<strong>pseudo-instruction<\/strong>\u4e2d\uff0c\u5b83\u59cb\u7ec8\u662f\u4e00\u4e2a\u6807\u7b7e\u3002\u5728\u67d0\u4e9b<strong>directive<\/strong>\u4e2d\uff0c\u5b83\u662f\u53d8\u91cf\u6216\u8005\u5e38\u6570\u7684\u7b26\u53f7\u3002\u5728\u4efb\u4f55\u60c5\u51b5\u4e0b\uff0c\u5bf9<strong>directive<\/strong>\u7684\u63cf\u8ff0\u90fd\u4f1a\u6e05\u695a\u7684\u8bf4\u660e\u8fd9\u4e00\u70b9\u3002<\/p>\n<p><strong>symbol<\/strong>\u5fc5\u987b\u4ece\u9996\u5217\u5f00\u59cb\uff0c\u5176\u4e2d<strong>\u4e0d\u53ef\u4ee5\u5305\u542b\u4efb\u4f55\u7a7a\u683c\u6216\u8005\u5236\u8868\u7b26<\/strong>\uff0c\u9664\u975e\u5b83\u7531\u6761\u5f62\u7b26\u53f7\uff08|\uff09\u5305\u56f4\u3002<\/p>\n<p>\u6807\u7b7e\u662f\u5730\u5740\u7684\u7b26\u53f7\u8868\u793a\u3002\u53ef\u4ee5\u4f7f\u7528\u6807\u7b7e\u6765\u6807\u8bb0\u8981\u4ece\u4ee3\u7801\u7684\u5176\u4ed6\u90e8\u5206\u5f15\u7528\u7684\u7279\u5b9a\u5730\u5740\u3002\u6570\u5b57\u672c\u5730\u6807\u7b7e\u662f\u4ee50-99\u8303\u56f4\u5185\u7684\u6570\u5b57\u5f00\u5934\u7684\u6807\u7b7e\u7684\u5b50\u7c7b\u3002\u4e0e\u5176\u4ed6\u6807\u7b7e\u4e0d\u540c\uff0c\u53ef\u4ee5\u591a\u6b21\u5b9a\u4e49\u6570\u503c\u672c\u5730\u6807\u7b7e\u3002\u8fd9\u4f7f\u5f97\u5b83\u4eec\u5728\u4f7f\u7528\u5b8f\u751f\u6210\u6807\u7b7e\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p>\u6307\u4ee4\u5411\u6c47\u7f16\u7a0b\u5e8f\u63d0\u4f9b\u5f71\u54cd\u6c47\u7f16\u8fc7\u7a0b\u6216\u5f71\u54cd\u6700\u7ec8\u8f93\u51fa\u56fe\u50cf\u7684\u91cd\u8981\u4fe1\u606f\u3002<\/p>\n<p>\u6307\u4ee4\u548c\u4f2a\u6307\u4ee4\u6784\u6210\u5904\u7406\u5668\u7528\u4e8e\u6267\u884c\u4efb\u52a1\u7684\u4ee3\u7801\u3002<\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1a<\/p>\n<p><strong>instruction<\/strong>\u3001<strong>directive<\/strong>\u548c<strong>pseudo-instruction<\/strong>\u524d\u9762\u5fc5\u987b\u6709\u7a7a\u683c\uff0c\u4f8b\u5982\u7a7a\u683c\u6216\u5236\u8868\u7b26\uff0c\u4e0d\u7ba1\u524d\u9762\u662f\u5426\u6709\u6807\u7b7e\u3002<\/p>\n<p>\u6709\u4e9b<strong>directive<\/strong>\u4e0d\u5141\u8bb8\u4f7f\u7528\u6807\u7b7e\u3002<\/p>\n<\/blockquote>\n<p>\u6ce8\u91ca\u662f\u6e90\u4ee3\u7801\u884c\u7684\u6700\u540e\u4e00\u90e8\u5206\u3002\u884c\u4e0a\u7684<strong>\u7b2c\u4e00\u4e2a\u5206\u53f7<\/strong>\u6807\u8bb0\u6ce8\u91ca\u7684\u5f00\u5934\uff0c\u9664\u975e\u5206\u53f7\u51fa\u73b0\u5728\u5b57\u7b26\u4e32\u6587\u5b57\u4e2d\u3002\u884c\u7684\u672b\u5c3e\u662f\u6ce8\u91ca\u7684\u7ed3\u5c3e\u3002\u6ce8\u91ca\u672c\u8eab\u5c31\u662f\u6709\u6548\u7684\u4e00\u884c\u3002\u6c47\u7f16\u7a0b\u5e8f\u5ffd\u7565\u6240\u6709\u6ce8\u91ca\u3002<\/p>\n<blockquote>\n<p>\u7b14\u8005\u6ce8\uff1a<\/p>\n<p>\u4ee5\u4e0a\u5185\u5bb9\u4e2d\uff0c<strong>instruction<\/strong>\u548c<strong>directive<\/strong>\u5747\u53ef\u88ab\u7ffb\u8bd1\u4e3a\u6307\u4ee4\uff0c\u4f46\u662f\u4e24\u79cd\u6307\u4ee4\u5b58\u5728\u4e0d\u540c\u4e4b\u5904\uff1a<\/p>\n<p><strong>instruction<\/strong>\uff1a\u6307\u4ee4\uff0c\u662f\u5904\u7406\u5668\u76f4\u63a5\u6267\u884c\u7684\u6307\u4ee4\uff0c\u8be5\u79cd\u6307\u4ee4\u4f1a\u76f4\u63a5\u88ab\u6c47\u7f16\u4e3a\u673a\u5668\u7801\u5e76\u94fe\u63a5\u8fdb\u5165\u6700\u7ec8\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n<p><strong>directive<\/strong>\uff1a\u4f2a\u6307\u4ee4\uff0c\u662f\u5bf9\u7f16\u8bd1\u5668\u7684\u6307\u4ee4\uff0c\u4ee5\u544a\u8bc9\u7f16\u8bd1\u5668\u5e94\u8be5\u5982\u4f55\u5904\u7406\u5f85\u6c47\u7f16\u6570\u636e\u3002\u8be5\u79cd\u6307\u4ee4\u4ec5\u5728\u6c47\u7f16\u65f6\u4f7f\u7528\uff0c\u4ed6\u4eec\u53ef\u80fd\u4f1a\u5f71\u54cd\u4ee3\u7801\u7684\u751f\u6210\u65b9\u5f0f\uff0c\u4f46\u662f\u4ed6\u4eec\u672c\u8eab\u4e0d\u4f1a\u5bfc\u81f4\u4efb\u4f55\u4ee3\u7801\u751f\u6210\u3002<\/p>\n<p>\u53c2\u8003\u81ea\uff1a<a href=\"https:\/\/www.quora.com\/What-is-the-difference-between-an-instruction-and-a-directive-in-assembly-language\">Quroa - What is the difference between an instruction and a directive in assembly language?<\/a><\/p>\n<\/blockquote>\n<p>\u6b64\u5916\uff0c\u7f16\u5199\u6307\u4ee4\u65f6\u8981\u4e48\u5168\u90e8\u91c7\u7528\u5927\u5199\uff0c\u8981\u4e48\u5168\u90e8\u91c7\u7528\u5c0f\u5199\uff0c<strong>\u4e0d\u53ef\u4ee5\u5927\u5c0f\u5199\u6df7\u7528<\/strong>\u3002\u5f53\u7136\uff0c\u6807\u7b7e\u4e2d\u53ef\u4ee5\u968f\u610f\u4f7f\u7528\u5927\u5c0f\u5199\u3002<\/p>\n<p>\u4e3a\u4e86\u4f7f\u6e90\u6587\u4ef6\u66f4\u6613\u4e8e\u9605\u8bfb\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u884c\u7684\u672b\u5c3e\u653e\u7f6e<strong>\u53cd\u659c\u6760\uff08\\\uff09<\/strong>\u5c06\u4e00\u957f\u884c\u6e90\u4ee3\u7801\u62c6\u5206\u4e3a\u51e0\u884c\u3002\u53cd\u659c\u6760\u540e\u9762\u4e0d\u80fd\u8ddf\u4efb\u4f55\u5176\u4ed6\u5b57\u7b26\uff0c\u5305\u62ec\u7a7a\u683c\u548c\u5236\u8868\u7b26\u3002\u6c47\u7f16\u5668\u5c06\u53cd\u659c\u6760\u540e\u8ddf\u884c\u5c3e\u5e8f\u5217\u89c6\u4e3a\u7a7a\u767d\u3002\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7a7a\u884c\u6765\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1a<\/p>\n<p>\u5728\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\u4e2d\uff0c\u4e0d\u8981\u4f7f\u7528\u53cd\u659c\u6760\u540e\u8ddf\u884c\u5c3e\u5e8f\u5217\u3002<\/p>\n<\/blockquote>\n<p>\u884c\u7684\u957f\u5ea6\u9650\u5236\uff08\u5305\u62ec\u4f7f\u7528\u53cd\u659c\u6760\u7684\u4efb\u4f55\u6269\u5c55\u540d\uff09\u4e3a4095\u4e2a\u5b57\u7b26\u3002<\/p>\n<h2>\u6307\u4ee4\u683c\u5f0f<\/h2>\n<p>\u90e8\u5206\u6c47\u7f16\u6307\u4ee4\u5177\u6709\u4ee5\u4e0b\u7684\u8bed\u6cd5\u683c\u5f0f\uff1a<\/p>\n<p><code>Operation{s}{cond} Rd Rn,Operand2<\/code><\/p>\n<p>\u4ee5\u6b64\u4e3a\u4f8b\u89e3\u91ca\u4e0b\u8bed\u6cd5\u7684\u6307\u4ee4\u683c\u5f0f\uff1a<\/p>\n<ul>\n<li>Operation\uff1a\u64cd\u4f5c\u6307\u4ee4<\/li>\n<li>cond\uff1a\u6761\u4ef6<\/li>\n<li>s\uff1a\u72b6\u6001\u7801<\/li>\n<li>Rd\uff1a\u76ee\u6807\u5bc4\u5b58\u5668<\/li>\n<li>Rn\uff1a\u6e90\u5bc4\u5b58\u5668<\/li>\n<li>Operand2\uff1a\u9644\u52a0\u64cd\u4f5c<\/li>\n<\/ul>\n<h3>{s}\u72b6\u6001\u540e\u7f00<\/h3>\n<p>\u72b6\u6001\u540e\u7f00\u662f\u53ef\u9009\u7684\u540e\u7f00\uff0c\u6307\u4ee4\u5c06\u6839\u636e\u662f\u5426\u6709\u72b6\u6001\u540e\u7f00\u4ee5\u53ca\u64cd\u4f5c\u7ed3\u679c\u6765\u66f4\u65b0\u6761\u4ef6\u6807\u5fd7\u4f4d\uff08N\u6807\u3001Z\u6807\u3001C\u6807\u3001V\u6807\uff09<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\n\nADD R1,R2,#4    ;\u5c06R2\u52a04\u540e\u5b58\u5728R1\u5bc4\u5b58\u5668\u5185\uff0c\u4e0d\u66f4\u65b0flag\u6807\u5fd7\n;------\nADDS R1,R2,#4   ;\u5c06R2\u52a04\u540e\u5b58\u5728R1\u5bc4\u5b58\u5668\u5185\uff0c\u5e76\u66f4\u65b0flag\u6807\u5fd7<\/code><\/pre>\n<h3>{cond}\u6761\u4ef6\u540e\u7f00<\/h3>\n<p>\u6761\u4ef6\u540e\u7f00\u662f\u53ef\u9009\u7684\u540e\u7f00\uff0c\u8868\u793a\u6267\u884c\u6307\u4ee4\u6240\u5fc5\u9700\u7684\u6761\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u7684\u540e\u7f00\u53ca\u5176\u5bf9\u5e94\u7684\u6807\u5fd7\u4f4d\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u540e\u7f00<\/th>\n<th style=\"text-align: center;\">\u6807\u5fd7\u4f4d<\/th>\n<th style=\"text-align: center;\">\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">EQ<\/td>\n<td style=\"text-align: center;\">Z\u6807\u7f6e\u4f4d<\/td>\n<td style=\"text-align: center;\">\u76f8\u7b49<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">NE<\/td>\n<td style=\"text-align: center;\">Z\u6807\u590d\u4f4d<\/td>\n<td style=\"text-align: center;\">\u4e0d\u76f8\u7b49<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">CS\/HS<\/td>\n<td style=\"text-align: center;\">C\u6807\u7f6e\u4f4d<\/td>\n<td style=\"text-align: center;\">\u65e0\u7b26\u53f7\u5927\u4e8e\u7b49\u4e8e\uff08&gt;=\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">CC\/LO<\/td>\n<td style=\"text-align: center;\">C\u6807\u590d\u4f4d<\/td>\n<td style=\"text-align: center;\">\u65e0\u7b26\u53f7\u5c0f\u4e8e\uff08&lt;\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MI<\/td>\n<td style=\"text-align: center;\">N\u6807\u7f6e\u4f4d<\/td>\n<td style=\"text-align: center;\">\u8d1f<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">PL<\/td>\n<td style=\"text-align: center;\">N\u6807\u590d\u4f4d<\/td>\n<td style=\"text-align: center;\">\u6b63\u6216\u96f6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">VS<\/td>\n<td style=\"text-align: center;\">V\u6807\u7f6e\u4f4d<\/td>\n<td style=\"text-align: center;\">\u6709\u6ea2\u51fa<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">VC<\/td>\n<td style=\"text-align: center;\">V\u6807\u590d\u4f4d<\/td>\n<td style=\"text-align: center;\">\u65e0\u6ea2\u51fa<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">HI<\/td>\n<td style=\"text-align: center;\">C\u6807\u7f6e\u4f4d\u4e14Z\u6807\u590d\u4f4d<\/td>\n<td style=\"text-align: center;\">\u65e0\u7b26\u53f7\u5927\u4e8e\uff08&gt;\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">LS<\/td>\n<td style=\"text-align: center;\">C\u6807\u590d\u4f4d\u6216Z\u6807\u7f6e\u4f4d<\/td>\n<td style=\"text-align: center;\">\u65e0\u7b26\u53f7\u5c0f\u4e8e\u6216\u7b49\u4e8e\uff08&lt;=\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">GE<\/td>\n<td style=\"text-align: center;\">N\u6807\u4e0eV\u6807\u72b6\u6001\u76f8\u540c<\/td>\n<td style=\"text-align: center;\">\u6709\u7b26\u53f7\u6570\u5927\u4e8e\u7b49\u4e8e\uff08&gt;=\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">LT<\/td>\n<td style=\"text-align: center;\">N\u6807\u4e0eV\u6807\u72b6\u6001\u4e0d\u540c<\/td>\n<td style=\"text-align: center;\">\u6709\u7b26\u53f7\u6570\u5c0f\u4e8e\uff08&lt;\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">GT<\/td>\n<td style=\"text-align: center;\">Z\u6807\u590d\u4f4d\uff0cN\u6807\u4e0eV\u6807\u72b6\u6001\u76f8\u540c<\/td>\n<td style=\"text-align: center;\">\u6709\u7b26\u53f7\u6570\u5927\u4e8e\uff08&gt;\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">LE<\/td>\n<td style=\"text-align: center;\">Z\u6807\u7f6e\u4f4d\uff0cN\u6807\u4e0eV\u6807\u72b6\u6001\u4e0d\u540c<\/td>\n<td style=\"text-align: center;\">\u6709\u7b26\u53f7\u6570\u5c0f\u4e8e\u7b49\u4e8e\uff08&lt;=\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">AL<\/td>\n<td style=\"text-align: center;\">\u4efb\u610f\u6807\u5fd7<\/td>\n<td style=\"text-align: center;\">\u6b63\u5e38\u6267\u884c\u6307\u4ee4\uff1b\u8be5\u540e\u7f00\u5e38\u7701\u7565<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\n\nCMP R1,R2       ;\u6bd4\u8f83R1\u5bc4\u5b58\u5668\u4e0eR2\u5bc4\u5b58\u5668\u7684\u503c\nADDEQ R1,R2,#4  ;\u5982\u679c\u4e0a\u6b65\u6bd4\u8f83\u7ed3\u679c\u76f8\u7b49\uff1a\u5c06R2\u52a04\u540e\u5b58\u5728R1\u5bc4\u5b58\u5668\u5185\uff0c\u4e0d\u66f4\u65b0flag\u6807\u5fd7\uff1b\u5426\u5219\u4e0d\u6267\u884c\u8be5\u53e5\u6307\u4ee4<\/code><\/pre>\n<h2>\u5bfb\u5740\u65b9\u5f0f<\/h2>\n<p>Arm\u6c47\u7f16\u5177\u6709\u4ee5\u4e0b\u51e0\u79cd\u5bfb\u5740\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\n<p>\u7acb\u5373\u6570\u5bfb\u5740\uff1a<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nADD R0,R0,#0x3f  ;\u5c06R0\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u52a0\u4e0a0x3F\u540e\u5b58\u5165R0\u5bc4\u5b58\u5668<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5bc4\u5b58\u5668\u5bfb\u5740\uff1a<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nADD R0,R1,R2    ;\u5c06R1\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u52a0\u4e0aR2\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u7136\u540e\u5b58\u5165R0\u5bc4\u5b58\u5668\u4e2d<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5bc4\u5b58\u5668\u95f4\u63a5\u5bfb\u5740<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nLDR R0,[R1]    ;\u5c06R1\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5b58\u5730\u5740\u503c\u5904\u7684\u503c\u52a0\u8f7d\u5230R0\u5bc4\u5b58\u5668\u4e2d<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5bc4\u5b58\u5668\u79fb\u4f4d\u5bfb\u5740<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nADD R3,R2,R1,LSL #2    ;\u5c06R1\u4e2d\u7684\u503c\u5de6\u79fb\u4e24\u4f4d\u540e\u52a0\u4e0aR2\u7136\u540e\u5b58\u5165R3\u5bc4\u5b58\u5668\u4e2d<\/code><\/pre>\n<\/li>\n<li>\n<p>\u57fa\u5740\u5730\u5740\u5bfb\u5740<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nLDR R0,[R1,#4]    ;\u5c06R1\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5b58\u5730\u5740\u503c+4\u5904\u7684\u503c\u52a0\u8f7d\u5230R0\u5bc4\u5b58\u5668\u4e2d<\/code><\/pre>\n<\/li>\n<li>\n<p>\u591a\u5bc4\u5b58\u5668\u5bfb\u5740<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nLDMIA R0,{R1,R2,R3,R4}    ;<\/code><\/pre>\n<\/li>\n<li>\n<p>\u76f8\u5bf9\u5bfb\u5740<\/p>\n<pre><code class=\"language-assembly\">;\u4f8b\u5982\uff1a\nBL START    ;\u8df3\u8f6c\u5230Start\u6807\u7b7e\u5904<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>\u5e38\u7528\u6307\u4ee4<\/h2>\n<blockquote>\n<p>\u7b14\u8005\u6ce8\uff1a<\/p>\n<p>\u5177\u4f53\u7684\u6307\u4ee4\u8bed\u6cd5\u67e5\u8be2\u8bf7\u53c2\u8003\uff1a<a href=\"https:\/\/developer.arm.com\/documentation\/dui0801\/g\/\">ARM Compiler armasm User Guide<\/a><\/p>\n<\/blockquote>\n<p>Arm\u6c47\u7f16\u4e2d\u5e38\u7528\u7684\u6307\u4ee4\u5982\u4e0b\uff1a<\/p>\n<h3>\u5bc4\u5b58\u5668\u64cd\u4f5c\u6307\u4ee4<\/h3>\n<h4>\u6570\u5b66\u64cd\u4f5c\u6307\u4ee4<\/h4>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<th style=\"text-align: center;\">\u8868\u8fbe\u5f0f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">ADC<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u5e26\u8fdb\u4f4d\u7684\u52a0\u6cd5\u8fd0\u7b97<\/td>\n<td style=\"text-align: center;\">Rd=Rn+Op2+C<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><strong>ADD<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd,Rn,Op2<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>\u52a0\u6cd5\u8fd0\u7b97<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd=Rn+Op2<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><strong>MOV<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd,Op2<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>\u6570\u636e\u4f20\u9001<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd=Op2<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MVN<\/td>\n<td style=\"text-align: center;\">Rd,Op2<\/td>\n<td style=\"text-align: center;\">\u6570\u636e\u53d6\u53cd\u4f20\u9001<\/td>\n<td style=\"text-align: center;\">Rd=~Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">RSB<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u7ffb\u8f6c\u51cf\u6cd5\u8fd0\u7b97<\/td>\n<td style=\"text-align: center;\">Rd=Op2-Rn<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">RSC<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u5e26\u8fdb\u4f4d\u7684\u7ffb\u8f6c\u51cf\u6cd5<\/td>\n<td style=\"text-align: center;\">Rd=Op2-Rn-!C<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">SBC<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u5e26\u8fdb\u4f4d\u7684\u51cf\u6cd5\u8fd0\u7b97<\/td>\n<td style=\"text-align: center;\">Rd=Rn-Op2-!C<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><strong>SUB<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd,Rn,Op2<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>\u51cf\u6cd5\u8fd0\u7b97<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd=Rn-Op2<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><strong>MUL<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Rd,Rm,Rs<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>32\u4f4d\u4e58\u6cd5<\/strong><\/td>\n<td style=\"text-align: center;\">*<em>Rd=Rm<\/em>Rs**<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MLA<\/td>\n<td style=\"text-align: center;\">Rd,Rm,Rs,Rn<\/td>\n<td style=\"text-align: center;\">32\u4f4d\u7d2f\u52a0\u4e58\u6cd5<\/td>\n<td style=\"text-align: center;\">Rd=Rm*Rs+Rn<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u903b\u8f91\u8fd0\u7b97\u6307\u4ee4<\/h4>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<th style=\"text-align: center;\">\u8868\u8fbe\u5f0f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">AND<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6309\u4f4d\u903b\u8f91\u4e0e<\/td>\n<td style=\"text-align: center;\">Rd=Rn&amp;Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">BIC<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u4f4d\u6e05\u96f6<\/td>\n<td style=\"text-align: center;\">Rd=Rn&amp;~Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">EOR<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6309\u4f4d\u903b\u8f91\u5f02\u6216<\/td>\n<td style=\"text-align: center;\">Rd=Rn^Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">ORR<\/td>\n<td style=\"text-align: center;\">Rd,Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6309\u4f4d\u903b\u8f91\u6216<\/td>\n<td style=\"text-align: center;\">Rd=Rn\u6309\u4f4d\u6216Op2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u6bd4\u8f83\u64cd\u4f5c\u6307\u4ee4<\/h4>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<th style=\"text-align: center;\">\u8868\u8fbe\u5f0f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">CMP<\/td>\n<td style=\"text-align: center;\">Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6bd4\u8f83<\/td>\n<td style=\"text-align: center;\">Rn-Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">CMN<\/td>\n<td style=\"text-align: center;\">Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u8d1f\u6570\u6bd4\u8f83<\/td>\n<td style=\"text-align: center;\">Rn-\uff08-Op2\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">TEQ<\/td>\n<td style=\"text-align: center;\">Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6d4b\u8bd5\u76f8\u7b49<\/td>\n<td style=\"text-align: center;\">Rn^Op2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">TST<\/td>\n<td style=\"text-align: center;\">Rn,Op2<\/td>\n<td style=\"text-align: center;\">\u6d4b\u8bd5<\/td>\n<td style=\"text-align: center;\">Rn&amp;Op2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5185\u5b58\u64cd\u4f5c\u6307\u4ee4<\/h3>\n<h4>\u5355\u5bc4\u5b58\u5668\u64cd\u4f5c\u6307\u4ee4<\/h4>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">LDR<\/td>\n<td style=\"text-align: center;\">Rn,Addr<\/td>\n<td style=\"text-align: center;\">\u6309\u7167\u5b57\u957f\u4ece\u5185\u5b58\u8bfb\u53d6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">STR<\/td>\n<td style=\"text-align: center;\">Rn,Addr<\/td>\n<td style=\"text-align: center;\">\u6309\u7167\u5b57\u957f\u5b58\u50a8\u5230\u5185\u5b58\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">SWP<\/td>\n<td style=\"text-align: center;\">Rt, Rt2, [Rn]<\/td>\n<td style=\"text-align: center;\">\u5185\u5b58\u503c\u5b58\u5165Rt\uff0cRt2\u503c\u5b58\u5165\u5185\u5b58\uff08\u82e5Rt=Rt2\u5219\u4e3a\u4ea4\u6362<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>\u7b14\u8005\u6ce8\uff1a<\/p>\n<p>LDR\u6307\u4ee4\u5728\u624b\u518c\u4e2d\u7684\u8bed\u6cd5\u5982\u4e0b<strong>\uff08STR\u540c\u7406\uff0c\u7565\uff09<\/strong>\uff1a<\/p>\n<p><code>LDR{type}{cond}{.W} Rt, label<\/code><\/p>\n<p>\u5176\u4e2dtype\u8868\u793a\u5b58\u53d6\u7684\u957f\u5ea6\u7c7b\u578b\uff0c\u53ef\u9009\u503c\u6709\uff1a<\/p>\n<p>B(usigned byte)\u3001SB(signed byte)\u3001H(unsigned half word)\u3001SH(signed half word)\u3001-\uff08\u8868\u793a\u7701\u7565\uff09<\/p>\n<\/blockquote>\n<h5>\u793a\u4f8b\u4ee3\u7801\uff1a<\/h5>\n<pre><code class=\"language-assembly\">;\u4ee3\u7801\u6bb51\uff1a\u8bfb\u53d60x20000000\u5904\u7684\u4e00\u4e2a\u5b57\u5230R0\u5bc4\u5b58\u5668\u4e2d\nMOV R1,#0x20000000\nLDR R0,[R1]\n\n;\u4ee3\u7801\u6bb52\uff1a\u8bfb\u53d60x20000000\u5904\u7684\u534a\u5b57\u5230R0\u5bc4\u5b58\u5668\u4e2d\nMOV R1,#0x20000000\nLDRH R0,[R1]\n\n;\u4ee3\u7801\u6bb53\uff1a\u8bfb\u53d60x20000000\u5904\u7684\u4e00\u4e2a\u5b57\u8282\u5230R0\u5bc4\u5b58\u5668\u4e2d\nMOV R1,#0x20000000\nLDRB R0,[R1]<\/code><\/pre>\n<p>\u5f53\u5185\u5b58\u4e2d\u7684\u503c\u5982\u4e0b\u65f6\uff1a<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/07\/2233594007.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/07\/2233594007.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"image-20220706174614027.png\" \/><\/div><\/p>\n<p>\u4ee3\u7801\u6bb5\u62671\u884c\u540e\uff0cR0\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u4e3a\uff1a0x00F42400\uff08\u4e0d\u7406\u89e3\u56db\u4e2a\u5b57\u8282\u4e3a\u4ec0\u4e48\u53cd\u8fc7\u6765\u7684\u8bfb\u8005\u8bf7\u590d\u4e60\u4e00\u4e0b\u6709\u5173\u5927\u5c0f\u7aef\u5b58\u50a8\u7684\u77e5\u8bc6\uff0cSTM32\u662f\u5c0f\u7aef\u5b58\u50a8\uff09<\/p>\n<p>\u4ee3\u7801\u6bb5\u62672\u884c\u540e\uff0cR0\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u4e3a\uff1a0x00002400<\/p>\n<p>\u4ee3\u7801\u6bb5\u62673\u884c\u540e\uff0cR0\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u4e3a\uff1a0x00000000<\/p>\n<h4>\u591a\u5bc4\u5b58\u5668\u64cd\u4f5c<\/h4>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">LDM<\/td>\n<td style=\"text-align: center;\">Rn,regList<\/td>\n<td style=\"text-align: center;\">\u591a\u5bc4\u5b58\u5668\u8bfb\u53d6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">STM<\/td>\n<td style=\"text-align: center;\">Rn,regList<\/td>\n<td style=\"text-align: center;\">\u591a\u5bc4\u5b58\u5668\u5199\u5165<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>\u7b14\u8005\u6ce8\uff1a<\/p>\n<p>LDM\u6307\u4ee4\u5728\u624b\u518c\u4e2d\u7684\u8bed\u6cd5\u5982\u4e0b<strong>\uff08STM\u540c\u7406\uff0c\u7565\uff09<\/strong>\uff1a<\/p>\n<p><code>LDM{addr_mode}{cond} Rn{!}, reglist{^}<\/code><\/p>\n<p>\u5176\u4e2daddr_mode\u8868\u793a\u5b58\u53d6\u65f6\u7684\u5730\u5740\u6a21\u5f0f\uff0c\u53ef\u9009\u503c\u6709\uff1a<\/p>\n<p>IA(increase after)\u3001IB(increase before)\u3001DA(decrease after)\u3001DB(decrease before)<\/p>\n<p>\u5176\u4e2dIB\u548cDA\u5747<strong>\u4ec5\u652f\u6301A32\u6307\u4ee4\u96c6<\/strong>\uff0c\u6545\u5728\u7b14\u8005\u7684\u5e73\u53f0\u4e0a\u65e0\u6cd5\u4f7f\u7528\u3002<\/p>\n<\/blockquote>\n<h4>\u7a0b\u5e8f\u72b6\u6001\u5bc4\u5b58\u5668\u64cd\u4f5c<\/h4>\n<p>\u7a0b\u5e8f\u72b6\u6001\u5bc4\u5b58\u5668\u4e0d\u53ef\u76f4\u63a5\u4fee\u6539\uff0c\u6545\u63d0\u4f9b\u4e86\u5982\u4e0b\u6307\u4ee4\u6765\u5e2e\u52a9\u6211\u4eec\u4fee\u6539\u7a0b\u5e8f\u72b6\u6001\u5bc4\u5b58\u5668(PSR)\u4e2d\u7684\u503c\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">MRS<\/td>\n<td style=\"text-align: center;\">Rd, psr<\/td>\n<td style=\"text-align: center;\">\u7a0b\u5e8f\u72b6\u6001\u5bc4\u5b58\u5668\u79fb\u52a8\u5230\u901a\u7528\u5bc4\u5b58\u5668\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MSR<\/td>\n<td style=\"text-align: center;\">psr_fields, Rm<\/td>\n<td style=\"text-align: center;\">\u901a\u7528\u5bc4\u5b58\u5668\u79fb\u52a8\u5230\u7a0b\u5e8f\u72b6\u6001\u5bc4\u5b58\u5668\u4e2d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>\u7b14\u8005\u6ce8\uff1a<\/p>\n<p>\u4e3a\u4e86\u66f4\u5bb9\u6613\u7684\u8bb0\u4f4f\u8fd9\u4e24\u6761\u6307\u4ee4\u7684\u65b9\u5411\uff0c\u9700\u8981\u5bf9\u6307\u4ee4\u6709\u4e00\u70b9\u81ea\u5df1\u7684\u7406\u89e3\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>MRS\u53ef\u4ee5\u7406\u89e3\u4e3a\uff1a<code>MOV Reg,Status<\/code>\uff0c\u6545\u5176\u65b9\u5411\u81ea\u7136\u662f\u5c06\u72b6\u6001\u5bc4\u5b58\u5668\u79fb\u5165\u901a\u7528\u5bc4\u5b58\u5668\u3002<\/p>\n<\/blockquote>\n<h3>\u8df3\u8f6c\u6307\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">B<\/td>\n<td style=\"text-align: center;\">lable<\/td>\n<td style=\"text-align: center;\">\u8df3\u8f6c\u4ee3\u7801\u5230lable\u5904<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">BL<\/td>\n<td style=\"text-align: center;\">lable<\/td>\n<td style=\"text-align: center;\">\u8df3\u8f6c\u5230lable\u5904\u5e76\u4e3aLR\u5bc4\u5b58\u5668\u8d4b\u503c\u4ee5\u4fbf\u540e\u7eed\u8fd4\u56de<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">BX<\/td>\n<td style=\"text-align: center;\">lable<\/td>\n<td style=\"text-align: center;\">\u8df3\u8f6c\u5230lable\u5904\u5e76\u5207\u6362\u6307\u4ee4\u96c6\u5230Thumb<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">BLX<\/td>\n<td style=\"text-align: center;\">lable<\/td>\n<td style=\"text-align: center;\">\u8df3\u8f6c\u5230lable\u5e76\u8d4b\u503cLR\u5e76\u5207\u6362\u6307\u4ee4\u96c6\u5230Thumb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5f02\u5e38\u6307\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u7801<\/th>\n<th style=\"text-align: center;\">\u64cd\u4f5c\u6570<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">SVC(SWI)<\/td>\n<td style=\"text-align: center;\">#imm<\/td>\n<td style=\"text-align: center;\">\u89e6\u53d1\u5f02\u5e38\uff0cCPSR\u4fdd\u5b58\u5230SPSR\uff0c\u8c03\u7528SVC_Handler<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">BKPT<\/td>\n<td style=\"text-align: center;\">#imm<\/td>\n<td style=\"text-align: center;\">\u89e6\u53d1\u65ad\u70b9\u5f02\u5e38<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u5e38\u7528\u4f2a\u6307\u4ee4<\/h2>\n<p>\u57fa\u4e8e\u4e0d\u540c\u7684\u5e73\u53f0\uff0c\u5e38\u7528\u7684\u4f2a\u6307\u4ee4\u53ef\u4ee5\u5927\u81f4\u5206\u4e3a\u4e24\u4e2aArm\u4f2a\u6307\u4ee4\u548cGNU\u4f2a\u6307\u4ee4\uff0c\u4e0d\u540c\u5e73\u53f0\u7684\u4f2a\u6307\u4ee4\u7edd\u5927\u90e8\u5206\u4e0d\u53ef\u517c\u5bb9\uff0c\u4ee5\u4e0b\u5217\u4e3e\u4e3aArm\u4f2a\u6307\u4ee4\uff1a<\/p>\n<h3>\u57fa\u672c\u4f2a\u6307\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u4f2a\u6307\u4ee4<\/th>\n<th style=\"text-align: center;\">\u7528\u6cd5<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">AREA<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u58f0\u660e\u6bb5\u540d\uff0c\u6bb5\u529f\u80fd\uff0c\u5c5e\u6027<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">CODE16\/CODE32<\/td>\n<td style=\"text-align: center;\">\u65e0<\/td>\n<td style=\"text-align: center;\">\u58f0\u660e\u4ee5\u4e0b\u6307\u4ee4\u7684\u6307\u4ee4\u4f4d\u6570\uff0c\u4e0d\u505a\u5207\u6362<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">ENTRY<\/td>\n<td style=\"text-align: center;\">ENTRY addr<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u6c47\u7f16\u7a0b\u5e8f\u5165\u53e3\u70b9<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">EQU<\/td>\n<td style=\"text-align: center;\">name EQU const<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u5e38\u91cf<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">END<\/td>\n<td style=\"text-align: center;\">\u65e0<\/td>\n<td style=\"text-align: center;\">\u6e90\u7a0b\u5e8f\u7ed3\u5c3e\u6807\u5fd7<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">EXPORT<\/td>\n<td style=\"text-align: center;\">EXPORT \u7b26\u53f7<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u5168\u5c40\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">IMPORT<\/td>\n<td style=\"text-align: center;\">IMPORT \u7b26\u53f7<\/td>\n<td style=\"text-align: center;\">\u9759\u6001\u5bfc\u5165\u5168\u5c40\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">EXTERN<\/td>\n<td style=\"text-align: center;\">EXTERN \u7b26\u53f7<\/td>\n<td style=\"text-align: center;\">\u52a8\u6001\u5f15\u7528\u5168\u5c40\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">GET<\/td>\n<td style=\"text-align: center;\">GET \u201c\u6587\u4ef6\u540d\u201d<\/td>\n<td style=\"text-align: center;\">\u5305\u542b\u6587\u4ef6\u5230\u5f53\u524d\u6587\u4ef6\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">RN<\/td>\n<td style=\"text-align: center;\">name RN Rn<\/td>\n<td style=\"text-align: center;\">\u5bc4\u5b58\u5668\u5b9a\u4e49\u522b\u540d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u53d8\u91cf\u76f8\u5173\u4f2a\u6307\u4ee4<\/h3>\n<p>\u6c47\u7f16\u652f\u6301\u7684\u53d8\u91cf\u6709\u4e09\u79cd\uff1a\u6570\u5b57\u53d8\u91cf\u3001\u903b\u8f91\u53d8\u91cf\u548c\u5b57\u7b26\u4e32\u53d8\u91cf\u3002<\/p>\n<p>\u53d8\u91cf\u7684\u751f\u547d\u5468\u671f\u6709\u4e24\u79cd\uff1a\u5168\u5c40\u548c\u5c40\u90e8\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u4f2a\u6307\u4ee4<\/th>\n<th style=\"text-align: center;\">\u7528\u6cd5<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">GBLA\/GBLL\/GBLS<\/td>\n<td style=\"text-align: center;\">GBLA name<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u5168\u5c40\u6570\u5b57\/\u903b\u8f91\/\u5b57\u7b26\u4e32\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">LBLA\/LBLL\/LBLS<\/td>\n<td style=\"text-align: center;\">LBLA name<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u5c40\u90e8\u6570\u5b57\/\u903b\u8f91\/\u5b57\u7b26\u4e32\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">SETA\/SETL\/SETS<\/td>\n<td style=\"text-align: center;\">name SETA value<\/td>\n<td style=\"text-align: center;\">\u4e3a\u6570\u5b57\/\u903b\u8f91\/\u5b57\u7b26\u4e32\u53d8\u91cf\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">RLIST<\/td>\n<td style=\"text-align: center;\">nameRLIST {RegList}<\/td>\n<td style=\"text-align: center;\">\u5b9a\u4e49\u5bc4\u5b58\u5668\u5217\u8868\u53d8\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u6570\u636e\u5b9a\u4e49\u76f8\u5173\u4f2a\u6307\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u4f2a\u6307\u4ee4<\/th>\n<th style=\"text-align: center;\">\u7528\u6cd5<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">DCB<\/td>\n<td style=\"text-align: center;\">name DCB value<\/td>\n<td style=\"text-align: center;\">\u5206\u914d\u8fde\u7eed\u7684\u5b57\u8282\u5b58\u50a8\u5355\u5143<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">DCW<\/td>\n<td style=\"text-align: center;\">name DCW value<\/td>\n<td style=\"text-align: center;\">\u5206\u914d\u8fde\u7eed\u7684\u534a\u5b57\u5b58\u50a8\u5355\u5143<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">DCD<\/td>\n<td style=\"text-align: center;\">name DCD value<\/td>\n<td style=\"text-align: center;\">\u5206\u914d\u8fde\u7eed\u7684\u5b57\u5b58\u50a8\u5355\u5143<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">DCFD<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u6d6e\u70b9\u53cc\u7cbe\u5ea6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">DCFS<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u6d6e\u70b9\u5355\u7cbe\u5ea6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">SPACE<\/td>\n<td style=\"text-align: center;\">name SPACE value<\/td>\n<td style=\"text-align: center;\">\u5206\u914dvalue\u4e2a\u5b57\u8282\u7684\u8fde\u7eed\u5b58\u50a8\u5355\u5143<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MAP<\/td>\n<td style=\"text-align: center;\">MAP addr<\/td>\n<td style=\"text-align: center;\">\u7528\u4e8e\u6784\u5efa\u6570\u636e\u7ed3\u6784<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">FIELD<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u7528\u4e8e\u6784\u5efa\u6570\u636e\u7ed3\u6784<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u63a7\u5236\u76f8\u5173\u4f2a\u6307\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u4f2a\u6307\u4ee4<\/th>\n<th style=\"text-align: center;\">\u7528\u6cd5<\/th>\n<th style=\"text-align: center;\">\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">IF ELSE ENDIF<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u5206\u652f<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">WHILE WEND<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u5faa\u73af<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MACRO MEND<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u5b8f\u5b9a\u4e49<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">MEXIT<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">\u8df3\u51fa\u5b8f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u6df7\u5408\u7f16\u7a0b<\/h2>\n<p>C\u8bed\u8a00\u4f5c\u4e3a\u4e00\u79cd\u9ad8\u7ea7\u8bed\u8a00\uff0c\u6709\u65f6\u5019\u5e76\u4e0d\u80fd\u5b9e\u73b0\u6838\u5fc3\u5bc4\u5b58\u5668\u7684\u64cd\u4f5c\uff0c\u800c\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u90e8\u5206\u64cd\u4f5c\uff0c\u5f80\u5f80\u9700\u8981C\u7a0b\u5e8f\u548c\u6c47\u7f16\u7a0b\u5e8f\u8fdb\u884c\u6df7\u5408\u7f16\u7a0b\u3002\u4ee5\u4e0b\u662f\u5e38\u7528\u7684\u51e0\u79cd\u6df7\u5408\u7f16\u7a0b\u65b9\u5f0f\uff1a<\/p>\n<h3>C\u4e2d\u5185\u8054\u6c47\u7f16<\/h3>\n<p>C\u8bed\u8a00\u4e2d\u5185\u8054\u6c47\u7f16\u662f\u7531<strong>\u7f16\u8bd1\u5668<\/strong>\u5b9e\u73b0\u7684\u529f\u80fd\uff0c\u6240\u4ee5\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\u5b9e\u73b0\u7684\u8bed\u6cd5\u4e0e\u65b9\u5f0f\u90fd\u5e76\u4e0d\u76f8\u540c\uff0c\u6b64\u5904\u7b14\u8005\u4ecb\u7ecd\u7684\u662fAC6\u5bf9\u5e94\u7684\u6807\u51c6\uff0c\u5177\u4f53\u7684\u7f16\u8bd1\u5668\u7684\u6807\u51c6\u53ef\u4ee5\u67e5\u770b<a href=\"https:\/\/developer.arm.com\/documentation\/dui1093\/d\/Using-Assembly-and-Intrinsics-in-C-or-C---Code\/Writing-inline-assembly-code?lang=en\">ARM\u7f16\u8bd1\u5668\u624b\u518c<\/a>\u6765\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002<\/p>\n<p>\u5185\u8054\u6c47\u7f16\u53ef\u4ee5\u4f7f\u7528<code>__asm<\/code>\u5173\u952e\u5b57\u6765\u5b9e\u73b0\uff0c\u4f7f\u7528\u5176\u5185\u8054\u6c47\u7f16\u8bed\u53e5\u7684\u4e00\u822c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-C\">\/\/ \u57fa\u7840\u8bed\u6cd5\n__asm [volatile] (&lt;code&gt;);\n\n\/\/ \u6269\u5c55\u8bed\u6cd5\n__asm [volatile] (&lt;code_template&gt;\n                 :&lt;output_operand_list&gt;\n                [:&lt;input_operand_list&gt;\n                [:&lt;clobbered_register_list&gt;]]);<\/code><\/pre>\n<p>\u5bf9\u4e8e<code>&lt;code&gt;<\/code>\u5176\u5b9e\u5c31\u662f\u666e\u901a\u7684\u6c47\u7f16\u8bed\u8a00\uff0c\u4f8b\u5982\uff1a<code>&quot;ADD R0, R1, R2&quot;<\/code>\u3002<\/p>\n<p>\u800c<code>&lt;code_template&gt;<\/code>\u5219\u662f\u6c47\u7f16\u4ee3\u7801\u6a21\u677f\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><code>&quot;ADD %[result], %[input_i], %[input_j]&quot;<\/code><\/p>\n<p><code>&lt;output_operand_list&gt;<\/code>\u662f\u8f93\u51fa\u64cd\u4f5c\u6570\u5217\u8868\uff0c\u6bcf\u4e2a\u64cd\u4f5c\u6570\u6709\u4e00\u4e2a\u7531\u65b9\u62ec\u53f7\u5305\u542b\u7684\u7b26\u53f7\u540d\uff0c\u4e00\u4e2a\u7ea6\u675f\u4fee\u9970\u7b26\u4ee5\u53ca\u4e00\u4e2a\u7531\u5706\u62ec\u53f7\u5305\u542b\u7684C\u8868\u8fbe\u5f0f\u7ec4\u6210\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><code>[result] &quot;=r&quot; (res)<\/code><\/p>\n<p>\u8be5\u5217\u8868\u53ef\u4ee5\u4e3a\u7a7a\u3002<\/p>\n<p><code>&lt;input_operand_list&gt;<\/code>\u662f\u8f93\u5165\u64cd\u4f5c\u6570\u5217\u8868\uff0c\u683c\u5f0f\u540c\u4e0a\uff0c\u7531\u9017\u53f7\u5206\u9694\u3002\u4f8b\u5982\uff1a<\/p>\n<p><code>[input_i] &quot;r&quot; (i), [input_j] &quot;r&quot; (j)<\/code><\/p>\n<p><code>&lt;clobbered_register_list&gt;<\/code>\u662f\u53ef\u7834\u574f\u7684\u5bc4\u5b58\u5668\u5217\u8868\uff08\u5fc5\u987b\u4f7f\u7528\u5c0f\u5199\u5217\u8868\uff09\uff0c\u9664\u5bc4\u5b58\u5668\u5916\u8fd8\u53ef\u4ee5\u586b\u5165\u4e24\u4e2a\u7279\u6b8a\u53c2\u6570\uff1a<\/p>\n<p>\u201dcc\u201c\uff1a\u4f7f\u6307\u4ee4\u5f71\u54cd\u6761\u4ef6\u6807\u5fd7\u4f4d<\/p>\n<p>\u201dmemory\u201c\uff1a\u4f7f\u6307\u4ee4\u8bbf\u95ee\u672a\u77e5\u5185\u5b58\u5730\u5740<\/p>\n<p>\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-C\">int add(int a,int b){\n    int res;\n\n    __asm (&quot;ADD %[result], %[input_i], %[input_j]&quot;\n        : [result] &quot;=r&quot; (res)\n        : [input_i] &quot;r&quot; (a), [input_j] &quot;r&quot; (b)\n        : &quot;r5&quot;,&quot;r6&quot;,&quot;cc&quot;,&quot;memory&quot;\n    );\n\n    return res\n}<\/code><\/pre>\n<h3>C\u4e2d\u8c03\u6c47\u7f16<\/h3>\n<p>C\u4e2d\u8c03\u7528\u6c47\u7f16\u51fd\u6570\u5176\u5b9e\u5f88\u7b80\u5355\uff1a<\/p>\n<ul>\n<li>\n<p>\u6c47\u7f16\u6587\u4ef6\u4e2dEXPORT\u51fd\u6570\u540d<\/p>\n<\/li>\n<li>\n<p>C\u6587\u4ef6\u4e2dextern\u5bf9\u5e94\u51fd\u6570<\/p>\n<\/li>\n<\/ul>\n<p>\u5176\u4e2d\u9700\u8981\u63d0\u5230\u7684\u4e00\u70b9\u5c31\u662f<a href=\"https:\/\/blog.csdn.net\/jasonchen_gbd\/article\/details\/55225200\">ARM\u8fc7\u7a0b\u8c03\u7528\u6807\u51c6\uff08APCS\uff09<\/a>\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\u4f20\u53c2\u6807\u51c6\uff1aR0-R3\u8fd9\u56db\u4e2a\u5bc4\u5b58\u5668\u662f\u7528\u6765\u4f20\u53c2\u7684\u5bc4\u5b58\u5668\uff0c\u53ef\u7528\u4e8e\u5411\u6c47\u7f16\u51fd\u6570\u4e2d\u4f20\u9012\u53c2\u6570\u3002<\/p>\n<h3>\u6c47\u7f16\u4e2d\u8c03C<\/h3>\n<p>\u4e0e\u4e0a\u8282\u5927\u540c\u5c0f\u5f02\uff1a<\/p>\n<ul>\n<li>\u6c47\u7f16\u6587\u4ef6\u4e2dIMPORT\u51fd\u6570\u540d<\/li>\n<li>C\u6587\u4ef6\u4e2d\u5b9a\u4e49\u51fd\u6570\u5373\u53ef<\/li>\n<\/ul>\n<p>\u4f20\u53c2\u6807\u51c6\u4ecd\u7136\u53c2\u7167APCS\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e66\u63a5\u4e0a\u7bc7\uff1a\u6765\u5b66\u5b66ARM\u6c47\u7f16&#8212;-\u57fa\u672c\u77e5\u8bc6(\u4e0a) \u901a\u8fc7\u4e4b\u524d\u7684\u5b66\u4e60\uff0c\u7b14\u8005\u5df2\u7ecf\u5bf9\u4e8eArmv7-M\u4f53\u7cfb\u67b6\u6784\u6709\u4e86\u4e00\u4e9b\u5927 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[34,14],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-embedded","tag-arm","tag-14"],"_links":{"self":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=227"}],"version-history":[{"count":3,"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions\/442"}],"wp:attachment":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}