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

相关推荐
easyboot4 小时前
C#使用pythonnet简单示例
开发语言·python·c#
刘欣的博客5 小时前
c# winform 控件dock 停造位置、摆放顺序问题
c#·winform·dock停靠问题
Java程序员威哥6 小时前
Arthas+IDEA实战:Java线上问题排查完整流程(Spring Boot项目落地)
java·开发语言·spring boot·python·c#·intellij-idea
easyboot7 小时前
C#通过sqlsugar插入数据到postgresql
开发语言·c#
阿蒙Amon7 小时前
C#每日面试题-break、continue和goto的区别
java·面试·c#
mudtools8 小时前
C#中基于Word COM组件的数学公式排版实践
开发语言·c#·word
阿蒙Amon8 小时前
C#每日面试题-简述this和base的作用
java·面试·c#
云草桑8 小时前
C#.net 分布式ID之雪花ID,时钟回拨是什么?怎么解决?
分布式·算法·c#·.net·雪花id
云草桑8 小时前
业务系统设计 权限系统 MAC、DAC、RBAC、ABAC 、核心概念(主体 / 客体 / 用户 - 角色 - 对象)、及数据权限
数据库·c#·权限·数据设计
188号安全攻城狮9 小时前
【PWN】HappyNewYearCTF_2_栈上变量覆写1
linux·运维·汇编·安全·网络安全