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でstack machine その61

Last updated at Posted at 2024-12-24

概要

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

練習問題

AtCoderを解け。
整数 a,b,cと、文字列 s が与えられます。 a+b+c の計算結果と、文字列 s を並べて表示しなさい。

サンプルコード


.assembly AtCoder {}
.method public static void Main() {
	.entrypoint
	.locals init ([0] int32 a, [1] string line, [2] string[] lines, [3] int32 b, [4] int32 c, [5] string s)
	call string [System.Console]System.Console::ReadLine()
	call int32 [System.Runtime]System.Int32::Parse(string)
	stloc.0
	call string [System.Console]System.Console::ReadLine()
	stloc.1
	ldloc.1
	ldc.i4.1
	newarr [System.Runtime]System.String
	dup
	ldc.i4.0
	ldstr " "
	stelem.ref
	ldc.i4.0
	callvirt instance string[] [System.Runtime]System.String::Split(string[], valuetype [System.Runtime]System.StringSplitOptions)
	stloc.2
	ldloc.2
	ldc.i4.0
	ldelem.ref
	call int32 [System.Runtime]System.Int32::Parse(string)
	stloc.3
	ldloc.2
	ldc.i4.1
	ldelem.ref
	call int32 [System.Runtime]System.Int32::Parse(string)
	stloc.s 4
	call string [System.Console]System.Console::ReadLine()
	stloc.s 5
	ldloc.0
	ldloc.3
	add
	ldloc.s 4
	add
	stloc.0
	ldloc.0
	call void [System.Console]System.Console::Write(int32)
	ldstr " "
	call void [System.Console]System.Console::Write(string)
	ldloc.s 5
	call void [System.Console]System.Console::WriteLine(string)
	ret
}



実行結果

>at0
1
2 3
test
6 test

以上。

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?