{"id":449,"date":"2018-04-16T10:00:00","date_gmt":"2018-04-16T01:00:00","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2018\/04\/16\/introduce-assembly"},"modified":"2018-04-16T10:00:00","modified_gmt":"2018-04-16T01:00:00","slug":"introduce-assembly","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2018\/04\/16\/introduce-assembly\/","title":{"rendered":"\u30a2\u30bb\u30f3\u30d6\u30ea\u8a00\u8a9e\u306b\u5165\u9580\u3057\u3088\u3046"},"content":{"rendered":"

MMM\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u67f3\u6cbc\u3067\u3059\u3002
\n\u3044\u3088\u3044\u3088\u4eca\u9031\u306fJapan Container Days\u3067\u3059\u306d!!<\/p>\n

\u4eca\u56de\u306f\u3001Hello World\u3092\u51fa\u529b\u3057\u3066\u307f\u308b\u3053\u3068\u3067\u3001
\n\u30a2\u30bb\u30f3\u30d6\u30ea\u8a00\u8a9e\u306e\u57fa\u790e\u3092\u5b66\u3093\u3067\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u74b0\u5883<\/h1>\n

\u4eca\u56de\u306f\u30a2\u30bb\u30f3\u30d6\u30e9\u306bnasm\u3092\u63a1\u7528\u3057\u307e\u3059\u3002
\n\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.0.0\u4ee5\u4e0a\u3067\u3042\u308b\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/p>\n

\u7b46\u8005\u306e\u74b0\u5883\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n

$ nasm --version\nNASM version 2.13.01 compiled on Feb 28 2018<\/code><\/pre>\n

\u307e\u305f\u3001\u7b46\u8005\u306e\u30de\u30b7\u30f3\u306eCPU\u60c5\u5831\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002(4\u30b3\u30a2\u306a\u305f\u30814\u884c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002)<\/p>\n

$ cat \/proc\/cpuinfo | grep 'model name'\nmodel name      : Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz\nmodel name      : Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz\nmodel name      : Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz\nmodel name      : Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz<\/code><\/pre>\n

Linux\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u306fGentoo\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002(darwin\u3067\u3082\u305f\u3076\u3093\u3067\u304d\u308b\u3068\u601d\u3046\u306e\u3067\u9811\u5f35\u3063\u3066\u304f\u3060\u3055\u3044\u3002)
\n\u30c7\u30a3\u30b9\u30c8\u30ea\u53ca\u3073\u30ab\u30fc\u30cd\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n

$ cat \/etc\/gentoo-release\nGentoo Base System release 2.4.1\n\n$ uname -r\n4.14.8-gentoo-r1<\/code><\/pre>\n

\u30bb\u30af\u30b7\u30e7\u30f3<\/h2>\n

\u672c\u30a8\u30f3\u30c8\u30ea\u3067\u306f\u30a2\u30bb\u30f3\u30d6\u30ea\u306e\u5168\u3066\u306e\u6587\u6cd5\u306b\u306f\u89e6\u308c\u307e\u305b\u3093\u3002
\n\u3068\u308a\u3042\u3048\u305aHello World\u306e\u51fa\u529b\u306b\u5fc5\u8981\u306a\u77e5\u8b58\u306b\u7d5e\u3063\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306f\u3001 \u30c7\u30fc\u30bf\u30bb\u30af\u30b7\u30e7\u30f3<\/code> \u3068 \u30c6\u30ad\u30b9\u30c8\u30bb\u30af\u30b7\u30e7\u30f3<\/code> \u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n

\u30c7\u30fc\u30bf\u30bb\u30af\u30b7\u30e7\u30f3<\/h3>\n

\u30c7\u30fc\u30bf\u30bb\u30af\u30b7\u30e7\u30f3\u306f\u3001\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u66f8\u304d\u65b9\u3092\u3057\u307e\u3059\u3002<\/p>\n

section .data\n    msg db      "Hello world!"<\/code><\/pre>\n

msg<\/code> \u306f\u5909\u6570\u540d\u3001 "Hello world!"<\/code> \u304c\u30c7\u30fc\u30bf\u3067\u3059\u3002
\ndb<\/code> \u306f\u30011\u30d0\u30a4\u30c8\u5206\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002(dw<\/code>\u306f2\u30d0\u30a4\u30c8\u3001dd<\/code>\u306f4\u30d0\u30a4\u30c8)<\/p>\n

\u3064\u307e\u308a\u3001\u4e0a\u8a18\u306f<\/p>\n

char msg[] = "Hello, world!"<\/code><\/pre>\n

\u3068\u540c\u3058\u3088\u3046\u306a\u3053\u3068\u3067\u3059\u3002<\/p>\n

\u30c6\u30ad\u30b9\u30c8\u30bb\u30af\u30b7\u30e7\u30f3<\/h3>\n

\u30c6\u30ad\u30b9\u30c8\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u306f\u3001\u5b9f\u969b\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002
\n\u30c6\u30ad\u30b9\u30c8\u30bb\u30af\u30b7\u30e7\u30f3\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u958b\u59cb\u3057\u307e\u3059\u3002<\/p>\n

section .text\n    global _start<\/code><\/pre>\n

global _start<\/code> \u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002
\n_start<\/code> \u306f\u30e9\u30d9\u30eb(\u95a2\u6570\u306e\u958b\u59cb\u4f4d\u7f6e\u307f\u305f\u3044\u306a\u3082\u306e)\u3068\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n

\u51e6\u7406\u306e\u6587\u6cd5\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n

[label:] instruction [operands] [; comment]<\/code><\/pre>\n

\u4f8b\u3048\u3070\u3001<\/p>\n

mov     rax, 1<\/code><\/pre>\n

\u3068\u66f8\u3051\u3070\u3001 rax<\/code> \u30ec\u30b8\u30b9\u30bf\u306b 1<\/code> \u3092\u30bb\u30c3\u30c8\u3059\u308b\u3001\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

\u30ec\u30b8\u30b9\u30bf<\/h3>\n

\u30ec\u30b8\u30b9\u30bf\u3068\u306f\u8981\u3059\u308b\u306b\u8a18\u61b6\u9818\u57df\u3067\u3059\u3002
\n\u30e1\u30e2\u30ea\u306e\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002
\n\u30e1\u30e2\u30ea\u3088\u308a\u3082\u9ad8\u901f\u306b\u52d5\u4f5c\u3057\u3001CPU\u306e\u4e0a(\u7269\u7406)\u306b\u3042\u308a\u307e\u3059\u3002
\n\u672c\u30a8\u30f3\u30c8\u30ea\u3067\u767b\u5834\u3059\u308b\u30ec\u30b8\u30b9\u30bf\u306f\u3001x64\u74b0\u5883\u306e\u3082\u306e\u3067\u3042\u308b\u3053\u3068\u306b\u7559\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002(x86\u3068\u304b\u3060\u3068\u540d\u524d\u304c\u9055\u3044\u307e\u3059\u3002)<\/p>\n

\u30ec\u30b8\u30b9\u30bf\u306f(\u7269\u7406\u7684\u306b)\u8907\u6570\u5b58\u5728\u3057\u3066\u304a\u308a\u3001\u305d\u308c\u305e\u308c\u540d\u524d\u304c\u3064\u3044\u3066\u3044\u307e\u3059\u3002
\n\u4eca\u56de\u4f7f\u7528\u3059\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u30ec\u30b8\u30b9\u30bf\u3067\u3059\u3002<\/p>\n