0
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?

More than 3 years have passed since last update.

ilasmでstack machine その14

Posted at

概要

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

練習問題

zundoko表示せよ。

サンプルコード


.assembly extern mscorlib {
}
.assembly zundoko {
}
.method static void main() {
.entrypoint
.locals init (class [mscorlib]System.Random r)
.locals init (int32 i)
	newobj instance void [mscorlib]System.Random::.ctor()
	ldc.i4	0
	stloc	i
loop:
	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::Write(string)
	br		loop
zun:
	ldstr	"ズン "
	call	void [mscorlib]System.Console::Write(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
}


実行結果

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

>

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

>

以上。

0
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
0
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?