了解IL汇编跳转语句

il代码,

cpp 复制代码
.assembly extern mscorlib {}
 
 .assembly Test
 {
     .ver 1:0:1:0
 }
 .module test.exe
  
 .method static void main() cil managed
 {
     .maxstack 5
     .entrypoint
     
     ldstr "Enter First Number"
     call void [mscorlib]System.Console::WriteLine (string)
     call  string [mscorlib]System.Console::ReadLine ()
     call int32 [mscorlib]System.Int32::Parse(string)

     ldstr "Enter Second Number"
     call void [mscorlib]System.Console::WriteLine (string)
     call  string [mscorlib]System.Console::ReadLine ()
     call int32 [mscorlib]System.Int32::Parse(string)

     ble smaller
     ldstr "Second Number is smaller than first."    
     call void [mscorlib]System.Console::WriteLine (string)

     br exit

smaller:
     ldstr "First number is smaller than second."    
     call void [mscorlib]System.Console::WriteLine (string)
exit:    
     ret
 }

提示输入数,获取输入数,转换输入数为整型;然后这句实现比较,

ble smaller,它告诉编译器去检查栈里面的第一数是否小于或等于第二个数,如果是小于,那么它将会跳转到"smaller"这个标签处;

构建运行如下;

还不是很了解IL汇编和其跳转语句,有时间继续;

相关推荐
helloworddm1 分钟前
LocalGrainDirectory详解
c#
武藤一雄34 分钟前
.NET 中常见计时器大全
microsoft·微软·c#·.net·wpf·.netcore
Lv11770081 小时前
Visual Studio中Array数组的常用查询方法
笔记·算法·c#·visual studio
旧梦吟2 小时前
脚本语言 汇编
汇编
wearegogog1232 小时前
基于C#的FTP客户端实现方案
java·网络·c#
wuguan_2 小时前
C#之ArrayList
c#·arraylist
CreasyChan2 小时前
C# 异步编程详解
开发语言·windows·c#
iCxhust2 小时前
8088单板机C语言汇编混合编程实验方法与步骤
c语言·汇编·单片机·嵌入式硬件·微机原理
正运动技术2 小时前
全国产强实时运动控制内核(十二):实时在线变速实现多段速的软着陆
嵌入式硬件·c#·运动控制·运动控制器·运动控制卡·正运动·pc上位机
m5655bj3 小时前
使用 C# 设置 Word 段落对齐样式
开发语言·c#·word