了解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是跳转语句;有时间继续;

相关推荐
AAA大运重卡何师傅(专跑国道)11 小时前
【无标题】
开发语言·c#
xiaoshuaishuai819 小时前
C# AvaloniaUI ProgressBar用法
开发语言·c#
怣疯knight20 小时前
ida里打印python版本
汇编
是星辰吖~1 天前
X86反汇编_深度学习_栈反汇编分析
汇编
是星辰吖~1 天前
X86反汇编_深度学习_队列反汇编分析
汇编
wearegogog1231 天前
基于C#的电机监控上位机(串口通信+实时波形)
开发语言·c#
△曉風殘月〆1 天前
C#如何Hook托管函数
c#·hook
雪豹阿伟1 天前
18.C# —— 三层结构 + 接口架构实战(UI+Model+DAL+IDAL)
c#·上位机
雪豹阿伟1 天前
17.C# —— 事件
c#·上位机
weixin_428005301 天前
C#调用 AI学习从0开始-第2阶段(Function Calling+工具调用智能体)-第9天实战
人工智能·学习·ai·c#·functioncalling