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

相关推荐
执迷不悟8236 小时前
ARM--汇编指令
汇编·arm开发
北域码匠7 小时前
Karatsuba乘法超详细解析(原理+流程+性能分析+纯原生C#无第三方库完整实现)
算法·c#·大数乘法·高精度计算·数据结构与算法·分治算法·karatsuba 乘法
syker9 小时前
WinMaster v0.3.3 完整使用手册
c#
Risehuxyc11 小时前
C# 将doc转换为docx
开发语言·c#·xhtml
czhc114007566313 小时前
717:回调r=>{};norice;fov;pcb;寸动距离;背钻主钻孔;
c#
henreash14 小时前
Orleans10的非对称部署(部署更友好的方式)
c#
geovindu15 小时前
CSharp: Recursion Algorithm
开发语言·后端·算法·c#·递归算法
geats人山人海16 小时前
c# 第八章 多态与案例
开发语言·c#