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でclassを書け。

方針

  • floatを足すclassを作る。

サンプルコード


.assembly oop {}
.class Calc extends [mscorlib]System.Object {
	.method public void .ctor() {
		ret
	}
	.method public float32 Sum(float32, float32) {
		ldarg.1
		ldarg.2
		add
		ret
	}
}
.class public Program extends [mscorlib]System.Object {
	.method public static void Main(string[] args) {
	.maxstack 3
	.entrypoint
		newobj instance void Calc::.ctor()
		ldc.r4 4.5
		ldc.r4 45.67
		call instance float32 Calc::Sum(float32, float32)
		call void [mscorlib]System.Console::WriteLine(float32)
		ret
	}
}

実行結果

>oop
50.17

以上

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?