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

相关推荐
yufei-coder3 小时前
C# Windows 窗体开发基础
vscode·microsoft·c#·visual studio
dangoxiba4 小时前
[Unity Demo]从零开始制作空洞骑士Hollow Knight第十三集:制作小骑士的接触地刺复活机制以及完善地图的可交互对象
游戏·unity·visualstudio·c#·游戏引擎
AitTech4 小时前
深入理解C#中的TimeSpan结构体:创建、访问、计算与格式化
开发语言·数据库·c#
hiyo5858 小时前
C#中虚函数和抽象函数的概念
开发语言·c#
开心工作室_kaic10 小时前
基于微信小程序的校园失物招领系统的设计与实现(论文+源码)_kaic
c语言·javascript·数据库·vue.js·c#·旅游·actionscript
时光追逐者14 小时前
WaterCloud:一套基于.NET 8.0 + LayUI的快速开发框架,完全开源免费!
前端·microsoft·开源·c#·.net·layui·.netcore
friklogff15 小时前
【C#生态园】打造现代化跨平台应用:深度解析.NET桌面应用工具
开发语言·c#·.net
hiyo5851 天前
C#的面向对象
开发语言·c#
新手unity自用笔记1 天前
项目-坦克大战笔记-子弹的生成
笔记·学习·c#
中游鱼1 天前
Visual Studio C# 编写加密火星坐标转换
kotlin·c#·visual studio