{"id":6361,"date":"2017-02-22T23:52:31","date_gmt":"2017-02-22T14:52:31","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6361"},"modified":"2017-02-23T19:18:42","modified_gmt":"2017-02-23T10:18:42","slug":"mac-intel-mac-%e3%81%ae%e3%82%a2%e3%82%bb%e3%83%b3%e3%83%96%e3%83%a9%e3%81%a7%e3%81%af-align-%e3%81%af-p2align-%e3%81%ae%e6%84%8f%e5%91%b3%e3%81%a7%e3%81%82%e3%82%8b","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6361","title":{"rendered":"Mac (Intel Mac) \u306e\u30a2\u30bb\u30f3\u30d6\u30e9\u3067\u306f .align \u306f .p2align \u306e\u610f\u5473\u3067\u3042\u308b"},"content":{"rendered":"<p>\u4e3b\u8a9e\u3092\u5927\u304d\u304f\u53d6\u308a\u3059\u304e\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\uff08\u5b9f\u969b\u306b\u78ba\u8a8d\u3057\u305f\u306e\u306f\u300cMac \u306e i386\/x86_64 \u3092\u30bf\u30fc\u30b2\u30c3\u30c8\u3068\u3059\u308b\u3001Xcode \u306b\u542b\u307e\u308c\u3066\u3044\u308b Clang \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u300d\u3060\u3051\uff09\u306e\u3067\u3059\u304c\u3001\u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\u901a\u308a\u306e\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>Linux \u306e i386\/x86_64 \u3084 Windows \u306e x86\/x64 \u3092\u30bf\u30fc\u30b2\u30c3\u30c8\u3068\u3059\u308b\u5834\u5408\u306f GCC (GAS) \u3067\u3082 Clang \u3067\u3082 <code>.align<\/code> \u306f <code>.balign<\/code> \u306e\u610f\u5473\u3001\u3064\u307e\u308a\u5f15\u6570\u306f\u30d0\u30a4\u30c8\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u4e00\u65b9\u3001Mac \u306e\u5834\u5408\u306f <code>.p2align<\/code> \u306e\u610f\u5473\u3001\u3064\u307e\u308a2\u3092\u6307\u5b9a\u3057\u305f\u6570\u3067\u7d2f\u4e57\u3057\u305f\u30d0\u30a4\u30c8\u6570\u3067\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3055\u308c\u307e\u3059\u3002\u306a\u306e\u3067\u300164 \u30d0\u30a4\u30c8\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u306b\u3059\u308b\u3064\u3082\u308a\u3067 <code>.align 64<\/code> \u3068\u304b\u66f8\u304f\u306816\u30a8\u30af\u30b5\u30d0\u30a4\u30c8\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3068\u898b\u306a\u3055\u308c\u3066\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092 x86_64 \u5411\u3051\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\nint main(void)\r\n{\r\n        int ret;\r\n        asm volatile (\r\n                \".align 4\\n\"\r\n                \"incl %%eax\\n\"\r\n                \".align 4\\n\"\r\n        : \"=a\"(ret));\r\n        return ret;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>Linux \u3060\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u30014\u30d0\u30a4\u30c8\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\n[umezawa@devcent7:pts\/0 ~]$ clang -o asmalign asmalign.c\r\n[umezawa@devcent7:pts\/0 ~]$ gdb asmalign\r\nGNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\r\nand \"show warranty\" for details.\r\nThis GDB was configured as \"x86_64-redhat-linux-gnu\".\r\nFor bug reporting instructions, please see:\r\n<http: \/\/www.gnu.org\/software\/gdb\/bugs><\/http:>...\r\nReading symbols from \/home\/umezawa\/asmalign...(no debugging symbols found)...done.\r\n(gdb) disassemble main\r\nDump of assembler code for function main:\r\n   0x00000000004004f0 &lt;+0&gt;:     push   %rbp\r\n   0x00000000004004f1 &lt;+1&gt;:     mov    %rsp,%rbp\r\n   0x00000000004004f4 &lt;+4&gt;:     movl   $0x0,-0x4(%rbp)\r\n   0x00000000004004fb &lt;+11&gt;:    nop\r\n   0x00000000004004fc &lt;+12&gt;:    inc    %eax            # \u3053\u3053\r\n   0x00000000004004fe &lt;+14&gt;:    xchg   %ax,%ax\r\n   0x0000000000400500 &lt;+16&gt;:    mov    %eax,-0x8(%rbp) # \u3053\u3053\r\n   0x0000000000400503 &lt;+19&gt;:    mov    -0x8(%rbp),%eax\r\n   0x0000000000400506 &lt;+22&gt;:    pop    %rbp\r\n   0x0000000000400507 &lt;+23&gt;:    retq\r\nEnd of assembler dump.\r\n<\/pre>\n<\/blockquote>\n<p>Mac \u3060\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u300116\u30d0\u30a4\u30c8\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\n[umezawa@metis:ttys000 ~]$ clang -o asmalign asmalign.c\r\n[umezawa@metis:ttys000 ~]$ lldb asmalign\r\n(lldb) target create \"asmalign\"\r\nCurrent executable set to 'asmalign' (x86_64).\r\n(lldb) disassemble --name main\r\nasmalign`main:\r\nasmalign[0x100000f90] &lt;+0&gt;:  pushq  %rbp\r\nasmalign[0x100000f91] &lt;+1&gt;:  movq   %rsp, %rbp\r\nasmalign[0x100000f94] &lt;+4&gt;:  movl   $0x0, -0x4(%rbp)\r\nasmalign[0x100000f9b] &lt;+11&gt;: nopl   (%rax,%rax)\r\nasmalign[0x100000fa0] &lt;+16&gt;: incl   %eax             # \u3053\u3053\r\nasmalign[0x100000fa2] &lt;+18&gt;: nopw   %cs:(%rax,%rax)\r\nasmalign[0x100000fb0] &lt;+32&gt;: movl   %eax, -0x8(%rbp) # \u3053\u3053\r\nasmalign[0x100000fb3] &lt;+35&gt;: movl   -0x8(%rbp), %eax\r\nasmalign[0x100000fb6] &lt;+38&gt;: popq   %rbp\r\nasmalign[0x100000fb7] &lt;+39&gt;: retq\r\n<\/pre>\n<\/blockquote>\n<p>\u79c1\u306f\u30d0\u30a4\u30c8\u6570\u6307\u5b9a\u3067\u6163\u308c\u3066\u3044\u308b\u306e\u3067 <code>.balign<\/code> \u306b\u7f6e\u304d\u63db\u3048\u308c\u3070\u305d\u308c\u3067\u6e08\u3080\u3053\u3068\u306a\u3093\u3067\u3059\u304c\u3001\u306a\u3093\u3067\u3053\u3093\u306a\u3053\u3068\u306b\u306a\u3063\u3066\u308b\u3093\u3067\u3057\u3087\u3046\u3002 PowerPC \u6642\u4ee3\u304b\u3089\u306e\u4f1d\u7d71\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8a9e\u3092\u5927\u304d\u304f\u53d6\u308a\u3059\u304e\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\uff08\u5b9f\u969b\u306b\u78ba\u8a8d\u3057\u305f\u306e\u306f\u300cMac \u306e i386\/x86_64 \u3092\u30bf\u30fc\u30b2\u30c3\u30c8\u3068\u3059\u308b\u3001Xcode \u306b\u542b\u307e\u308c\u3066\u3044\u308b Clang \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u300d\u3060\u3051\uff09\u306e\u3067\u3059\u304c\u3001\u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\u901a\u308a\u306e\u3053\u3068\u306b [&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-6361","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\/6361","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=6361"}],"version-history":[{"count":14,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6361\/revisions"}],"predecessor-version":[{"id":6376,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6361\/revisions\/6376"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6361"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}