IL汇编语言读取控制台输入和转换为整数

新建一个testcvt.il;

.assembly extern mscorlib {}
 
 .assembly Test
 {
     .ver 1:0:1:0
 }
 .module test.exe
  
 .method static void main() cil managed
 {
     .maxstack 1
     .entrypoint

    ldstr "\n请输入一个数字:"
    call void [mscorlib]System.Console::Write(string)
    call string [mscorlib]System.Console::ReadLine()
    call int32 [mscorlib]System.Convert::ToInt32(string)     
    call void [mscorlib]System.Console::Write (int32)
 
     ret
 }

我还不了解IL汇编的内容;查了网上资料,上面代码应该是,提示输入一个数字,然后读入控制台输入,是作为字符串读入,然后转换为整数,然后输出这个整数;

构建运行看一下;如下; 

 按照所理解的意思运行了;有中文字符的错误先不管;

现在还不清楚读入的字符放哪,转换为整数放哪,有时间继续;

猜你喜欢

转载自blog.csdn.net/bcbobo21cn/article/details/132123879
今日推荐