ilasmでstack machine その18

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

# 練習問題
マイナンバーのチェックデジットを計算せよ。

# サンプルコード

```

.assembly extern mscorlib {
}
.assembly myno {
}
.method static void main() {
.entrypoint
.locals init (string[] str)
.locals init (int32 a)
.locals init (int32 b)
	ldc.i4	0
	stloc	a
loop:
	ldstr	"mynumber "
	call	void [mscorlib]System.Console::WriteLine(string)
	call	string [mscorlib]System.Console::ReadLine()
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	dup
	ldc.i4	0
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	6
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	1
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	5
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	2
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	4
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	3
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	3
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	4
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	2
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	5
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	7
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	6
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	6
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	7
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	5
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	8
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	4
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	9
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	3
	mul
	ldloc	a
	add
	stloc	a

	ldc.i4	10
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	ldc.i4	2
	mul
	ldloc	a
	add
	ldc.i4	11
	rem
	stloc	a

	ldc.i4	11
	ldc.i4	1
	callvirt instance string [mscorlib]System.String::Substring(int32, int32)
	call	int32 [mscorlib]System.Int32::Parse(string)
	stloc	b

	ldloc	a
	ldc.i4	1
	bgt		tugi
	ldc.i4	0
	br		tugi2
tugi:
	ldloc	a
tugi2:

	ldc.i4	11
	ldloc	b
	sub

	beq		tugi3
	ldstr	"false"
	call	void [mscorlib]System.Console::WriteLine(string)
	ret
tugi3:
	ldstr	"true"
	call	void [mscorlib]System.Console::WriteLine(string)
	ret
}




```

# 実行結果

```

>imyno
mynumber
123456789010
false

>imyno
mynumber
123456789011
false

>imyno
mynumber
123456789012
false

>imyno
mynumber
123456789013
false

>imyno
mynumber
123456789014
false

>imyno
mynumber
123456789015
false

>imyno
mynumber
123456789016
false

>imyno
mynumber
123456789017
false

>imyno
mynumber
123456789018
true

>imyno
mynumber
123456789019
false

>imyno
mynumber
023456789013
true

>


```

以上。