{"id":6378,"date":"2017-02-23T23:59:30","date_gmt":"2017-02-23T14:59:30","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6378"},"modified":"2017-02-24T00:52:49","modified_gmt":"2017-02-23T15:52:49","slug":"gcc-%e3%81%ae%e3%82%a4%e3%83%b3%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%a2%e3%82%bb%e3%83%b3%e3%83%96%e3%83%a9%e3%81%a7%e5%85%a5%e5%8a%9b%e3%83%ac%e3%82%b8%e3%82%b9%e3%82%bf%e3%81%8c%e7%a0%b4%e5%a3%8a","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6378","title":{"rendered":"GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3067\u5165\u529b\u30ec\u30b8\u30b9\u30bf\u304c\u7834\u58ca\u3055\u308c\u308b\u3053\u3068\u3092\u6307\u5b9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3067\u306f\u51fa\u529b (output operands) \u30ea\u30b9\u30c8\u3001\u5165\u529b (input operands) \u30ea\u30b9\u30c8\u306e\u4ed6\u306b\u3001\u30a2\u30bb\u30f3\u30d6\u30e9\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u3069\u306e\u30ec\u30b8\u30b9\u30bf\u304c\u7834\u58ca\u3055\u308c\u308b\u304b\uff08\u3064\u307e\u308a\u3001\u3069\u306e\u30ec\u30b8\u30b9\u30bf\u3092\u30b3\u30f3\u30d1\u30a4\u30e9\u5074\u3067\u5fa9\u5143\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u304b\uff09\u3092\u6307\u5b9a\u3059\u308b <a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Extended-Asm.html#Clobbers\">\u7834\u58ca (clobber) \u30ea\u30b9\u30c8<\/a>\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u3053\u3053\u3067\u3001\u7834\u58ca\u30ea\u30b9\u30c8\u306b\u6307\u5b9a\u3067\u304d\u308b\u30ec\u30b8\u30b9\u30bf\u306f\u51fa\u529b\u30ea\u30b9\u30c8\u306b\u3082\u5165\u529b\u30ea\u30b9\u30c8\u306b\u3082\u51fa\u73fe\u3057\u3066\u306f\u3044\u3051\u306a\u3044\u3001\u3068\u3044\u3046\u4ed5\u69d8\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u51fa\u529b\u30ea\u30b9\u30c8\u306b\u51fa\u73fe\u3057\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u306f\u5206\u304b\u308b\uff08\u6a5f\u80fd\u7684\u306b\u6392\u4ed6\u306a\u306e\u3067\uff09\u306e\u3067\u3059\u304c\u3001\u5165\u529b\u30ea\u30b9\u30c8\u306b\u51fa\u73fe\u3057\u3066\u306f\u3044\u3051\u306a\u3044\u3068\u3044\u3046\u5236\u7d04\u306f\u4e0d\u4fbf\u3067\u3059\u3002\u305d\u306e\u307e\u307e\u3067\u306f\u30a2\u30bb\u30f3\u30d6\u30e9\u30d6\u30ed\u30c3\u30af\u5074\u3067\u5bfe\u51e6\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3069\u3046\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30ea\u30f3\u30af\u5148\u3092\u3088\u304f\u8aad\u3080\u3068\u5206\u304b\u308a\u307e\u3059\u304c\u3001\u51fa\u529b\u30ea\u30b9\u30c8\u306b\u3082\u6307\u5b9a\u3057\u3066\u3057\u307e\u3048\u3070\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u306f2\u3064\u306easm\u6587\u3067 eax \u306b\u540c\u3058\u5024 (10) \u3092\u6e21\u3059\u3088\u3046\u306b\u6307\u793a\u3057\u3066\u304a\u308a\u3001\u3055\u3089\u306b1\u3064\u76ee\u306easm\u6587\u3067\u306f\u51fa\u529b\u30ea\u30b9\u30c8\u3082\u7834\u58ca\u30ea\u30b9\u30c8\u3082\u7a7a\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u6700\u9069\u5316\u3092\u304b\u3051\u305f\u5834\u5408\u306f2\u3064\u76ee\u306easm\u6587\u306e\u3068\u3053\u308d\u3067 eax \u306b 10 \u3092\u4fdd\u5b58\u3059\u308b\u547d\u4ee4\u3092\u7701\u7565\u3057\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f1\u3064\u76ee\u306e\u30a2\u30bb\u30f3\u30d6\u30ea\u30d6\u30ed\u30c3\u30af\u3067 eax \u306e\u5024\u306f\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u671f\u5f85\u3055\u308c\u308b\u7d50\u679c (11) \u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<blockquote>\n<pre>\r\n[umezawa@devcent7:pts\/0 ~]$ cat clobber.c\r\nint main(void)\r\n{\r\n        int ret;\r\n\r\n        asm volatile(\r\n                \"incl %%eax\\n\\t\"\r\n        :\r\n        : \"a\"(10));\r\n\r\n        asm volatile(\r\n                \"incl %%eax\\n\\t\"\r\n        : \"=a\"(ret)\r\n        : \"a\"(10));\r\n\r\n        return ret;\r\n}\r\n[umezawa@devcent7:pts\/0 ~]$ gcc -S -o- -O2 clobber.c\r\n        .file   \"clobber.c\"\r\n        .section        .text.startup,\"ax\",@progbits\r\n        .p2align 4,,15\r\n        .globl  main\r\n        .type   main, @function\r\nmain:\r\n.LFB0:\r\n        .cfi_startproc\r\n        movl    $10, %eax\r\n#APP\r\n# 5 \"clobber.c\" 1\r\n        incl %eax\r\n\r\n# 0 \"\" 2\r\n# 10 \"clobber.c\" 1\r\n        incl %eax\r\n\r\n# 0 \"\" 2\r\n#NO_APP\r\n        ret\r\n        .cfi_endproc\r\n.LFE0:\r\n        .size   main, .-main\r\n        .ident  \"GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-11)\"\r\n        .section        .note.GNU-stack,\"\",@progbits\r\n<\/pre>\n<\/blockquote>\n<p>\u4e00\u65b9\u30011\u3064\u76ee\u306easm\u6587\u3067\u51fa\u529b\u30ea\u30b9\u30c8\u306b eax \u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u6697\u9ed9\u7684\u306b eax \u306f\u30a2\u30bb\u30f3\u30d6\u30ea\u30d6\u30ed\u30c3\u30af\u5185\u3067\u5909\u66f4\u3055\u308c\u308b\u3068\u898b\u306a\u3055\u308c\u30012\u3064\u76ee\u306easm\u6587\u306e\u524d\u306b\u6539\u3081\u3066 eax \u306b\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30ec\u30b8\u30b9\u30bf\u304b\u3089\u5909\u6570\u306b\u79fb\u52d5\u3059\u308b\u51e6\u7406\u304c\u7121\u99c4\u306e\u3088\u3046\u306b\u601d\u3048\u307e\u3059\u304c\u3001\u5f8c\u3067\u5909\u6570\u3092\u4f7f\u308f\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u6700\u9069\u5316\u3092\u304b\u3051\u308b\u3068\u305d\u306e\u51e6\u7406\u306f\u6d88\u6ec5\u3059\u308b\u306e\u3067\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<blockquote>\n<pre>\r\n[umezawa@devcent7:pts\/0 ~]$ cat clobber.c\r\nint main(void)\r\n{\r\n        int ret;\r\n        void* clobber;\r\n\r\n        asm volatile(\r\n                \"incl %%eax\\n\\t\"\r\n        : \"=a\"(clobber)\r\n        : \"a\"(10));\r\n\r\n        asm volatile(\r\n                \"incl %%eax\\n\\t\"\r\n        : \"=a\"(ret)\r\n        : \"a\"(10));\r\n\r\n        return ret;\r\n}\r\n[umezawa@devcent7:pts\/0 ~]$ gcc -S -o- -O2 clobber.c\r\n        .file   \"clobber.c\"\r\n        .section        .text.startup,\"ax\",@progbits\r\n        .p2align 4,,15\r\n        .globl  main\r\n        .type   main, @function\r\nmain:\r\n.LFB0:\r\n        .cfi_startproc\r\n        movl    $10, %edx\r\n        movl    %edx, %eax\r\n#APP\r\n# 6 \"clobber.c\" 1\r\n        incl %eax\r\n\r\n# 0 \"\" 2\r\n#NO_APP\r\n        movl    %edx, %eax\r\n#APP\r\n# 11 \"clobber.c\" 1\r\n        incl %eax\r\n\r\n# 0 \"\" 2\r\n#NO_APP\r\n        ret\r\n        .cfi_endproc\r\n.LFE0:\r\n        .size   main, .-main\r\n        .ident  \"GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-11)\"\r\n        .section        .note.GNU-stack,\"\",@progbits\r\n<\/pre>\n<\/blockquote>\n<p>\u3061\u306a\u307f\u306b\u3001\u51fa\u529b\u5148\u306e\u5909\u6570\u3092\u8907\u6570\u306e\u30ec\u30b8\u30b9\u30bf\u3067\u5171\u7528\u3057\u3066\u3082\u7279\u306b\u30a8\u30e9\u30fc\u306f\u51fa\u307e\u305b\u3093\u3002\uff08\u3044\u3044\u306e\u304b\uff1f\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GCC \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3067\u306f\u51fa\u529b (output operands) \u30ea\u30b9\u30c8\u3001\u5165\u529b (input operands) \u30ea\u30b9\u30c8\u306e\u4ed6\u306b\u3001\u30a2\u30bb\u30f3\u30d6\u30e9\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u3069\u306e\u30ec\u30b8\u30b9\u30bf\u304c\u7834\u58ca\u3055\u308c\u308b\u304b\uff08\u3064\u307e\u308a\u3001\u3069\u306e\u30ec\u30b8\u30b9\u30bf\u3092\u30b3\u30f3\u30d1\u30a4 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-6378","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6378"}],"version-history":[{"count":3,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6378\/revisions"}],"predecessor-version":[{"id":6381,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6378\/revisions\/6381"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6378"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}