了解IL汇编循环

IL代码,

cpp 复制代码
.assembly extern mscorlib {}
 
 .assembly Test
 {
     .ver 1:0:1:0
 }
 .module test.exe
  
 .method static void main() cil managed
 {
     .maxstack 8
     .entrypoint
     .locals init (int32, int32)
   
     ldc.i4 4
     stloc.0        //Upper    limit of the Loop, total 5 
     ldc.i4 0 
     stloc.1        //Initialize the Starting of loop 

Start:     
     //Check if the Counter exceeds
     ldloc.1 
     ldloc.0 
     bgt Exit //If Second variable exceeds the first variable, then exit

     ldloc.1
     call void [mscorlib]System.Console::WriteLine(int32)

     //Increase the Counter
     ldc.i4 1
     ldloc.1
     add
     stloc.1
     br Start
Exit:    
     ret
}

构建运行如下;

我还不是太理解,循环的开始和结束值是不是装入栈;循环变量加1也是在栈上操作;循环中啥也没干,只是输出了循环变量值;bgt、br是跳转语句;有时间继续;

相关推荐
睡前要喝豆奶粉12 小时前
.NET Core Web API中数据库相关配置
数据库·c#·.netcore
周杰伦fans13 小时前
C# 中 Entity Framework (EF) 和 EF Core 里的 `AsNoTracking` 方法
开发语言·c#
她说彩礼65万13 小时前
C#设计模式 单例模式实现方式
单例模式·设计模式·c#
小尧嵌入式14 小时前
STM32启动汇编文件详解及启动逻辑
汇编·arm开发·stm32·单片机
花阴偷移16 小时前
逆向基础--汇编基础(CS与IP) (05)
网络·汇编·网络协议·tcp/ip
Aevget16 小时前
界面控件DevExpress WPF v25.1新版亮点:AI功能的全面升级
c#·.net·wpf·界面控件·devexpress·ui开发
Archy_Wang_117 小时前
Hangfire 入门与实战:在 .NET Core 中实现可靠后台任务处理
c#·.netcore
爱编程的鱼20 小时前
想学编程作为今后的工作技能,学哪种语言适用性更强?
开发语言·算法·c#·bug
清风与日月21 小时前
c#事件委托示例
开发语言·c#
用户37215742613521 小时前
C# 实现在 Excel 中高效生成和操作表格
c#