申松淦

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
今天看IL,写出了第一个ilasm程序,编译通过,开心
 
.assembly extern mscorlib{}
.assembly Test
{
 .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
  }
 }
}
posted on 2006-05-01 11:47  申松淦  阅读(513)  评论(0编辑  收藏  举报