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

相关推荐
阿松爱学习10 小时前
【Unity开发】Unity长截图功能实现
unity·c#·游戏引擎
水饺编程12 小时前
第2章:Linux 基础,在 root 中创建用户账号
linux·c语言·汇编·1024程序员节
_oP_i13 小时前
Windows 11 家庭中文版 25H2
c#
unicrom_深圳市由你创科技13 小时前
电池化成曲线MES追溯:关键点提取与验证
c#
老王IT13 小时前
C#语言基础语法介绍
开发语言·c#
人丰14 小时前
一次生产卡顿复盘:BI 数据抽取引发 PostgreSQL 长事务事故
数据库·c#
一个风轻云淡15 小时前
从 int $0x80 到 iret:用 gdb 把 getpid 走一遍
linux·c语言·开发语言·汇编
淡海水16 小时前
07-01-源码-.NET Core GC总览与架构
unity·架构·c#·.netcore·gc
weixin_4166600718 小时前
Mermaid流程图导出到Word:SVG、PNG与清晰度如何选择?
开发语言·c#
公子小六21 小时前
基于.NET的Windows窗体编程之WinForms自定义控件(3)
windows·c#·.net·音视频·winforms