概要
ilasmでstack machineやってみた。
日本語プログラミング言語のMindで、ilasmをコンパイル、実行してみた。
サンプルコード
出力ファイルは ファイル。
メインとは
「hello.il」で 出力ファイルを 新規オープンし
「.assembly hello {}」で 出力ファイルに 一行書き込み
「.method static void Main() cil managed {」で 出力ファイルに 一行書き込み
「 .entrypoint」で 出力ファイルに 一行書き込み
「 ldstr "Hello World!!"」で 出力ファイルに 一行書き込み
「 call void [mscorlib]System.Console::WriteLine(string)」で 出力ファイルに 一行書き込み
「 ret」で 出力ファイルに 一行書き込み
「}」で 出力ファイルに 一行書き込み
出力ファイルを クローズし
「C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm hello.il」を プログラム実行
「hello」を プログラム実行
。
実行結果
>il0
Microsoft (R) .NET Framework IL Assembler. Version 4.8.9105.0
Copyright (c) Microsoft Corporation. All rights reserved.
Assembling 'hello.il' to EXE --> 'hello.exe'
Source file is ANSI
hello.il(5) : warning : Reference to undeclared extern assembly 'mscorlib'. Attempting autodetect
Assembled global method Main
Creating PE file
Emitting classes:
Emitting fields and methods:
Global Methods: 1;
Emitting events and properties:
Global
Writing PE file
Operation completed successfully
Hello World!!
以上