言語プロセッサ

言語プロセッサとは

高水準言語
int B = 5;
言語プロセッサ

による変換
機械語
5E 23 ...

CPUが実行するプログラムは機械語とか機械語プログラムと言われる。

「プログラム実行のしくみ」中の機械語のプログラムにあるように、5E 23 56 F3 3E FE D3 71 CD ...... というようなもので、ニーモニックを書き加えて多少理解しやすく書いたものは次のようになっている。

番地 機械語 ニーモニック
D000 5E LD E,(HL)
D001 23 INC HL
D002 56 LD D,(HL)
D003 F3 DI
D004 3E FE LD A,FE
D006 D3 71 OUT (71),A
............

この機械語でプログラムを組むのは手間がかかるので、人間にわかりやすい書き方をしたものをコンピュータを使って機械語へ書き直すことを考えた。上記のニーモニックはその最も簡単なもので、これにいろいろな機能を加えて発展させたものをアセンブリ言語という。

この機械語への変換をするソフトウェアを言語プロセッサという。

アセンブリ言語は対象となるCPUによって書き方が異なるし、まだまだ人間にはわかりにくい。そこでさらに人間の言葉に近い言語から変換できるようになっていった。このような言語を高水準言語あるいは高級言語という。

高水準言語には、FORTRAN, BASIC, C, C++, Java などたくさん存在する。目的により使い分けるが時代と共に流行もある。

高水準言語から、機械語に変換することを「翻訳」ということがある。

コンパイラとインタプリタ

高水準言語から、機械語に変換する方法は大きく分けてコンパイラ方式とインタプリタ方式がある。

コンパイラではファイルが作成され、OS上で直接実行される

ソースプログラム
ファイル
コンパイラによる変換

オブジェクトプログラムの生成
オブジェクトプログラム
ファイル
OSから実行

インタプリタでは変換しながら実行もする

ソースプログラム
ファイル
インタプリタによる変換
と実行

実際には途中で中間言語に変換することもあるので、簡単に2つに分類できないこともある。

たとえば Java という言語では、コンパイルにより中間言語のファイルを作った後、javaというプログラムで中間言語を解釈しながら実行する。後半の仕組みはインタプリタと同じ動作である。

コンパイラの例(C言語)

有名なCのプログラム例を実際にコンパイルしてみます。まずはソースファイルを作ります。次のプログラムを書いてHello.cという名前で保存します。

#include <stdio.h>
 
int main(void)
{
  printf("Hello, World!\n");
  return 0;
}

コンパイルします。

$ gcc Hello.c -o Hello 

Helloという名前のファイルができています。

$ ls -l
-rwx------ 1 hoge hoge 6273 2009-05-06 20:00 Hello
-rw------- 1 hoge hoge   82 2009-05-06 20:00 Hello.c

実行します。

$ ./Hello
Hello, World!

この時実行されるのはHello.cではなくコンパイルして作成されたHelloです。

ファイルの内容を確認する

Hello.cを調べます。fileというコマンドで調べることができます。

$ file Hello.c
Hello.c: ASCII C program text

ASCIIで書かれたテキストファイルでCのプログラムだといっています。

テキストファイルならばcatコマンドで内容を表示できます。

$ cat Hello.c
#include <stdio.h>
 
int main(void)
{
  printf("Hello, World!\n");
  return 0;
}

ではコンパイルの結果作成されたHelloをfileコマンドで調べると

$ file Hello
Hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped

このファィルはcatコマンドで表示するとまともに読めません。hdコマンドでコードを見ることができます。

