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

相关推荐
FuckPatience1 小时前
C# SqlSugar+SQLite: 无法加载 DLL“e_sqlite3”: 找不到指定的模块
开发语言·c#
HelloRevit1 小时前
Windows Server SMB 共享文件 回收站
windows·c#
曹牧1 小时前
C#:ToDouble
开发语言·c#
yongui478342 小时前
使用C#实现Excel实时读取并导入SQL数据库
数据库·c#·excel
阿蒙Amon3 小时前
C#每日面试题-简述匿名方法
java·面试·c#
波波0073 小时前
C# 中静态类的正确与错误用法
c#
阿蒙Amon3 小时前
C#每日面试题-简述匿名类型
开发语言·c#
jghhh013 小时前
C#中实现不同进程(EXE)间通信的方案
java·单例模式·c#
2501_930707784 小时前
使用C#代码在 Word 中删除页眉或页脚
开发语言·c#·word
警醒与鞭策4 小时前
大模型对比
unity·性能优化·c#·游戏引擎·cursor