{
  "version": "https://jsonfeed.org/version/1", 
  "title": "\u6c47\u7f16", 
  "description": "", 
  "home_page_url": "https://www.v2ex.com/go/assembly", 
  "feed_url": "https://www.v2ex.com/feed/assembly.json", 
  "items": [
    {
      "author": {
        "url": "https://www.v2ex.com/member/foxyier", 
        "name": "foxyier", 
        "avatar": "https://cdn.v2ex.com/gravatar/1f81470bfe2e5790748810e44269bbc9?s=73&d=retro"
      }, 
      "url": "https://www.v2ex.com/t/1041265", 
      "title": "\u5728\u6d4f\u89c8\u5668\u4f7f\u7528 wasm \u5982\u4f55\u89e3\u51b3\u517c\u5bb9\u6027\u95ee\u9898", 
      "id": "https://www.v2ex.com/t/1041265", 
      "date_published": "2024-05-16T03:54:51+00:00", 
      "content_html": "<p>\u4e3a\u4e86\u5b89\u5168\u8003\u8651\uff0c \u6253\u7b97\u91c7\u7528 wasm \u4fdd\u62a4\u52a0\u5bc6\u7b97\u6cd5\u3002</p>\n<p>\u4f46\u662f\u9488\u5bf9\u4e0d\u517c\u5bb9\u7684\u6d4f\u89c8\u5668\uff0c\u5982\u4f55\u80fd\u505a\u5230\u964d\u7ea7\u7684\u540c\u65f6\u4e0d\u4f1a\u51fa\u73b0\u6f0f\u6d1e\u5462\u3002</p>\n<p>\u60f3\u8bf7\u6559\u4e00\u4e0b\u5927\u4f6c\u4eec\u9488\u5bf9\u8fd9\u79cd\u573a\u666f\u90fd\u662f\u600e\u4e48\u505a\u7684\u3002</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/huzhikuizainali", 
        "name": "huzhikuizainali", 
        "avatar": "https://cdn.v2ex.com/avatar/1869/a390/522912_large.png?m=1752498684"
      }, 
      "url": "https://www.v2ex.com/t/1017817", 
      "title": "C++\u4e2d i=i; \u4e0e *p=i; \u5bf9\u5e94\u7684\u6c47\u7f16\u4ee3\u7801\u4e3a\u4ec0\u4e48\u4e0d\u4e00\u6837\uff1f", 
      "id": "https://www.v2ex.com/t/1017817", 
      "date_published": "2024-02-23T03:56:41+00:00", 
      "content_html": "\u300a C++ Primer \u300b P48   \u95ee\u8fd9\u4e2a\u95ee\u9898\u7684\u76ee\u7684\u662f\u5e0c\u671b\u66f4\u6df1\u5165\u7406\u89e3 C++\u7684\u6307\u9488<br />int i=42;<br />int &amp;r=i;<br />int *p=&amp;i;<br />*p=i;<br />i=i;<br /><br />\u4e0a\u8ff0 C++\u4ee3\u7801\u4e2d i=i; \u4e0e *p=i; \u5bf9\u5e94\u7684\u6c47\u7f16\u4ee3\u7801\u4e3a\u4ec0\u4e48\u4e0d\u4e00\u6837\uff1f<br />\u5728 <a target=\"_blank\" href=\"http://godbolt.org\" rel=\"nofollow noopener\">godbolt.org</a> \u4e2d<br /> *p=i; \u5bf9\u5e94\u5982\u4e0b\u6c47\u7f16\u8bed\u8a00<br />         mov     edx, DWORD PTR [rbp-20]<br />        mov     rax, QWORD PTR [rbp-16]<br />        mov     DWORD PTR [rax], edx<br />        <br />i=i;\u5bf9\u5e94\u5982\u4e0b\u6c47\u7f16\u8bed\u8a00<br />        mov     eax, DWORD PTR [rbp-20]<br />        mov     DWORD PTR [rbp-20], eax"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/tiRolin", 
        "name": "tiRolin", 
        "avatar": "https://cdn.v2ex.com/gravatar/34a55186afde13a3880f2970ecaeffdc?s=73&d=retro"
      }, 
      "url": "https://www.v2ex.com/t/998869", 
      "title": "\u6c47\u7f16\u95ee\u9898\u6c42\u89e3\uff0c\u8fd9\u4e2a\u95ee\u9898\u6211\u81ea\u5df1\u786e\u5b9e\u505a\u4e0d\u6765", 
      "id": "https://www.v2ex.com/t/998869", 
      "date_published": "2023-12-08T18:43:04+00:00", 
      "content_html": "<p>\u9898\u76ee\u8981\u6c42\u5982\u4e0b</p>\n<p>\u5728\u5c4f\u5e55\u7684\u7b2c\u4e00\u884c\u663e\u793a\u6570\u636e belles \u3002\nbelles\tdb  \"Reading is a happy thing. For those who love reading, once they read it,\"\t\u3002\u8bf7\u6839\u636e\u9700\u8981\u7f16\u5199\u5b50\u7a0b\u5e8f\uff0c\u5b9e\u73b0\uff1a\u4f9d\u6b21\u53d6\u8d70\u5b57\u7b26\uff0c\u5e76\u8ba9\u5b57\u7b26\u4ece\u5176\u4f4d\u7f6e\u8dcc\u843d\u5230\u5c4f\u5e55\u5e95\u90e8\u5e76\u6d88\u5931\u3002</p>\n<p>\u6211\u81ea\u5df1\u7684\u60f3\u6cd5\u662f\u5c06\u505a\u597d\u51e0\u4e2a\u5faa\u73af\u6765\u5199\uff0c\u6bd4\u5982\u7b2c\u4e00\u4e2a\u5faa\u73af\u8ba9\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5f80\u4e0b\u6389\uff0c\u7b2c\u4e8c\u4e2a\u5c31\u8ba9\u7b2c\u4e8c\u4e2a\u5f80\u4e0b\u6389\u5565\u7684\uff0c\u4f46\u662f\u6211\u5199\u4e86\u4e00\u4e2a\u53d1\u73b0\u505a\u8fd9\u6837\u7684\u5faa\u73af\u76f4\u63a5\u8fd0\u884c\u4e4b\u540e DosBox \u4f1a\u76f4\u63a5\u5361\u6b7b\uff0c\u95ee GPT \uff0c\u4f46\u662f GPT \u81ea\u5df1\u7ed9\u7684\u4ee3\u7801\u603b\u662f\u6709\u95ee\u9898\uff0c\u767e\u5ea6\u4e00\u4e0b\u4e5f\u53ea\u80fd\u627e\u5230\u4e00\u4e2a\u4ee3\u7801\uff0c\u90a3\u4e2a\u4ee3\u7801\u4e5f\u4e0d\u80fd\u5b9e\u73b0\u9898\u76ee\u8981\u6c42\u7684\u6548\u679c\uff0c\u505a\u4e86\u51e0\u4e2a\u5c0f\u65f6\u4e86\u8fd8\u5361\u5728\u8fd9</p>\n<p>\u6211\u771f\u7684\u6ca1\u529e\u6cd5\u4e86\uff0c\u6240\u4ee5\u6211\u6765\u8bf7\u6559\u5404\u4f4d\uff0c\u6c42\u6c42\u5404\u4f4d\u5927\u4f6c\u5e2e\u5e2e\u6211\u5427\n\u5982\u679c\u7ed9\u4e0d\u4e86\u4ee3\u7801\uff0c\u7ed9\u6211\u70b9\u601d\u8def\u4e5f\u884c\uff0c\u6211\u81ea\u5df1\u4f1a\u53bb\u8bd5\u7684</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/tiRolin", 
        "name": "tiRolin", 
        "avatar": "https://cdn.v2ex.com/gravatar/34a55186afde13a3880f2970ecaeffdc?s=73&d=retro"
      }, 
      "url": "https://www.v2ex.com/t/996629", 
      "title": "\u6709\u8c01\u80fd\u6765\u6559\u6211\u4e00\u4e0b\u6c47\u7f16\u7684\u95ee\u9898\u5417\uff1f\u6211\u771f\u7684\u56e0\u4e3a\u8fd9\u4e2a\u5361\u4e86\u597d\u4e45\u4e86", 
      "id": "https://www.v2ex.com/t/996629", 
      "date_published": "2023-11-30T12:35:15+00:00", 
      "content_html": "<p>\u9898\u76ee\u8981\u6c42\u662f\u8fd9\u6837\u7684</p>\n<p>\u5728\u5c4f\u5e55\u4e2d\u7684\u7b2c 10 \u884c\u5230 15 \u884c\u7684\u7b2c 20 \u5217\u5f00\u59cb\u663e\u793a\u5982\u4e0b\u83dc\u5355\uff1a\nArithmetic system of primary school</p>\n<ol>\n<li>add</li>\n<li>subtract</li>\n<li>multiply</li>\n<li>divide</li>\n</ol>\n<p>\u7136\u540e\u6211\u5199\u51fa\u4e86\u4e0b\u9762\u7684\u4ee3\u7801</p>\n<pre><code>assume cs:codesg, ds:datasg\ndatasg segment\n    welcome db 'Arithmetic system of primary school$'\n    file db '1. add$'\n    insert db '2. subtract$'\n    modify db '3. multiply$'\n    exit db '4. devide$'\ndatasg ends\n  \ncodesg segment\nstart:\n\n    mov ax, datasg\n    mov ds, ax\n        \n    mov ah, 02h \n    mov dh, 09h \n    mov dl, 13h \n    int 10h \n        \n    lea dx, welcome\n    mov ah, 09h\n    int 21h \n        \n    mov ah, 02h \n    mov dh, 10h \n    mov dl, 13h \n    int 10h \n        \n    lea dx, file\n    mov ah, 09h\n    int 21h   \n        \n    mov ah, 02h \n    mov dh, 11h \n    mov dl, 13h \n    int 10h \n        \n    lea dx, insert\n    mov ah, 09h\n    int 21h\n        \n    mov ah, 02h \n    mov dh, 12h \n    mov dl, 13h \n    int 10h \n        \n    lea dx, modify\n    mov ah, 09h\n    int 21h\n        \n    mov ah, 02h \n    mov dh, 13h \n    mov dl, 13h \n    int 10h \n        \n    lea dx, exit\n    mov ah, 09h\n    int 21h\n        \n    ;\u7b49\u5f85\u7528\u6237\u6309\u952e\n    mov ah, 07h \n    int 21h \n        \n    mov ah, 4ch \n    int 21h \ncodesg ends\nend start\n</code></pre>\n<p>\u8fd9\u4e2a\u4ee3\u7801\u53ef\u4ee5\u6b63\u786e\u663e\u793a\u51fa\u6211\u8981\u7684\u5185\u5bb9\uff0c\u4f46\u662f\u7b2c\u4e00\u884c\u548c\u7b2c\u4e8c\u884c\u4e4b\u95f4\u603b\u662f\u6709\u7a7a\u884c\uff0c\u5177\u4f53\u8868\u73b0\u5982\u4e0b</p>\n<p><img alt=\"\" class=\"embedded_image\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"https://rolin-typora.oss-cn-guangzhou.aliyuncs.com/20231130203445.png\"/></p>\n<p>\u6211\u771f\u7684\u60f3\u4e0d\u660e\u767d\u95ee\u9898\u51fa\u5728\u54ea\u91cc\n\u4e0d\u8bba\u662f\u95ee\u767e\u5ea6\u8fd8\u662f\u95ee gpt \u90fd\u4e0d\u592a\u7ba1\u7528\uff0c\u6211\u6ca1\u6cd5\u4e86\u6240\u4ee5\u6765\u95ee\u95ee\u5404\u4f4d\uff0c\u5e0c\u671b\u6709\u61c2\u7684\u6551\u4e00\u4e0b\uff0c\u6211\u5148\u8c22\u8c22\u5404\u4f4d\u4e86</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/realdvorak", 
        "name": "realdvorak", 
        "avatar": "https://cdn.v2ex.com/gravatar/07fa22bfc488fd28f6d7229c56262542?s=73&d=retro"
      }, 
      "url": "https://www.v2ex.com/t/940385", 
      "title": "\u5982\u4f55\u5b66\u4e60\u6c47\u7f16\u8bed\u8a00\uff1f", 
      "id": "https://www.v2ex.com/t/940385", 
      "date_published": "2023-05-16T05:28:13+00:00", 
      "content_html": "<p>\u5df2\u7ecf\u770b\u8fc7\u4e86\u738b\u723d\u8001\u5e08\u7684\u300a\u6c47\u7f16\u8bed\u8a00\u300b\uff0c\u8bb2\u7684\u5f88\u597d\uff0c\u4f46\u662f\u662f\u7528 8086 \u5165\u95e8\u7684\u3002\u60f3\u8fdb\u4e00\u6b65\u5b66\u4e60\uff0c\u6709\u6ca1\u6709\u63a8\u8350\u7684\u6559\u6750\uff0c\u73b0\u5728\u5728\u770b\u300a\u4ece\u5b9e\u6a21\u5f0f\u5230\u4fdd\u62a4\u6a21\u5f0f\u300b\uff0c\u8fd9\u672c\u600e\u4e48\u6837\uff1f</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/dangyuluo", 
        "name": "dangyuluo", 
        "avatar": "https://cdn.v2ex.com/avatar/b251/eb66/70143_large.png?m=1674619921"
      }, 
      "url": "https://www.v2ex.com/t/888159", 
      "date_modified": "2022-10-19T08:46:31+00:00", 
      "content_html": "<p>\u4ee5\u4e0b\u662f\u6e90\u7801\uff1a</p>\n<pre><code class=\"language-c\">int duplicate(int n)\n{\n    return n * 2;\n}\nint global_var = duplicate(0x42);\n\nint main(int argc, char** argv){\n    return global_var;\n}\n</code></pre>\n<p>\u6709\u4e00\u4e2a global variable, \u7528\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\uff0c\u5e76\u67e5\u770b\u6c47\u7f16\u4ee3\u7801\uff1a</p>\n<pre><code class=\"language-shell\">g++ -o main ./main.c -O0\nobjdump -C -S -s main\n</code></pre>\n<p>\u5176\u8f93\u51fa\u53ef\u89c1\uff1a <a href=\"https://controlc.com/70c59b1e\" rel=\"nofollow\">https://controlc.com/70c59b1e</a></p>\n<p>\u603b\u662f\u542c\u522b\u4eba\u8bf4\uff0cstatic storage variable(\u57fa\u672c\u4e0a\u5c31\u662f global variable)\u5728\u8fdb\u5165<code>main</code>\u4e4b\u524d\u5c31\u88ab\u521d\u59cb\u5316\u4e86\uff0c\u4f46\u662f\u5728\u67e5\u770b\u6c47\u7f16\u4ee3\u7801\u65f6\uff0c\u6211\u5e76\u6ca1\u6709\u627e\u5230\u76f8\u5173\u7684\u8c03\u7528\u3002</p>\n<p><code>__static_initialization_and_destruction_0(int, int)</code>\u770b\u8d77\u6765\u50cf\u662f\u521d\u59cb\u5316<code>global_var</code>\uff0c\u88ab<code>_GLOBAL__sub_I__Z9duplicatei</code>\u8c03\u7528\uff0c\u4f46\u662f\u6211\u6ca1\u6709\u5728\u4efb\u4f55\u5730\u65b9\u770b\u5230\u5bf9<code>_GLOBAL__sub_I__Z9duplicatei</code>\u7684\u8c03\u7528\u3002\u56e0\u6b64\u60f3\u8bf7\u95ee\u6211\u7684\u601d\u8def\u5bf9\u4e48\uff1f</p>\n", 
      "date_published": "2022-10-19T08:46:09+00:00", 
      "title": "Linux \u4e0b, global variable \u5728\u6c47\u7f16\u91cc\u662f\u4ec0\u4e48\u65f6\u5019\u88ab\u521d\u59cb\u5316\u7684\u5462\uff1f", 
      "id": "https://www.v2ex.com/t/888159"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/Orlion", 
        "name": "Orlion", 
        "avatar": "https://cdn.v2ex.com/avatar/a2a6/ad27/212136_large.png?m=1699950457"
      }, 
      "url": "https://www.v2ex.com/t/744836", 
      "title": "Lock \u6307\u4ee4\u5230\u5e95\u6709\u4ec0\u4e48\u7528\uff1f", 
      "id": "https://www.v2ex.com/t/744836", 
      "date_published": "2021-01-14T03:38:19+00:00", 
      "content_html": "<p>\u6700\u8fd1\u5728\u770b\u539f\u5b50\u64cd\u4f5c\u7684\u539f\u7406\uff0c\u5f97\u77e5\u662f\u901a\u8fc7 Lock \u6307\u4ee4\u4fdd\u8bc1\u4e86\u5185\u5b58\u8bfb\u5199\u539f\u5b50\u6027\uff0c\u5176\u539f\u7406\u662f</p>\n<ul>\n<li>CPU \u4fdd\u8bc1 Lock \u540e\u7f00\u540e\u8ddf\u7684\u6307\u4ee4\u539f\u5b50\u6027</li>\n<li>\u8001 CPU \u4e0a\u901a\u8fc7\u9501\u603b\u7ebf\u6765\u4fdd\u8bc1\u53ef\u89c1\u6027</li>\n<li>\u65b0 CPU \u4e0a\u5982\u679c\u6570\u636e\u5b58\u5728\u4e8e cpu cache \u4e0a\u65f6\u901a\u8fc7 MESI \u534f\u8bae\u6765\u5b9e\u73b0\u53ef\u89c1\u6027\uff0c\u5426\u5219\u8fd8\u662f\u9501\u603b\u7ebf</li>\n</ul>\n<p>\u5bf9\u6b64\u6211\u4ea7\u751f\u4e86\u51e0\u4e2a\u95ee\u9898\uff1a</p>\n<ol>\n<li>\u96be\u9053\u4e0d\u58f0\u660e Lock CPU \u5c31\u4e0d\u901a\u8fc7 MESI \u534f\u8bae\u4fdd\u8bc1 cache \u4e00\u81f4\u6027\u5417\uff1f\u6211\u89c9\u5f97\u4e0d\u662f, <a href=\"https://strikefreedom.top/cpu-caches-theory-and-application\" rel=\"nofollow\">https://strikefreedom.top/cpu-caches-theory-and-application</a> \u8fd9\u7bc7\u6587\u7ae0\u7684 demo \u4e2d\u5e76\u6ca1\u6709\u58f0\u660e Lock \u6307\u4ee4\uff0c\u4f46\u4ecd\u7136\u51fa\u73b0\u4e86\u7f13\u5b58\u5931\u6548\u3002</li>\n<li>\u662f\u4e0d\u662f\u9664\u4e86 cpu cache \u5916\u8fd8\u6709 store buffer \u548c invalid queue \u4f1a\u5f71\u54cd\u53ef\u89c1\u6027\uff0c\u6240\u4ee5 CPU \u53ea\u80fd\u4fdd\u8bc1 cache \u7684\u4e00\u81f4\u6027\u4f46\u4fdd\u8bc1\u4e0d\u4e86\u5176\u4ed6\u786c\u4ef6\u7f13\u5b58\u5c42\u9762\u7684\u4e00\u81f4\u6027\uff0c\u6240\u4ee5\u8fd8\u662f\u9700\u8981 Lock \u6307\u4ee4\uff1f</li>\n</ol>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/zokin", 
        "name": "zokin", 
        "avatar": "https://cdn.v2ex.com/avatar/6b42/d2ff/445496_large.png?m=1571392203"
      }, 
      "url": "https://www.v2ex.com/t/679656", 
      "title": "\u6c42\u5927\u795e\u5e2e\u5fd9\u89e3\u7b54\u4e24\u4e2a\u9898\uff0c\u5173\u4e8e\u7f16\u7a0b\u7684\uff0c\u5e94\u4ed8\u5fae\u673a\u539f\u7406\u4e0e\u5e94\u7528\u8fc7\u5173\u8003\u8bd5\u7684\uff0c\u4e0d\u80dc\u611f\u6fc0", 
      "id": "https://www.v2ex.com/t/679656", 
      "date_published": "2020-06-08T04:07:18+00:00", 
      "content_html": "<p>\u4e00\u3001\u5229\u7528 DOS \u7cfb\u7edf\u529f\u80fd\u8c03\u7528\u7f16\u5199\u6c47\u7f16\u7a0b\u5e8f\uff0c\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u81ea\u5df1\u59d3\u7684\u62fc\u97f3\u548c\u5b66\u53f7\u7684\u540e 4 \u4e2a\u6570\u5b57\u7b26\u53f7\u3002\u4f8b\u5982\uff0c\u4f60\u59d3\u201c\u674e\u201d\uff0c\u4f60\u7684\u5b66\u53f7\u662f\u201c20201234\u201d\uff0c\u5219\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u51fa\u201cLI\uff1a1234\u201d\u3002\u5177\u4f53\u8981\u6c42\u5982\u4e0b\uff1a\n\uff08 1 \uff09\u7f16\u5199\u51fa\u5b8c\u6574\u7684\u6c47\u7f16\u8bed\u8a00\u7a0b\u5e8f\uff1b\n\uff08 2 \uff09\u5229\u7528\u5b8f\u6c47\u7f16\u7a0b\u5e8f MASM \u548c\u8fde\u63a5\u7a0b\u5e8f LINK \u5bf9\u6240\u7f16\u5199\u7684\u7a0b\u5e8f\u8fdb\u884c\u6c47\u7f16\u548c\u8fde\u63a5\uff0c\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u5728 DOS \u4e0b\u8fd0\u884c\u7a0b\u5e8f\u3002\n\uff08 3 \uff09\u6253\u5370\u51fa\u76f8\u5e94\u7684\u5217\u8868\u6587\u4ef6\uff08\u540e\u7f00 lst \u7684\u6587\u4ef6\uff09\u6e05\u5355\uff0c\u5e76\u5bf9\u8c03\u8bd5\u8fd0\u884c\u7ed3\u679c\u8fdb\u884c\u622a\u56fe\uff0c\u4ee5\u8bc1\u660e\u7a0b\u5e8f\u8c03\u8bd5\u6210\u529f\u3002</p>\n<p>\u4e8c\u3001\u57fa\u4e8e 8088CPU \u8bbe\u8ba1\u4e00\u4e2a\u6a21\u62df\u6570\u636e\u91c7\u96c6\u7cfb\u7edf\u3002\n\u5177\u4f53\u8981\u6c42\u5982\u4e0b\uff1a\n\uff08 1 \uff09\u91c7\u7528 ADC0809 A/D \u8f6c\u6362\u5668\u4e0e Intel 8255 \u53ef\u7f16\u7a0b\u5e76\u884c\u63a5\u53e3\u82af\u7247\u8bbe\u8ba1\u63a5\u53e3\u7535\u8def\u3002\u8bbe 8255 \u7684 PA \u4e3a\u6570\u636e\u53e3\uff0cPB \u3001PC \u4e3a\u63a7\u5236\u53e3\uff0c\u8f93\u5165\u6a21\u62df\u91cf\u63a5\u5165 ADC0809 \u7684 IN1 \u901a\u9053\u3002\u753b\u51fa ADC 0809 \u901a\u8fc7 Intel 8255 \u4e0e 8088CPU \u63a5\u53e3\u7684\u7535\u8def\u539f\u7406\u56fe\u3002\n\uff08 2 \uff09\u5047\u8bbe\u5730\u5740\u7801\u4e3a 3F0H~3F3H \u65f6 8255 \u7247\u9009\u4fe1\u53f7\u6709\u6548\uff0c\u91c7\u7528 74LS138 \u8bd1\u7801\u5668\u8bbe\u8ba1\u5730\u5740\u8bd1\u7801\u7535\u8def\u3002\u753b\u51fa\u5730\u5740\u8bd1\u7801\u5668\u4e0e CPU \u7cfb\u7edf\u548c 8255 \u4e4b\u95f4\u7684\u8fde\u7ebf\u56fe\u3002\n\uff08 3 \uff09\u7528\u6c47\u7f16\u8bed\u8a00\u7f16\u5199\u4e00\u6bb5\u7a0b\u5e8f\uff0c\u5b9e\u73b0\u4ece IN1 \u901a\u9053\u8bfb\u53d6 100 \u4e2a\u6570\u636e\u5e76\u5b58\u5165\u5185\u5b58\u6570\u636e\u6bb5\u4e2d\u3002</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/dogedoge", 
        "name": "dogedoge", 
        "avatar": "https://cdn.v2ex.com/avatar/161f/8f43/269803_large.png?m=1512382225"
      }, 
      "url": "https://www.v2ex.com/t/664577", 
      "date_modified": "2020-04-21T04:02:46+00:00", 
      "content_html": "<p><a href=\"https://pdos.csail.mit.edu/6.828/2018/labs/lab1/\" rel=\"nofollow\">https://pdos.csail.mit.edu/6.828/2018/labs/lab1/</a></p>\n<p>\u7248\u672c\uff1a</p>\n<ul>\n<li><code>qemu</code>\uff1aQEMU emulator version 1.5.3 (qemu-kvm-1.5.3-167.el7_7.4), Copyright (c) 2003-2008 Fabrice Bellard</li>\n<li><code>centos</code>\uff1aCentOS-7-x86_64-Minimal-1908</li>\n<li><code>gdb</code>\uff1aGNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7</li>\n</ul>\n<p><strong>The ROM BIOS</strong> \u8fd9\u4e2a\u7ae0\u8282\uff0cA \u7a97\u53e3 <code>make qemu-gdb</code>\uff0cB \u7a97\u53e3 <code>make gdb</code></p>\n<p>A\uff1a</p>\n<pre><code>/usr/libexec/qemu-kvm -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::25000 -D qemu.log  -S\nVNC server running on `::1:5900'\n</code></pre>\n<p>B <code>si</code> \u5355\u6b65\u8c03\u8bd5:</p>\n<pre><code>[f000:fff0]    0xffff0: ljmp   $0xf000,$0xe05b\n[f000:e05b]    0xfe05b: cmpl   $0x0,%cs:0x69c8\n[f000:e062]    0xfe062: jne    0xfd0f7\n[f000:e066]    0xfe066: xor    %dx,%dx\n[f000:e068]    0xfe068: mov    %dx,%ss\n[f000:e070]    0xfe070: mov    $0xf1399,%edx\n[f000:e076]    0xfe076: jmp    0xfcf8c\n[f000:cf8c]    0xfcf8c: cli\n[f000:cf8d]    0xfcf8d: cld\n[f000:cf8e]    0xfcf8e: mov    %eax,%ecx\n[f000:cf91]    0xfcf91: mov    $0x8f,%eax\n[f000:cf97]    0xfcf97: out    %al,$0x70\n[f000:cf9b]    0xfcf9b: in     $0x92,%al\n[f000:cf9d]    0xfcf9d: or     $0x2,%al\n[f000:cf9f]    0xfcf9f: out    %al,$0x92\n[f000:cfa4]    0xfcfa4: lidtw  %cs:0x69b8\n[f000:cfaa]    0xfcfaa: lgdtw  %cs:0x6974\n[f000:cfb0]    0xfcfb0: mov    %cr0,%ecx\n[f000:cfb3]    0xfcfb3: and    $0x1fffffff,%ecx\n[f000:cfba]    0xfcfba: or     $0x1,%ecx\n[f000:cfbe]    0xfcfbe: mov    %ecx,%cr0\n</code></pre>\n<p>\u5207\u5165 PE \u4e4b\u540e\uff1a</p>\n<pre><code>The target architecture is assumed to be i386\n=&gt; 0xfcfc9:     mov    $0x10,%ecx\n=&gt; 0xfcfce:     mov    %ecx,%ds\n=&gt; 0xfcfd0:     mov    %ecx,%es\n=&gt; 0xfcfd2:     mov    %ecx,%ss\n=&gt; 0xfcfd6:     mov    %ecx,%gs\n=&gt; 0xfcfd8:     jmp    *%edx\n=&gt; 0xf1399:     sub    $0x8,%esp\n=&gt; 0xf139c:     movl   $0xf4254,0x4(%esp)\n=&gt; 0xf13a4:     movl   $0xf390a,(%esp)\n=&gt; 0xf13ab:     call   0xee4dd\n=&gt; 0xee4dd:     lea    0x8(%esp),%ecx\n=&gt; 0xee4e1:     mov    0x4(%esp),%edx\n=&gt; 0xee4e5:     mov    $0xf4200,%eax\n=&gt; 0xee4ea:     call   0xedd5a\n=&gt; 0xedd5a:     push   %ebp\n=&gt; 0xedd5b:     push   %edi\n=&gt; 0xedd5c:     push   %esi\n=&gt; 0xedd5d:     push   %ebx\n=&gt; 0xedd5e:     sub    $0xc,%esp\n=&gt; 0xedd61:     mov    %eax,%ebx\n=&gt; 0xedd63:     mov    %edx,0x4(%esp)\n=&gt; 0xedd67:     mov    %ecx,%ebp\n=&gt; 0xedd69:     mov    0x4(%esp),%esi\n=&gt; 0xedd6d:     movsbl (%esi),%edx\n=&gt; 0xedd70:     test   %dl,%dl\n=&gt; 0xedd72:     je     0xedfb6\n=&gt; 0xedd78:     cmp    $0x25,%dl\n=&gt; 0xedd7b:     jne    0xede1b\n=&gt; 0xede1b:     mov    %ebx,%eax\n=&gt; 0xede1d:     call   0xec570\n=&gt; 0xec570:     mov    %eax,%ecx\n=&gt; 0xec572:     movsbl %dl,%edx\n=&gt; 0xec575:     call   *(%ecx)\n=&gt; 0xec565:     mov    %edx,%eax\n=&gt; 0xec567:     mov    0xf683c,%dx\n=&gt; 0xec56e:     out    %al,(%dx)\n=&gt; 0xec577:     ret\n\n=&gt; 0xede22:     jmp    0xedfaa\n=&gt; 0xedfaa:     lea    0x1(%esi),%eax\n=&gt; 0xedfad:     mov    %eax,0x4(%esp)\n=&gt; 0xedfb1:     jmp    0xedd69\n=&gt; 0xedd69:     mov    0x4(%esp),%esi\n=&gt; 0xedd6d:     movsbl (%esi),%edx\n=&gt; 0xedd70:     test   %dl,%dl\n=&gt; 0xedd72:     je     0xedfb6\n=&gt; 0xedd78:     cmp    $0x25,%dl\n=&gt; 0xedd7b:     jne    0xede1b\n=&gt; 0xede1b:     mov    %ebx,%eax\n=&gt; 0xede1d:     call   0xec570\n=&gt; 0xec570:     mov    %eax,%ecx\n=&gt; 0xec572:     movsbl %dl,%edx\n=&gt; 0xec575:     call   *(%ecx)\n=&gt; 0xec565:     mov    %edx,%eax\n=&gt; 0xec567:     mov    0xf683c,%dx\n=&gt; 0xec56e:     out    %al,(%dx)\n=&gt; 0xec577:     ret\n...\n</code></pre>\n<p>\u4e2d\u95f4\u9694\u5f00\u7684\u90a3\u4e00\u6bb5\u4e00\u76f4\u5230 <code>...</code> \u5c31\u662f\u6b7b\u5faa\u73af\uff0c\u4f46\u662f\u5982\u679c\u8fd9\u4e2a\u65f6\u5019 <code>c</code> continue \u7684\u8bdd A \u53c8\u53ef\u4ee5\u8fdb kernel\uff0c\u800c\u4e14\u8bd5\u4e86\u65ad\u70b9\uff0c\u5e76\u6ca1\u6709\u8fdb <code>0x7c00</code>\u3002</p>\n<p>\u627e\u5230\u4e00\u7bc7\uff1a<a href=\"https://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642\" rel=\"nofollow\">https://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642</a>\uff0c\u628a A \u7a97\u53e3\u6362\u6210\u76f4\u63a5\u6267\u884c\uff1a</p>\n<pre><code>/usr/libexec/qemu-kvm -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -D qemu.log -S -s\n</code></pre>\n<p>\u5176\u5b9e\u5c31\u662f\u6362\u4e86 gdb TCP 1234 \u7aef\u53e3\uff0c\u7136\u540e\u6309\u7167 stackoverflow \u4e0a\u5728 B \u8fde 1234\uff1a</p>\n<pre><code>target remote localhost:1234\n</code></pre>\n<p>\u6700\u7ec8 <code>si</code> \u8fd8\u662f\u8fdb\u4e86\u6b7b\u5faa\u73af... \u53e6\u5916\u8bd5\u4e86 <code>-bios</code> \u53c2\u6570\uff0c\u4e5f\u786e\u5b9e\u662f\u4f7f\u7528\u7684 <code>seabios.bin</code>\u3002</p>\n<p>\u5df2\u7ecf\u67e5\u4e0d\u52a8\u4e86\uff0c\u6c42\u5927\u4f6c\u89e3\u7b54~</p>\n", 
      "date_published": "2020-04-21T03:59:06+00:00", 
      "title": "6.828 lab1 Exercise 2 \u6b7b\u5faa\u73af\u95ee\u9898", 
      "id": "https://www.v2ex.com/t/664577"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/Nullplus", 
        "name": "Nullplus", 
        "avatar": "https://cdn.v2ex.com/gravatar/d410526612e0aa7408e2bb05799cbd33?s=73&d=retro"
      }, 
      "url": "https://www.v2ex.com/t/638896", 
      "title": "\u5982\u4f55\u89e3\u51b3 ShellCode \u4e2d call \u6240\u4ea7\u751f\u7684 \\x00", 
      "id": "https://www.v2ex.com/t/638896", 
      "date_published": "2020-01-17T21:48:45+00:00", 
      "content_html": "<p>\u5404\u4f4d\u5927\u4f6c\u597d\uff0c\u60f3\u95ee\u4e00\u4e2a\u5173\u4e8e\u6c47\u7f16\u548c ShellCode \u4e2d\u96f6\u5b57\u8282\u7684\u95ee\u9898\u3002</p>\n<p>\u5728\u5b66\u4e60\u7f13\u51b2\u6ea2\u51fa\u65f6\uff0c\u6211\u6839\u636e\u8981\u6c42\u5199\u4e86\u4e00\u6bb5\u53d6\u5f97\u7a0b\u5e8f PID \u7684\u6c47\u7f16\u6765\u6784\u9020 ShellCode\uff0c\u5176\u4e2d\u4e00\u6bb5\u8c03\u7528\u4e86 C \u4e2d\u7684 printf \u6765\u8f93\u51fa\u7ed3\u679c\uff1a</p>\n<pre><code class=\"language-assembly\">lea    rdi, [rel message]\nmov    rsi, rax\ncall   printf\n</code></pre>\n<p>\u53cd\u6c47\u7f16\u540e\u7684\u7ed3\u679c\u5982\u4e0b\uff1a</p>\n<pre><code class=\"language-assembly\">  13:\t48 8d 3d e8 ff ff ff \tlea    -0x18(%rip),%rdi        # 2 &lt;message&gt;\n  1a:\t48 89 c6             \tmov    %rax,%rsi\n  1d:\te8 00 00 00 00       \tcallq  22 &lt;code+0x19&gt;\n</code></pre>\n<p>\u5982\u4e0a\u9762\u4ee3\u7801\u7b2c\u4e09\u884c\u6240\u793a\uff0copcode \u51fa\u73b0\u4e86 <code>\\x00</code>\uff0c \u6211\u641c\u7d22\u4e86\u4e00\u5708\u90fd\u6ca1\u6709\u5408\u9002\u7684\u80fd\u628a <code>\\x00</code> \u66ff\u6362\u6389\u7684\u65b9\u6848\uff0c\u4e8e\u662f\u60f3\u6765 V \u7ad9\u95ee\u95ee\u5404\u4f4d\u5927\u4f6c\u4eec\uff5e</p>\n"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/Livid", 
        "name": "Livid", 
        "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1776858751"
      }, 
      "url": "https://www.v2ex.com/t/98928", 
      "title": "\u7528 AMD64 \u6c47\u7f16\u5199\u7684 web server", 
      "id": "https://www.v2ex.com/t/98928", 
      "date_published": "2014-02-03T12:07:37+00:00", 
      "content_html": "<a href=\"https://github.com/nemasu/asmttpd\" rel=\"nofollow\">https://github.com/nemasu/asmttpd</a>"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/keys", 
        "name": "keys", 
        "avatar": "https://cdn.v2ex.com/avatar/68bc/cf16/21721_large.png?m=1675995055"
      }, 
      "url": "https://www.v2ex.com/t/50324", 
      "date_modified": "2012-10-18T11:38:24+00:00", 
      "content_html": "", 
      "date_published": "2012-10-18T08:41:09+00:00", 
      "title": "\u6765\u505a\u4e2a\u8c03\u67e5\uff0c\u5404\u4f4dV2exer \u6709\u591a\u5c11\u5b66\u8fc7\u6c47\u7f16\uff1f\u6709\u7528\u8fc7\u5426\uff1f", 
      "id": "https://www.v2ex.com/t/50324"
    }, 
    {
      "author": {
        "url": "https://www.v2ex.com/member/Livid", 
        "name": "Livid", 
        "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1776858751"
      }, 
      "url": "https://www.v2ex.com/t/2303", 
      "date_modified": "2012-04-21T14:50:22+00:00", 
      "content_html": "<a href=\"http://asm.sourceforge.net/intro/Assembly-Intro.html\" rel=\"nofollow\">http://asm.sourceforge.net/intro/Assembly-Intro.html</a>", 
      "date_published": "2010-09-05T08:57:40+00:00", 
      "title": "Introduction to UNIX Assembly Programming", 
      "id": "https://www.v2ex.com/t/2303"
    }
  ]
}