今天看IL,写出了第一个ilasm程序,编译通过,开心
.assembly extern mscorlib{}
.assembly Test
{
.ver 1:0:0:0
}
.module Test.exe
{
.ver 1:0:0:0
}
.module Test.exe
.namespace Test
{
.class public auto ansi Test
{
.method public static void Main() cil managed
{
.entrypoint
.maxstack 2
ldstr "Please input the first number"
call void [mscorlib]System.Console::WriteLine(string)
call string [mscorlib]System.Console::ReadLine()
call int32 [mscorlib]System.Convert::ToInt32(string)
ldstr "Please input the sencond number"
call void [mscorlib]System.Console::WriteLine(string)
call string [mscorlib]System.Console::ReadLine()
call int32 [mscorlib]System.Convert::ToInt32(string)
call bool Test.math::IsGreat(int32,int32)
brfalse.s les
ldstr "First number is Gread than sencond Number"
call void [mscorlib]System.Console::WriteLine(string)
br finished
les:
ldstr "First number is less than sencond Number"
call void [mscorlib]System.Console::WriteLine(string)
finished:
ldstr "Thank you"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
.class public auto ansi math
{
.method public static bool IsGreat(int32,int32) cil managed
{
.maxstack 2
ldarg.0
ldarg.1
ble.s les
ldc.i4.1
ret
les:
ldc.i4.0
ret
}
}
}
{
.class public auto ansi Test
{
.method public static void Main() cil managed
{
.entrypoint
.maxstack 2
ldstr "Please input the first number"
call void [mscorlib]System.Console::WriteLine(string)
call string [mscorlib]System.Console::ReadLine()
call int32 [mscorlib]System.Convert::ToInt32(string)
ldstr "Please input the sencond number"
call void [mscorlib]System.Console::WriteLine(string)
call string [mscorlib]System.Console::ReadLine()
call int32 [mscorlib]System.Convert::ToInt32(string)
call bool Test.math::IsGreat(int32,int32)
brfalse.s les
ldstr "First number is Gread than sencond Number"
call void [mscorlib]System.Console::WriteLine(string)
br finished
les:
ldstr "First number is less than sencond Number"
call void [mscorlib]System.Console::WriteLine(string)
finished:
ldstr "Thank you"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
.class public auto ansi math
{
.method public static bool IsGreat(int32,int32) cil managed
{
.maxstack 2
ldarg.0
ldarg.1
ble.s les
ldc.i4.1
ret
les:
ldc.i4.0
ret
}
}
}