1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

概要

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

練習問題

ilasmでzundokoを書け。

環境

windows11

サンプルコード


.assembly zundoko {}
.method static void main() {
.entrypoint
.maxstack 8
.locals init (class [mscorlib]System.Random r, int32 i)
	newobj instance void [mscorlib]System.Random::.ctor()
	stloc r
	ldc.i4 0
	stloc i
loop:
	ldloc r
	ldc.i4 3
	callvirt instance int32 [mscorlib]System.Random::Next(int32)
	ldc.i4 1
	bgt zun
	ldc.i4 0
	stloc i
	ldstr "ドコ"
	call void [mscorlib]System.Console::WriteLine(string)
	br loop
zun:
	ldstr "ズン"
	call void [mscorlib]System.Console::WriteLine(string)
	ldloc i
	ldc.i4 1
	add
	stloc i
	ldloc i
	ldc.i4 3
	bgt end
	br loop
end:
	ldstr "ドコ キヨシ!!"
	call void [mscorlib]System.Console::WriteLine(string)
	ret
}


実行結果

>zundoko3
ズン
ドコ
ズン
ズン
ドコ
ドコ
ドコ
ドコ
ドコ
ドコ
ズン
ドコ
ドコ
ズン
ドコ
ズン
ドコ
ドコ
ドコ
ドコ
ドコ
ズン
ズン
ズン
ズン
ドコ キヨシ!!

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?