1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.method static void main()
{
.entrypoint
.locals ( string message )
ldstr "Hello! I'm MSIL Assembly.\n" stloc message
ldloc message call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
C#では・・・ :
1
2
3
4
5
|
-
|
|
|
!
|
void main(){
string message;
message = "Hello! I'm MSIL Assembly\n";
System.Console.WriteLine(message);
}
|
VB.NETでは・・・ :
1
2
3
4
5
|
public sub main()
dim message as string
message = "Hello! I'm MSIL Assembly" & vbcrlf
System.Console.WriteLine(message)
end sub
|
ローカル変数の初期化について †
基本的に自動では初期化されません。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.method static void main()
{
.entrypoint
.locals ( int32 x, int32 y )
ldloca x call instance string class [mscorlib]System.Int32::ToString() call void class [mscorlib]System.Console::WriteLine(string)
ldloca y call instance string class [mscorlib]System.Int32::ToString() call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果(例):
112722008
112722008
stringの場合は""になります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-
|
|
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.method static void main()
{
.entrypoint
.locals ( string message )
ldloc message call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果:
.localsの後にinitをつけると自動で初期化してくれます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.method static void main()
{
.entrypoint
.locals init ( int32 x, int32 y )
ldloca x call instance string class [mscorlib]System.Int32::ToString() call void class [mscorlib]System.Console::WriteLine(string)
ldloca y call instance string class [mscorlib]System.Int32::ToString() call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果(例):
0
0
参照 †
|
Last-modified: Mon, 27 Jul 2009 03:06:22 JST