ilasmでstack machine その57

# 概要
ilasmでstack machineやってみた。
練習問題やってみた。

# 練習問題
ilasmで、じゃんけんを実装せよ。

# サンプルコード

```

.assembly extern mscorlib {}
.assembly janken {}
.method static void Main() cil managed {
	.entrypoint
	.maxstack 3
	.locals init ([0] bool flg,
			[1] string a,
			[2] string b,
			[3] string name,
			[4] class [mscorlib]System.Random random,
			[5] class [mscorlib]System.Globalization.StringInfo nameInfo,
			[6] int32 newNameIndex,
			[7] string str,
			[8] string,
			[9] string,
			[10] string,
			[11] string,
			[12] string,
			[13] string,
			[14] string,
			[15] string,
			[16] bool)
L001: ldc.i4.1
L002: stloc.0
L003: br L196
L008: ldstr "2"
L00e: stloc.2
L00f: ldstr "012"
L014: stloc.3
L015: newobj instance void [mscorlib]System.Random::.ctor()
L01a: stloc.s 4
L01c: ldloc.3
L01d: newobj instance void [mscorlib]System.Globalization.StringInfo::.ctor(string)
L022: stloc.s 5
L024: ldloc.s 4
L026: ldloc.s 5
L028: callvirt instance int32 [mscorlib]System.Globalization.StringInfo::get_LengthInTextElements()
L02d: callvirt instance int32 [mscorlib]System.Random::Next(int32)
L032: stloc.s 6
L034: ldloc.s 5
L036: ldloc.s 6
L038: ldc.i4.1
L039: callvirt instance string [mscorlib]System.Globalization.StringInfo::SubstringByTextElements(int32, int32)
L03e: stloc.2
L03f: ldstr ""
L044: stloc.s 7
L046: ldstr "janken  0:gou 1:tyoki 2:par 3:exit"
L04b: call void [mscorlib]System.Console::WriteLine(string)
L051: call string [mscorlib]System.Console::ReadLine()
L056: stloc.1
L057: ldloc.1
L058: stloc.s 9
L05a: ldloc.s 9
L05c: stloc.s 8
L05e: ldloc.s 8
L060: ldstr "0"
L065: call bool [mscorlib]System.String::op_Equality(string, string)
L06a: brtrue.s L090
L06c: ldloc.s 8
L06e: ldstr "1"
L073: call bool [mscorlib]System.String::op_Equality(string, string)
L078: brtrue.s L0e5
L07a: ldloc.s 8
L07c: ldstr "2"
L081: call bool [mscorlib]System.String::op_Equality(string, string)
L086: brtrue L137
L08b: br L189
L090: ldloc.2
L091: stloc.s 11
L093: ldloc.s 11
L095: stloc.s 10
L097: ldloc.s 10
L099: ldstr "0"
L09e: call bool [mscorlib]System.String::op_Equality(string, string)
L0a3: brtrue.s L0c3
L0a5: ldloc.s 10
L0a7: ldstr "1"
L0ac: call bool [mscorlib]System.String::op_Equality(string, string)
L0b1: brtrue.s L0cc
L0b3: ldloc.s 10
L0b5: ldstr "2"
L0ba: call bool [mscorlib]System.String::op_Equality(string, string)
L0bf: brtrue.s L0d5
L0c1: br.s L0de
L0c3: ldstr "aiko"
L0c8: stloc.s 7
L0ca: br.s L0e0
L0cc: ldstr "you win"
L0d1: stloc.s 7
L0d3: br.s L0e0
L0d5: ldstr "my win"
L0da: stloc.s 7
L0dc: br.s L0e0
L0de: br.s L0e0
L0e0: br L18d
L0e5: ldloc.2
L0e6: stloc.s 13
L0e8: ldloc.s 13
L0ea: stloc.s 12
L0ec: ldloc.s 12
L0ee: ldstr "0"
L0f3: call bool [mscorlib]System.String::op_Equality(string, string)
L0f8: brtrue.s L118
L0fa: ldloc.s 12
L0fc: ldstr "1"
L101: call bool [mscorlib]System.String::op_Equality(string, string)
L106: brtrue.s L121
L108: ldloc.s 12
L10a: ldstr "2"
L10f: call bool [mscorlib]System.String::op_Equality(string, string)
L114: brtrue.s L12a
L116: br.s L133
L118: ldstr "my win"
L11d: stloc.s 7
L11f: br.s L135
L121: ldstr "aiko"
L126: stloc.s 7
L128: br.s L135
L12a: ldstr "you win"
L12f: stloc.s 7
L131: br.s L135
L133: br.s L135
L135: br.s L18d
L137: ldloc.2
L138: stloc.s 15
L13a: ldloc.s 15
L13c: stloc.s 14
L13e: ldloc.s 14
L140: ldstr "0"
L145: call bool [mscorlib]System.String::op_Equality(string, string)
L14a: brtrue.s L16a
L14c: ldloc.s 14
L14e: ldstr "1"
L153: call bool [mscorlib]System.String::op_Equality(string, string)
L158: brtrue.s L173
L15a: ldloc.s 14
L15c: ldstr "2"
L161: call bool [mscorlib]System.String::op_Equality(string, string)
L166: brtrue.s L17c
L168: br.s L185
L16a: ldstr "you win"
L16f: stloc.s 7
L171: br.s L187
L173: ldstr "my win"
L178: stloc.s 7
L17a: br.s L187
L17c: ldstr "aiko"
L181: stloc.s 7
L183: br.s L187
L185: br.s L187
L187: br.s L18d
L189: ldc.i4.0
L18a: stloc.0
L18b: br.s L18d
L18d: ldloc.s 7
L18f: call void [mscorlib]System.Console::WriteLine(string)
L196: ldloc.0
L197: stloc.s 16
L199: ldloc.s 16
L19b: brtrue L008
L1a0: ret
}





```

# 実行結果

```
>janken
janken  0:gou 1:tyoki 2:par 3:exit
1
aiko
janken  0:gou 1:tyoki 2:par 3:exit
2
you win
janken  0:gou 1:tyoki 2:par 3:exit
3

```

以上。