$ hd Hello
00000000  7f 45 4c 46 01 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 03 00 01 00 00 00  10 83 04 08 34 00 00 00  |............4...|
00000020  c8 06 00 00 00 00 00 00  34 00 20 00 07 00 28 00  |........4. ...(.|
00000030  1e 00 1b 00 06 00 00 00  34 00 00 00 34 80 04 08  |........4...4...|
00000040  34 80 04 08 e0 00 00 00  e0 00 00 00 05 00 00 00  |4...............|
00000050  04 00 00 00 03 00 00 00  14 01 00 00 14 81 04 08  |................|
00000060  14 81 04 08 13 00 00 00  13 00 00 00 04 00 00 00  |................|
00000070  01 00 00 00 01 00 00 00  00 00 00 00 00 80 04 08  |................|
00000080  00 80 04 08 b4 04 00 00  b4 04 00 00 05 00 00 00  |................|
00000090  00 10 00 00 01 00 00 00  b4 04 00 00 b4 94 04 08  |................|
000000a0  b4 94 04 08 08 01 00 00  10 01 00 00 06 00 00 00  |................|
000000b0  00 10 00 00 02 00 00 00  c8 04 00 00 c8 94 04 08  |................|
000000c0  c8 94 04 08 d0 00 00 00  d0 00 00 00 06 00 00 00  |................|
000000d0  04 00 00 00 04 00 00 00  28 01 00 00 28 81 04 08  |........(...(...|
000000e0  28 81 04 08 44 00 00 00  44 00 00 00 04 00 00 00  |(...D...D.......|
000000f0  04 00 00 00 51 e5 74 64  00 00 00 00 00 00 00 00  |....Q.td........|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 06 00 00 00  |................|
00000110  04 00 00 00 2f 6c 69 62  2f 6c 64 2d 6c 69 6e 75  |..../lib/ld-linu|
00000120  78 2e 73 6f 2e 32 00 00  04 00 00 00 10 00 00 00  |x.so.2..........|
00000130  01 00 00 00 47 4e 55 00  00 00 00 00 02 00 00 00  |....GNU.........|
00000140  06 00 00 00 12 00 00 00  04 00 00 00 14 00 00 00  |................|
00000150  03 00 00 00 47 4e 55 00  b1 f8 ed c8 35 10 d0 5b  |....GNU.....5..[|
00000160  15 37 26 d7 6c 83 c9 05  df 2c 66 8a 03 00 00 00  |.7&.l....,f.....|
00000170  05 00 00 00 01 00 00 00  03 00 00 00 04 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 02 00 00 00  |................|
00000190  00 00 00 00 02 00 00 00  04 00 00 00 01 00 00 00  |................|
000001a0  05 00 00 00 00 20 00 20  00 00 00 00 04 00 00 00  |..... . ........|
000001b0  ad 4b e3 c0 00 00 00 00  00 00 00 00 00 00 00 00  |.K..............|
000001c0  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  20 00 00 00 2e 00 00 00  00 00 00 00 00 00 00 00  | ...............|
000001e0  12 00 00 00 29 00 00 00  00 00 00 00 00 00 00 00  |....)...........|
000001f0  12 00 00 00 1a 00 00 00  9c 84 04 08 04 00 00 00  |................|
00000200  11 00 10 00 00 5f 5f 67  6d 6f 6e 5f 73 74 61 72  |.....__gmon_star|
00000210  74 5f 5f 00 6c 69 62 63  2e 73 6f 2e 36 00 5f 49  |t__.libc.so.6._I|
00000220  4f 5f 73 74 64 69 6e 5f  75 73 65 64 00 70 75 74  |O_stdin_used.put|
00000230  73 00 5f 5f 6c 69 62 63  5f 73 74 61 72 74 5f 6d  |s.__libc_start_m|
00000240  61 69 6e 00 47 4c 49 42  43 5f 32 2e 30 00 00 00  |ain.GLIBC_2.0...|
00000250  00 00 02 00 02 00 01 00  01 00 01 00 10 00 00 00  |................|
00000260  10 00 00 00 00 00 00 00  10 69 69 0d 00 00 02 00  |.........ii.....|
00000270  40 00 00 00 00 00 00 00  98 95 04 08 06 01 00 00  |@...............|
00000280  a8 95 04 08 07 01 00 00  ac 95 04 08 07 02 00 00  |................|
00000290  b0 95 04 08 07 03 00 00  55 89 e5 53 83 ec 04 e8  |........U..S....|
000002a0  00 00 00 00 5b 81 c3 f8  12 00 00 8b 93 fc ff ff  |....[...........|
000002b0  ff 85 d2 74 05 e8 1e 00  00 00 e8 e1 00 00 00 e8  |...t............|
000002c0  8c 01 00 00 58 5b c9 c3  ff 35 a0 95 04 08 ff 25  |....X[...5.....%|
000002d0  a4 95 04 08 00 00 00 00  ff 25 a8 95 04 08 68 00  |.........%....h.|
000002e0  00 00 00 e9 e0 ff ff ff  ff 25 ac 95 04 08 68 08  |.........%....h.|
000002f0  00 00 00 e9 d0 ff ff ff  ff 25 b0 95 04 08 68 10  |.........%....h.|
00000300  00 00 00 e9 c0 ff ff ff  00 00 00 00 00 00 00 00  |................|
00000310  31 ed 5e 89 e1 83 e4 f0  50 54 52 68 e0 83 04 08  |1.^.....PTRh....|
00000320  68 f0 83 04 08 51 56 68  c4 83 04 08 e8 b7 ff ff  |h....QVh........|
00000330  ff f4 90 90 90 90 90 90  90 90 90 90 90 90 90 90  |................|
00000340  55 89 e5 53 83 ec 04 80  3d bc 95 04 08 00 75 3f  |U..S....=.....u?|
00000350  a1 c0 95 04 08 bb c0 94  04 08 81 eb bc 94 04 08  |................|
00000360  c1 fb 02 83 eb 01 39 d8  73 1e 8d b6 00 00 00 00  |......9.s.......|
00000370  83 c0 01 a3 c0 95 04 08  ff 14 85 bc 94 04 08 a1  |................|
00000380  c0 95 04 08 39 d8 72 e8  c6 05 bc 95 04 08 01 83  |....9.r.........|
00000390  c4 04 5b 5d c3 8d 74 26  00 8d bc 27 00 00 00 00  |..[]..t&...'....|
000003a0  55 89 e5 83 ec 18 a1 c4  94 04 08 85 c0 74 12 b8  |U............t..|
000003b0  00 00 00 00 85 c0 74 09  c7 04 24 c4 94 04 08 ff  |......t...$.....|
000003c0  d0 c9 c3 90 55 89 e5 83  e4 f0 83 ec 10 c7 04 24  |....U..........$|
000003d0  a0 84 04 08 e8 1f ff ff  ff b8 00 00 00 00 c9 c3  |................|
000003e0  55 89 e5 5d c3 8d 74 26  00 8d bc 27 00 00 00 00  |U..]..t&...'....|
000003f0  55 89 e5 57 56 53 e8 4f  00 00 00 81 c3 a1 11 00  |U..WVS.O........|
00000400  00 83 ec 1c e8 8f fe ff  ff 8d bb 18 ff ff ff 8d  |................|
00000410  83 18 ff ff ff 29 c7 c1  ff 02 85 ff 74 24 31 f6  |.....)......t$1.|
00000420  8b 45 10 89 44 24 08 8b  45 0c 89 44 24 04 8b 45  |.E..D$..E..D$..E|
00000430  08 89 04 24 ff 94 b3 18  ff ff ff 83 c6 01 39 fe  |...$..........9.|
00000440  72 de 83 c4 1c 5b 5e 5f  5d c3 8b 1c 24 c3 90 90  |r....[^_]...$...|
00000450  55 89 e5 53 83 ec 04 a1  b4 94 04 08 83 f8 ff 74  |U..S...........t|
00000460  13 bb b4 94 04 08 66 90  83 eb 04 ff d0 8b 03 83  |......f.........|
00000470  f8 ff 75 f4 83 c4 04 5b  5d c3 90 90 55 89 e5 53  |..u....[]...U..S|
00000480  83 ec 04 e8 00 00 00 00  5b 81 c3 14 11 00 00 e8  |........[.......|
00000490  ac fe ff ff 59 5b c9 c3  03 00 00 00 01 00 02 00  |....Y[..........|
000004a0  48 65 6c 6c 6f 2c 20 57  6f 72 6c 64 21 00 00 00  |Hello, World!...|
000004b0  00 00 00 00 ff ff ff ff  00 00 00 00 ff ff ff ff  |................|
000004c0  00 00 00 00 00 00 00 00  01 00 00 00 10 00 00 00  |................|
000004d0  0c 00 00 00 98 82 04 08  0d 00 00 00 7c 84 04 08  |............|...|
000004e0  04 00 00 00 6c 81 04 08  f5 fe ff 6f 94 81 04 08  |....l......o....|
000004f0  05 00 00 00 04 82 04 08  06 00 00 00 b4 81 04 08  |................|
00000500  0a 00 00 00 4a 00 00 00  0b 00 00 00 10 00 00 00  |....J...........|
00000510  15 00 00 00 00 00 00 00  03 00 00 00 9c 95 04 08  |................|
00000520  02 00 00 00 18 00 00 00  14 00 00 00 11 00 00 00  |................|
00000530  17 00 00 00 80 82 04 08  11 00 00 00 78 82 04 08  |............x...|
00000540  12 00 00 00 08 00 00 00  13 00 00 00 08 00 00 00  |................|
00000550  fe ff ff 6f 58 82 04 08  ff ff ff 6f 01 00 00 00  |...oX......o....|
00000560  f0 ff ff 6f 4e 82 04 08  00 00 00 00 00 00 00 00  |...oN...........|
00000570  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000590  00 00 00 00 00 00 00 00  00 00 00 00 c8 94 04 08  |................|
000005a0  00 00 00 00 00 00 00 00  de 82 04 08 ee 82 04 08  |................|
000005b0  fe 82 04 08 00 00 00 00  00 00 00 00 47 43 43 3a  |............GCC:|
000005c0  20 28 44 65 62 69 61 6e  20 34 2e 34 2e 35 2d 38  | (Debian 4.4.5-8|
000005d0  29 20 34 2e 34 2e 35 00  00 2e 73 79 6d 74 61 62  |) 4.4.5...symtab|
000005e0  00 2e 73 74 72 74 61 62  00 2e 73 68 73 74 72 74  |..strtab..shstrt|
000005f0  61 62 00 2e 69 6e 74 65  72 70 00 2e 6e 6f 74 65  |ab..interp..note|
00000600  2e 41 42 49 2d 74 61 67  00 2e 6e 6f 74 65 2e 67  |.ABI-tag..note.g|
00000610  6e 75 2e 62 75 69 6c 64  2d 69 64 00 2e 67 6e 75  |nu.build-id..gnu|
00000620  2e 68 61 73 68 00 2e 64  79 6e 73 79 6d 00 2e 64  |.hash..dynsym..d|
00000630  79 6e 73 74 72 00 2e 67  6e 75 2e 76 65 72 73 69  |ynstr..gnu.versi|
00000640  6f 6e 00 2e 67 6e 75 2e  76 65 72 73 69 6f 6e 5f  |on..gnu.version_|
00000650  72 00 2e 72 65 6c 2e 64  79 6e 00 2e 72 65 6c 2e  |r..rel.dyn..rel.|
00000660  70 6c 74 00 2e 69 6e 69  74 00 2e 74 65 78 74 00  |plt..init..text.|
00000670  2e 66 69 6e 69 00 2e 72  6f 64 61 74 61 00 2e 65  |.fini..rodata..e|
00000680  68 5f 66 72 61 6d 65 00  2e 63 74 6f 72 73 00 2e  |h_frame..ctors..|
00000690  64 74 6f 72 73 00 2e 6a  63 72 00 2e 64 79 6e 61  |dtors..jcr..dyna|
000006a0  6d 69 63 00 2e 67 6f 74  00 2e 67 6f 74 2e 70 6c  |mic..got..got.pl|
000006b0  74 00 2e 64 61 74 61 00  2e 62 73 73 00 2e 63 6f  |t..data..bss..co|
000006c0  6d 6d 65 6e 74 00 00 00  00 00 00 00 00 00 00 00  |mment...........|
000006d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000006f0  1b 00 00 00 01 00 00 00  02 00 00 00 14 81 04 08  |................|
00000700  14 01 00 00 13 00 00 00  00 00 00 00 00 00 00 00  |................|
00000710  01 00 00 00 00 00 00 00  23 00 00 00 07 00 00 00  |........#.......|
00000720  02 00 00 00 28 81 04 08  28 01 00 00 20 00 00 00  |....(...(... ...|
00000730  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
00000740  31 00 00 00 07 00 00 00  02 00 00 00 48 81 04 08  |1...........H...|
00000750  48 01 00 00 24 00 00 00  00 00 00 00 00 00 00 00  |H...$...........|
00000760  04 00 00 00 00 00 00 00  48 00 00 00 05 00 00 00  |........H.......|
00000770  02 00 00 00 6c 81 04 08  6c 01 00 00 28 00 00 00  |....l...l...(...|
00000780  06 00 00 00 00 00 00 00  04 00 00 00 04 00 00 00  |................|
00000790  44 00 00 00 f6 ff ff 6f  02 00 00 00 94 81 04 08  |D......o........|
000007a0  94 01 00 00 20 00 00 00  06 00 00 00 00 00 00 00  |.... ...........|
000007b0  04 00 00 00 04 00 00 00  4e 00 00 00 0b 00 00 00  |........N.......|
000007c0  02 00 00 00 b4 81 04 08  b4 01 00 00 50 00 00 00  |............P...|
000007d0  07 00 00 00 01 00 00 00  04 00 00 00 10 00 00 00  |................|
000007e0  56 00 00 00 03 00 00 00  02 00 00 00 04 82 04 08  |V...............|
000007f0  04 02 00 00 4a 00 00 00  00 00 00 00 00 00 00 00  |....J...........|
00000800  01 00 00 00 00 00 00 00  5e 00 00 00 ff ff ff 6f  |........^......o|
00000810  02 00 00 00 4e 82 04 08  4e 02 00 00 0a 00 00 00  |....N...N.......|
00000820  06 00 00 00 00 00 00 00  02 00 00 00 02 00 00 00  |................|
00000830  6b 00 00 00 fe ff ff 6f  02 00 00 00 58 82 04 08  |k......o....X...|
00000840  58 02 00 00 20 00 00 00  07 00 00 00 01 00 00 00  |X... ...........|
00000850  04 00 00 00 00 00 00 00  7a 00 00 00 09 00 00 00  |........z.......|
00000860  02 00 00 00 78 82 04 08  78 02 00 00 08 00 00 00  |....x...x.......|
00000870  06 00 00 00 00 00 00 00  04 00 00 00 08 00 00 00  |................|
00000880  83 00 00 00 09 00 00 00  02 00 00 00 80 82 04 08  |................|
00000890  80 02 00 00 18 00 00 00  06 00 00 00 0d 00 00 00  |................|
000008a0  04 00 00 00 08 00 00 00  8c 00 00 00 01 00 00 00  |................|
000008b0  06 00 00 00 98 82 04 08  98 02 00 00 30 00 00 00  |............0...|
000008c0  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
000008d0  87 00 00 00 01 00 00 00  06 00 00 00 c8 82 04 08  |................|
000008e0  c8 02 00 00 40 00 00 00  00 00 00 00 00 00 00 00  |....@...........|
000008f0  04 00 00 00 04 00 00 00  92 00 00 00 01 00 00 00  |................|
00000900  06 00 00 00 10 83 04 08  10 03 00 00 6c 01 00 00  |............l...|
00000910  00 00 00 00 00 00 00 00  10 00 00 00 00 00 00 00  |................|
00000920  98 00 00 00 01 00 00 00  06 00 00 00 7c 84 04 08  |............|...|
00000930  7c 04 00 00 1c 00 00 00  00 00 00 00 00 00 00 00  ||...............|
00000940  04 00 00 00 00 00 00 00  9e 00 00 00 01 00 00 00  |................|
00000950  02 00 00 00 98 84 04 08  98 04 00 00 16 00 00 00  |................|
00000960  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
00000970  a6 00 00 00 01 00 00 00  02 00 00 00 b0 84 04 08  |................|
00000980  b0 04 00 00 04 00 00 00  00 00 00 00 00 00 00 00  |................|
00000990  04 00 00 00 00 00 00 00  b0 00 00 00 01 00 00 00  |................|
000009a0  03 00 00 00 b4 94 04 08  b4 04 00 00 08 00 00 00  |................|
000009b0  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
000009c0  b7 00 00 00 01 00 00 00  03 00 00 00 bc 94 04 08  |................|
000009d0  bc 04 00 00 08 00 00 00  00 00 00 00 00 00 00 00  |................|
000009e0  04 00 00 00 00 00 00 00  be 00 00 00 01 00 00 00  |................|
000009f0  03 00 00 00 c4 94 04 08  c4 04 00 00 04 00 00 00  |................|
00000a00  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
00000a10  c3 00 00 00 06 00 00 00  03 00 00 00 c8 94 04 08  |................|
00000a20  c8 04 00 00 d0 00 00 00  07 00 00 00 00 00 00 00  |................|
00000a30  04 00 00 00 08 00 00 00  cc 00 00 00 01 00 00 00  |................|
00000a40  03 00 00 00 98 95 04 08  98 05 00 00 04 00 00 00  |................|
00000a50  00 00 00 00 00 00 00 00  04 00 00 00 04 00 00 00  |................|
00000a60  d1 00 00 00 01 00 00 00  03 00 00 00 9c 95 04 08  |................|
00000a70  9c 05 00 00 18 00 00 00  00 00 00 00 00 00 00 00  |................|
00000a80  04 00 00 00 04 00 00 00  da 00 00 00 01 00 00 00  |................|
00000a90  03 00 00 00 b4 95 04 08  b4 05 00 00 08 00 00 00  |................|
00000aa0  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
00000ab0  e0 00 00 00 08 00 00 00  03 00 00 00 bc 95 04 08  |................|
00000ac0  bc 05 00 00 08 00 00 00  00 00 00 00 00 00 00 00  |................|
00000ad0  04 00 00 00 00 00 00 00  e5 00 00 00 01 00 00 00  |................|
00000ae0  30 00 00 00 00 00 00 00  bc 05 00 00 1c 00 00 00  |0...............|
00000af0  00 00 00 00 00 00 00 00  01 00 00 00 01 00 00 00  |................|
00000b00  11 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
00000b10  d8 05 00 00 ee 00 00 00  00 00 00 00 00 00 00 00  |................|
00000b20  01 00 00 00 00 00 00 00  01 00 00 00 02 00 00 00  |................|
00000b30  00 00 00 00 00 00 00 00  78 0b 00 00 10 04 00 00  |........x.......|
00000b40  1d 00 00 00 2d 00 00 00  04 00 00 00 10 00 00 00  |....-...........|
00000b50  09 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
00000b60  88 0f 00 00 fb 01 00 00  00 00 00 00 00 00 00 00  |................|
00000b70  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000b80  00 00 00 00 00 00 00 00  00 00 00 00 14 81 04 08  |................|
00000b90  00 00 00 00 03 00 01 00  00 00 00 00 28 81 04 08  |............(...|
00000ba0  00 00 00 00 03 00 02 00  00 00 00 00 48 81 04 08  |............H...|
00000bb0  00 00 00 00 03 00 03 00  00 00 00 00 6c 81 04 08  |............l...|
00000bc0  00 00 00 00 03 00 04 00  00 00 00 00 94 81 04 08  |................|
00000bd0  00 00 00 00 03 00 05 00  00 00 00 00 b4 81 04 08  |................|
00000be0  00 00 00 00 03 00 06 00  00 00 00 00 04 82 04 08  |................|
00000bf0  00 00 00 00 03 00 07 00  00 00 00 00 4e 82 04 08  |............N...|
00000c00  00 00 00 00 03 00 08 00  00 00 00 00 58 82 04 08  |............X...|
00000c10  00 00 00 00 03 00 09 00  00 00 00 00 78 82 04 08  |............x...|
00000c20  00 00 00 00 03 00 0a 00  00 00 00 00 80 82 04 08  |................|
00000c30  00 00 00 00 03 00 0b 00  00 00 00 00 98 82 04 08  |................|
00000c40  00 00 00 00 03 00 0c 00  00 00 00 00 c8 82 04 08  |................|
00000c50  00 00 00 00 03 00 0d 00  00 00 00 00 10 83 04 08  |................|
00000c60  00 00 00 00 03 00 0e 00  00 00 00 00 7c 84 04 08  |............|...|
00000c70  00 00 00 00 03 00 0f 00  00 00 00 00 98 84 04 08  |................|
00000c80  00 00 00 00 03 00 10 00  00 00 00 00 b0 84 04 08  |................|
00000c90  00 00 00 00 03 00 11 00  00 00 00 00 b4 94 04 08  |................|
00000ca0  00 00 00 00 03 00 12 00  00 00 00 00 bc 94 04 08  |................|
00000cb0  00 00 00 00 03 00 13 00  00 00 00 00 c4 94 04 08  |................|
00000cc0  00 00 00 00 03 00 14 00  00 00 00 00 c8 94 04 08  |................|
00000cd0  00 00 00 00 03 00 15 00  00 00 00 00 98 95 04 08  |................|
00000ce0  00 00 00 00 03 00 16 00  00 00 00 00 9c 95 04 08  |................|
00000cf0  00 00 00 00 03 00 17 00  00 00 00 00 b4 95 04 08  |................|
00000d00  00 00 00 00 03 00 18 00  00 00 00 00 bc 95 04 08  |................|
00000d10  00 00 00 00 03 00 19 00  00 00 00 00 00 00 00 00  |................|
00000d20  00 00 00 00 03 00 1a 00  01 00 00 00 00 00 00 00  |................|
00000d30  00 00 00 00 04 00 f1 ff  0c 00 00 00 b4 94 04 08  |................|
00000d40  00 00 00 00 01 00 12 00  1a 00 00 00 bc 94 04 08  |................|
00000d50  00 00 00 00 01 00 13 00  28 00 00 00 c4 94 04 08  |........(.......|
00000d60  00 00 00 00 01 00 14 00  35 00 00 00 40 83 04 08  |........5...@...|
00000d70  00 00 00 00 02 00 0e 00  4b 00 00 00 bc 95 04 08  |........K.......|
00000d80  01 00 00 00 01 00 19 00  5a 00 00 00 c0 95 04 08  |........Z.......|
00000d90  04 00 00 00 01 00 19 00  68 00 00 00 a0 83 04 08  |........h.......|
00000da0  00 00 00 00 02 00 0e 00  01 00 00 00 00 00 00 00  |................|
00000db0  00 00 00 00 04 00 f1 ff  74 00 00 00 b8 94 04 08  |........t.......|
00000dc0  00 00 00 00 01 00 12 00  81 00 00 00 b0 84 04 08  |................|
00000dd0  00 00 00 00 01 00 11 00  8f 00 00 00 c4 94 04 08  |................|
00000de0  00 00 00 00 01 00 14 00  9b 00 00 00 50 84 04 08  |............P...|
00000df0  00 00 00 00 02 00 0e 00  b1 00 00 00 00 00 00 00  |................|
00000e00  00 00 00 00 04 00 f1 ff  b9 00 00 00 9c 95 04 08  |................|
00000e10  00 00 00 00 01 02 17 00  cf 00 00 00 b4 94 04 08  |................|
00000e20  00 00 00 00 00 02 12 00  e0 00 00 00 b4 94 04 08  |................|
00000e30  00 00 00 00 00 02 12 00  f3 00 00 00 c8 94 04 08  |................|
00000e40  00 00 00 00 01 02 15 00  fc 00 00 00 b4 95 04 08  |................|
00000e50  00 00 00 00 20 00 18 00  07 01 00 00 e0 83 04 08  |.... ...........|
00000e60  05 00 00 00 12 00 0e 00  17 01 00 00 10 83 04 08  |................|
00000e70  00 00 00 00 12 00 0e 00  1e 01 00 00 00 00 00 00  |................|
00000e80  00 00 00 00 20 00 00 00  2d 01 00 00 00 00 00 00  |.... ...-.......|
00000e90  00 00 00 00 20 00 00 00  41 01 00 00 98 84 04 08  |.... ...A.......|
00000ea0  04 00 00 00 11 00 10 00  48 01 00 00 7c 84 04 08  |........H...|...|
00000eb0  00 00 00 00 12 00 0f 00  4e 01 00 00 00 00 00 00  |........N.......|
00000ec0  00 00 00 00 12 00 00 00  6b 01 00 00 9c 84 04 08  |........k.......|
00000ed0  04 00 00 00 11 00 10 00  7a 01 00 00 b4 95 04 08  |........z.......|
00000ee0  00 00 00 00 10 00 18 00  87 01 00 00 b8 95 04 08  |................|
00000ef0  00 00 00 00 11 02 18 00  94 01 00 00 c0 94 04 08  |................|
00000f00  00 00 00 00 11 02 13 00  a1 01 00 00 f0 83 04 08  |................|
00000f10  5a 00 00 00 12 00 0e 00  b1 01 00 00 bc 95 04 08  |Z...............|
00000f20  00 00 00 00 10 00 f1 ff  bd 01 00 00 c4 95 04 08  |................|
00000f30  00 00 00 00 10 00 f1 ff  c2 01 00 00 00 00 00 00  |................|
00000f40  00 00 00 00 12 00 00 00  d2 01 00 00 bc 95 04 08  |................|
00000f50  00 00 00 00 10 00 f1 ff  d9 01 00 00 4a 84 04 08  |............J...|
00000f60  00 00 00 00 12 02 0e 00  f0 01 00 00 c4 83 04 08  |................|
00000f70  1c 00 00 00 12 00 0e 00  f5 01 00 00 98 82 04 08  |................|
00000f80  00 00 00 00 12 00 0c 00  00 63 72 74 73 74 75 66  |.........crtstuf|
00000f90  66 2e 63 00 5f 5f 43 54  4f 52 5f 4c 49 53 54 5f  |f.c.__CTOR_LIST_|
00000fa0  5f 00 5f 5f 44 54 4f 52  5f 4c 49 53 54 5f 5f 00  |_.__DTOR_LIST__.|
00000fb0  5f 5f 4a 43 52 5f 4c 49  53 54 5f 5f 00 5f 5f 64  |__JCR_LIST__.__d|
00000fc0  6f 5f 67 6c 6f 62 61 6c  5f 64 74 6f 72 73 5f 61  |o_global_dtors_a|
00000fd0  75 78 00 63 6f 6d 70 6c  65 74 65 64 2e 35 39 38  |ux.completed.598|
00000fe0  32 00 64 74 6f 72 5f 69  64 78 2e 35 39 38 34 00  |2.dtor_idx.5984.|
00000ff0  66 72 61 6d 65 5f 64 75  6d 6d 79 00 5f 5f 43 54  |frame_dummy.__CT|
00001000  4f 52 5f 45 4e 44 5f 5f  00 5f 5f 46 52 41 4d 45  |OR_END__.__FRAME|
00001010  5f 45 4e 44 5f 5f 00 5f  5f 4a 43 52 5f 45 4e 44  |_END__.__JCR_END|
00001020  5f 5f 00 5f 5f 64 6f 5f  67 6c 6f 62 61 6c 5f 63  |__.__do_global_c|
00001030  74 6f 72 73 5f 61 75 78  00 48 65 6c 6c 6f 2e 63  |tors_aux.Hello.c|
00001040  00 5f 47 4c 4f 42 41 4c  5f 4f 46 46 53 45 54 5f  |._GLOBAL_OFFSET_|
00001050  54 41 42 4c 45 5f 00 5f  5f 69 6e 69 74 5f 61 72  |TABLE_.__init_ar|
00001060  72 61 79 5f 65 6e 64 00  5f 5f 69 6e 69 74 5f 61  |ray_end.__init_a|
00001070  72 72 61 79 5f 73 74 61  72 74 00 5f 44 59 4e 41  |rray_start._DYNA|
00001080  4d 49 43 00 64 61 74 61  5f 73 74 61 72 74 00 5f  |MIC.data_start._|
00001090  5f 6c 69 62 63 5f 63 73  75 5f 66 69 6e 69 00 5f  |_libc_csu_fini._|
000010a0  73 74 61 72 74 00 5f 5f  67 6d 6f 6e 5f 73 74 61  |start.__gmon_sta|
000010b0  72 74 5f 5f 00 5f 4a 76  5f 52 65 67 69 73 74 65  |rt__._Jv_Registe|
000010c0  72 43 6c 61 73 73 65 73  00 5f 66 70 5f 68 77 00  |rClasses._fp_hw.|
000010d0  5f 66 69 6e 69 00 5f 5f  6c 69 62 63 5f 73 74 61  |_fini.__libc_sta|
000010e0  72 74 5f 6d 61 69 6e 40  40 47 4c 49 42 43 5f 32  |rt_main@@GLIBC_2|
000010f0  2e 30 00 5f 49 4f 5f 73  74 64 69 6e 5f 75 73 65  |.0._IO_stdin_use|
00001100  64 00 5f 5f 64 61 74 61  5f 73 74 61 72 74 00 5f  |d.__data_start._|
00001110  5f 64 73 6f 5f 68 61 6e  64 6c 65 00 5f 5f 44 54  |_dso_handle.__DT|
00001120  4f 52 5f 45 4e 44 5f 5f  00 5f 5f 6c 69 62 63 5f  |OR_END__.__libc_|
00001130  63 73 75 5f 69 6e 69 74  00 5f 5f 62 73 73 5f 73  |csu_init.__bss_s|
00001140  74 61 72 74 00 5f 65 6e  64 00 70 75 74 73 40 40  |tart._end.puts@@|
00001150  47 4c 49 42 43 5f 32 2e  30 00 5f 65 64 61 74 61  |GLIBC_2.0._edata|
00001160  00 5f 5f 69 36 38 36 2e  67 65 74 5f 70 63 5f 74  |.__i686.get_pc_t|
00001170  68 75 6e 6b 2e 62 78 00  6d 61 69 6e 00 5f 69 6e  |hunk.bx.main._in|
00001180  69 74 00                                          |it.|

コンパイルしたファイルには文字として解釈できない文字がありますから、16進数でバイト列をそのまま表示しています。右の | | で挟まれたところには1バイトの文字と解釈できるものはその文字を、そうでない時は"."を表示しています。

コンパイルはソースを機械語に書き直すといいますが、そう単純ではないことが分かると思います。

実行はOSがこのプログラムHelloをファイルからメモリ上にロードし、始まりの場所をセットして処理を開始させます。Hello側は作業が終わればOSに制御を戻します。これが プログラムソースにあるreturnの意味です。0 は正常に終わったことを知らせるもので、UNIX系OSの取り決めです。

聖愛中学高等学校
http://www.seiai.ed.jp/
May. 2009 Feb. 2013