了解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汇编和其跳转语句,有时间继续;

相关推荐
_Cherry|2 小时前
Unity中窗口调整
unity·c#·游戏引擎
c#上位机3 小时前
halcon刚性变换(平移+旋转)——vector_angle_to_rigid
人工智能·计算机视觉·c#·上位机·halcon·机器视觉
小码编匠3 小时前
WPF 实现高仿 Windows 通知提示框:工业级弹窗设计与实现
后端·c#·.net
武藤一雄4 小时前
[WPF] 万字拆解依赖属性与附加属性
前端·microsoft·c#·.net·wpf
我好喜欢你~5 小时前
.net---图表库(LiveCharts.Wpf)
c#·wpf
helloworddm5 小时前
GrainType详解
服务器·网络·架构·c#
yngsqq5 小时前
CAD点集生成泰森多边形Voronoi图)——CAD二次开发
c#
武藤一雄5 小时前
C#:深入浅出委托(Delegate/Func/Action/Predicate)
开发语言·后端·microsoft·微软·c#·.net
缺点内向6 小时前
如何在Excel文档中获取分页信息
后端·c#·.net·excel
唐青枫6 小时前
C# Params Collections 详解:比 params T[] 更强大的新语法
c#·.net