{"id":71,"date":"2019-06-18T15:33:35","date_gmt":"2019-06-18T07:33:35","guid":{"rendered":"http:\/\/151.236.221.165\/?p=71"},"modified":"2019-06-18T15:34:02","modified_gmt":"2019-06-18T07:34:02","slug":"register-memory-access","status":"publish","type":"post","link":"https:\/\/www.sanburs.xyz\/index.php\/2019\/06\/18\/register-memory-access\/","title":{"rendered":"\u5bc4\u5b58\u5668\uff08\u5185\u5b58\u8bbf\u95ee\uff09"},"content":{"rendered":"<div class=\"has-toc have-toc\"><\/div>\n<hr \/>\n<p><strong>\u672c\u6587\u6458\u81ea\u300a\u6c47\u7f16\u8bed\u8a00\u300b\uff0c\u4f5c\u8005\u738b\u723d<\/strong><\/p>\n<h2>DS\u548c[address]<\/h2>\n<p>8086CPU\u4e2d\u6709\u4e00\u4e2aDS\u5bc4\u5b58\u5668,\u901a\u5e38\u7528\u6765\u5b58\u653e\u8981\u8bbf\u95ee\u6570\u636e\u7684\u6bb5\u5730\u5740\u3002<\/p>\n<blockquote><p>\n  move al,[0]\n<\/p><\/blockquote>\n<p>\u8fd9\u91cc\u4f7f\u7528move\u6307\u4ee4\u5c06\u4e00\u4e2a\u5185\u5b58\u5355\u5143\u4e2d\u7684\u5185\u5bb9\u9001\u5165\u4e00\u4e2a\u5bc4\u5b58\u5668\u3002[0]\u8868\u793a\u5185\u5b58\u5355\u5143\u7684\u504f\u79fb\u5730\u5740\u3002\u53ea\u6709\u504f\u79fb\u5730\u5740\u662f\u4e0d\u80fd\u5b9a\u4f4d\u4e00\u4e2a\u5185\u5b58\u5355\u5143\u7684\uff0c\u90a3\u4e48\u5185\u5b58\u7684\u6bb5\u5730\u5740\u662f\u591a\u5c11\u5462\uff1f\u6307\u4ee4\u6267\u884c\u65f6\uff0cCPU\u81ea\u52a8\u53d6ds\u4e2d\u7684\u6570\u636e\u4e3a\u5185\u5b58\u5355\u5143\u7684\u6bb5\u5730\u5740\u3002<br \/>\n\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c8086CPU\u4e0d\u652f\u6301\u76f4\u63a5\u5c06\u6570\u636e\u9001\u5230\u6bb5\u5bc4\u5b58\u5668\u3002\u6240\u4ee5<strong><em>move ds,1000H<\/em><\/strong>\u8fd9\u6761\u6307\u4ee4\u662f\u975e\u6cd5\u7684\u3002\u5e94\u8be5\u8fd9\u6837\uff1a<\/p>\n<blockquote><p>\n  move bx,1000H<br \/>\n  move ds,bx\n<\/p><\/blockquote>\n<p>\u81f3\u4e8e\u4e3a\u4ec0\u4e488086CPU\u4e0d\u652f\u6301\u76f4\u63a5\u5c06\u6570\u636e\u9001\u5230\u6bb5\u5bc4\u5b58\u5668?\u8fd9\u5c5e\u4e8e8086CPU\u786c\u4ef6\u8bbe\u8ba1\u7684\u95ee\u9898\uff0c\u53ea\u9700\u8981\u77e5\u9053\u8fd9\u4e00\u70b9\u5c31\u591f\u4e86\u3002<\/p>\n<h2>move,add,sub\u6307\u4ee4\u603b\u7ed3<\/h2>\n<blockquote><p>\n  move \u5bc4\u5b58\u5668,\u6570\u636e<br \/>\n  move \u5bc4\u5b58\u5668,\u5bc4\u5b58\u5668<br \/>\n  move \u5bc4\u5b58\u5668,\u5185\u5b58\u5355\u5143<br \/>\n  move \u5185\u5b58\u5355\u5143,\u5bc4\u5b58\u5668<br \/>\n  move \u6bb5\u5bc4\u5b58\u5668,\u5bc4\u5b58\u5668<br \/>\n  move \u5bc4\u5b58\u5668,\u6bb5\u5bc4\u5b58\u5668<br \/>\n  move \u5185\u5b58\u5355\u5143,\u6bb5\u5bc4\u5b58\u5668<br \/>\n  move \u6bb5\u5bc4\u5b58\u5668\uff0c\u5185\u5b58\u5355\u5143\n<\/p><\/blockquote>\n<p>add\u4e0esub\u6307\u4ee4\u4e0emove\u4e00\u6837\uff0c\u53ea\u662f\u4e0d\u80fd\u5bf9\u6bb5\u5bc4\u5b58\u5668\u8fdb\u884c\u64cd\u4f5c\u3002\u56e0\u4e3a\u6bb5\u5bc4\u5b58\u5668\u4e0d\u80fd\u50cf\u901a\u7528\u5bc4\u5b58\u5668\u90a3\u6837\u8fdb\u884c\u8fd0\u7b97\uff0c\u8fd9\u662f\u786c\u4ef6\u9650\u5236\u3002\u800cmove\u6307\u4ee4\u4e0d\u6d89\u53ca\u8fd0\u7b97\uff0c\u53ea\u662f\u4f20\u9001\u6307\u4ee4\u3002<br \/>\n##\u6808<br \/>\n8086CPU\u7684push\u548cpop\u90fd\u662f\u4ee5\u5b57\u4e3a\u5355\u4f4d\u8fdb\u884c\u7684\u3002<\/p>\n<h3>\u4e24\u4e2a\u95ee\u9898<\/h3>\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u628a10000H-1000FH\u8fd9\u6bb5\u5185\u5b58\u5f53\u505a\u6808\u4f7f\u7528\uff0c\u4f46\u662f\u81f3\u5c11\u6709\u4e24\u4e2a\u95ee\u9898\u3002<br \/>\n1. CPU\u5982\u4f55\u77e5\u905310000H-1000FH\u8fd9\u6bb5\u7a7a\u95f4\u88ab\u5f53\u505a\u6808\u4f7f\u7528\uff1f<br \/>\n2. \u5728\u8fdb\u884cpush\uff0cpop\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u5fc5\u987b\u77e5\u9053\u6808\u9876\u5355\u5143\uff0c\u53ef\u662f\uff0c\u5982\u4f55\u77e5\u9053\uff1f<\/p>\n<blockquote><p>\n  8086CPU\u4e2d\uff0c\u6709\u4e24\u4e2a\u5bc4\u5b58\u5668\uff0c\u6bb5\u5bc4\u5b58\u5668SS\u548c\u5bc4\u5b58\u5668SP\u3002\u6808\u9876\u5730\u5740\u5b58\u653e\u5728SS\u4e2d\uff0c\u504f\u79fb\u5730\u5740\u5b58\u653e\u5728SP\u4e2d\u3002\u4efb\u610f\u65f6\u523b\uff0cSS:SP\u6307\u5411\u6808\u9876\u5143\u7d20\u3002\n<\/p><\/blockquote>\n<h3>push\u4e0epop\u529f\u80fd\u63cf\u8ff0<\/h3>\n<p>\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5b8c\u6574\u7684\u63cf\u8ff0push\u548cpop\u7684\u529f\u80fd\u4e86\uff0c\u5982<strong><em>push ax<\/em><\/strong><\/p>\n<blockquote>\n<ol>\n<li>SP=SP-2\uff0cSS:SP\u6307\u5411\u5f53\u524d\u6808\u9876\u524d\u9762\u7684\u5355\u5143\uff0c\u4ee5\u5f53\u524d\u6808\u9876\u524d\u9762\u7684\u5355\u5143\u4e3a\u65b0\u7684\u6808\u9876\u3002<\/li>\n<li>\u5c06ax\u4e2d\u7684\u5185\u5bb9\u9001\u5165SS:SP\u6307\u5411\u5185\u5b58\u5355\u5143\u5904\uff0cSS:SP\u6307\u5411\u65b0\u6808\u9876\u3002<\/li>\n<\/ol>\n<\/blockquote>\n<p>pop\u6267\u884c\u8fc7\u7a0b\u4e0epush\u521a\u597d\u76f8\u53cd\uff0c<strong><em>pop ax<\/em><\/strong><\/p>\n<blockquote>\n<ol>\n<li>\u5c06SS:SP\u6307\u5411\u7684\u5185\u5b58\u5355\u5143\u5904\u7684\u6570\u636e\u9001\u5165ax<\/li>\n<li>SP=SP+2\uff0cSS:SP\u6307\u5411\u5f53\u524d\u6808\u9876\u4e0b\u9762\u7684\u5355\u5143\uff0c\u4ee5\u5f53\u524d\u6808\u9876\u4e0b\u9762\u7684\u5355\u5143\u4e3a\u65b0\u7684\u6808\u9876\u3002<\/li>\n<\/ol>\n<\/blockquote>\n<p>push\u548cpop\u90fd\u53ef\u4ee5\u64cd\u4f5c\u5bc4\u5b58\u5668\uff0c\u6bb5\u5bc4\u5b58\u5668\u548c\u5185\u5b58\u5355\u5143\u3002<\/p>\n<blockquote><p>\n  push \u5bc4\u5b58\u5668<br \/>\n  push \u6bb5\u5bc4\u5b58\u5668<br \/>\n  push \u5185\u5b58\u5355\u5143\n<\/p><\/blockquote>\n<h3>\u6808\u9876\u8d85\u754c<\/h3>\n<p>8086\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u6808\u9876\u8d85\u754c\u95ee\u9898\uff0c\u81ea\u5df1\u4f7f\u7528\u65f6\u6ce8\u610f\u3002\u65e2\u8981\u9632\u6b62\u5165\u6808\u592a\u591a\u5bfc\u81f4\u8d85\u754c\uff0c\u4e5f\u8981\u9632\u6b62\u6808\u7a7a\u7684\u65f6\u5019\u51fa\u6808\u5bfc\u81f4\u7684\u8d85\u754c\u3002<\/p>\n<h3>\u6808\u4e3a\u4ec0\u4e48\u9006\u5411\u751f\u957f<\/h3>\n<p><strong><em>\u8fd9\u6bb5\u5185\u5bb9\u6458\u81ea\u300aReverse Engineering for Beginners\u300b\uff0c\u4f5c\u8005\uff1aDennis Yurichev<\/em><\/strong><\/p>\n<p>The reason that the stack grows backward is probably historical. When the computers were big and occupied a whole room, it was easy to divide memory into two parts, one for the heap and one for the stack. Of course, it was unknown how big the heap and the stack would be during program execution, sothis solution was the simplest possible.<br \/>\nIn [D. M. Ritchie and K. Thompson, The UNIX Time Sharing System, (1974)]we can read\uff1a<\/p>\n<blockquote><p>\n  The user-core part of an image is divided into three logical segments.<br \/>\n  The program text segment begins at location 0 in the virtual address<br \/>\n  space. During execution, this segment is write-protected and a single<br \/>\n  copy of it is shared among all processes executing the same program.<br \/>\n  At the first 8K byte boundary above the program text segment in the<br \/>\n  virtual address space begins a nonshared, writable data segment, the<br \/>\n  size of which may be extended by a system call. Starting at the<br \/>\n  highest address in the virtual address space is a stack segment, which<br \/>\n  automatically grows downward as the hardware\u2019s stack pointer<br \/>\n  fluctuates.\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6458\u81ea\u300a\u6c47\u7f16\u8bed\u8a00\u300b\uff0c\u4f5c\u8005\u738b\u723d DS\u548c[address] 8086CPU\u4e2d\u6709\u4e00\u4e2aDS\u5bc4\u5b58\u5668,\u901a\u5e38\u7528\u6765\u5b58\u653e\u8981\u8bbf\u95ee\u6570\u636e\u7684\u6bb5\u5730\u5740\u3002 mo &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/71"}],"collection":[{"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":1,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":72,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/71\/revisions\/72"}],"wp:attachment":[{"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sanburs.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}