{"id":6460,"date":"2017-04-13T18:10:04","date_gmt":"2017-04-13T09:10:04","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6460"},"modified":"2017-04-13T18:10:04","modified_gmt":"2017-04-13T09:10:04","slug":"clang-%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%e3%81%af-equ-%e3%83%87%e3%82%a3%e3%83%ac%e3%82%af%e3%83%86%e3%82%a3%e3%83%96","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6460","title":{"rendered":"Clang \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3067\u306f .equ \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306e\u6271\u3044\u304c GCC \u3068\u7570\u306a\u308b"},"content":{"rendered":"<p>\u5f0f\u306e\u7f6e\u304d\u63db\u3048\u3092\u884c\u3046 <code>.equ<\/code> \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306e\u6271\u3044\u304c\u7570\u306a\u308b\u3053\u3068\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>\r\nint main(void)\r\n{\r\n    int ret;\r\n    asm volatile(\r\n        \".intel_syntax noprefix\\n\"\r\n        \".equ hoge, eax\\n\"\r\n        \"mov hoge, 42\\n\"\r\n    : \"=a\"(ret));\r\n    return ret;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>\u3053\u308c\u3092 GCC \u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001<code>mov hoge, 42<\/code> \u306f <code>mov eax, 42<\/code> \u306b\u7f6e\u304d\u63db\u308f\u308a\u3001eax \u30ec\u30b8\u30b9\u30bf\u306b 42 \u3092 mov \u3059\u308b\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e00\u65b9\u3001Clang \u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001eax \u306f\u30ec\u30b8\u30b9\u30bf\u3067\u306f\u306a\u304f\u5909\u6570\uff08\u30e1\u30e2\u30ea\u306e\u4f4d\u7f6e\uff09\u3060\u3068\u89e3\u91c8\u3055\u308c\u3001<code>mov dword ptr [eax\u3068\u3044\u3046\u5909\u6570\u306e\u30a2\u30c9\u30ec\u30b9], 42<\/code> \u306b\u7f6e\u304d\u63db\u308f\u308a\u307e\u3059\uff0864bit \u74b0\u5883\u306a\u3089 <code>qword ptr<\/code> \u306b\u306a\u308b\uff09\u3002\u305d\u3093\u306a\u5909\u6570\u306f\u7121\u3044\u306e\u3067\u30ea\u30f3\u30af\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u308c\u306f Clang \u306e\u65b9\u304c\u9069\u5207\u306a\u52d5\u4f5c\u306e\u3088\u3046\u306b\u3082\u601d\u3048\u307e\u3059\u3002\u306a\u305c\u306a\u3089\u30ec\u30b8\u30b9\u30bf\u3068\u3057\u3066\u306e eax \u306f\u30a2\u30bb\u30f3\u30d6\u30ea\u8a00\u8a9e\u306b\u304a\u3051\u308b\u5f0f (expression) \u3067\u306f\u306a\u3044\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u4ee3\u308f\u308a\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3060\u3068\u3069\u3061\u3089\u3067\u3082 OK \u3067\u3059\u3002 <code>.irp<\/code> \u3067\u306f\u30de\u30af\u30ed\u5c55\u958b\u3068\u540c\u3058\u304f\u6587\u5b57\u5217\u3068\u3057\u3066\u7f6e\u304d\u63db\u3048\u3092\u884c\u3046\u304b\u3089\u3067\u3059\u3002<\/p>\n<blockquote>\n<pre>\r\nint main(void)\r\n{\r\n    int ret;\r\n    asm volatile(\r\n        \".intel_syntax noprefix\\n\"\r\n        \".irp hoge, eax\\n\"\r\n        \"mov \\hoge, 42\\n\"\r\n        \".endr\\n\"\r\n    : \"=a\"(ret));\r\n    return ret;\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>\u305f\u3060\u3001 <code>.irp<\/code> \u306b\u306f\u5bfe\u5fdc\u3059\u308b <code>.endr<\/code> \u304c\u5fc5\u8981\u3067\u3042\u308b\u305f\u3081\u3001\u8907\u6570\u500b\u5b9a\u7fa9\u3059\u308b\u3068 <code>.endr<\/code> \u304c\u305f\u304f\u3055\u3093\u51fa\u3066\u304d\u3066\u898b\u305f\u76ee\u304c\u6b8b\u5ff5\u306a\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f0f\u306e\u7f6e\u304d\u63db\u3048\u3092\u884c\u3046 .equ \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306e\u6271\u3044\u304c\u7570\u306a\u308b\u3053\u3068\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/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-6460","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\/6460","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=6460"}],"version-history":[{"count":3,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6460\/revisions"}],"predecessor-version":[{"id":6463,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6460\/revisions\/6463"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6460"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}