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?

ilasmでclass

Last updated at Posted at 2019-12-30

概要

ilasmでclass書いてみた。

環境

windows 7 64bit
.Net Framework 2.0

サンプルコード

.assembly hello1 {
}
.class private auto ansi hello1 extends [mscorlib]System.Object {					
    //クラス
	.method public specialname rtspecialname instance void .ctor() cil managed {	
        //コンストラクター
		.maxstack	2
		ldarg.0
		call		instance void [mscorlib]System.Object::.ctor()
		ret
	}
	.method public instance void Say(string A_1) cil managed {
		.maxstack	1
		ldarg.1
		call		void [mscorlib]System.Console::WriteLine(string)
		ret
	}
	.method static void Main() cil managed {		
        //メイン
		.entrypoint
		.maxstack 	8
		.locals 	init (string V_0, class hello1 V_1)
		ldstr		"hello1"
		stloc.0										
        //変数V_0に、"hello1"入れる。
		newobj		instance void hello1::.ctor()
		stloc.1										
        //変数V_1に、クラスhello1入れる。
		ldloc.1
		ldloc.0
		call		instance void hello1::Say(string)
        //stackにクラスとhello1積んで、Sayをコール。
		ret
	}
}


以上。

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?