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

相关推荐
就是有点傻29 分钟前
在C#中,可以不实例化一个类而直接调用其静态字段
c#
软件黑马王子30 分钟前
C#系统学习第八章——字符串
开发语言·学习·c#
阿蒙Amon31 分钟前
C#读写文件:多种方式详解
开发语言·数据库·c#
就是有点傻2 小时前
C#如何实现中英文快速切换
数据库·c#
liulilittle4 小时前
C++ i386/AMD64平台汇编指令对齐长度获取实现
c语言·开发语言·汇编·c++
工业互联网专业4 小时前
汇编与接口技术:8259中断实验
汇编·单片机·嵌入式硬件·8259中断实验
一名用户6 小时前
unity实现梦日记式传送组件
后端·c#·unity3d
阿蒙Amon7 小时前
C#扩展方法全解析:给现有类型插上翅膀的魔法
开发语言·c#
small_wh1te_coder18 小时前
硬件嵌入式学习路线大总结(一):C语言与linux。内功心法——从入门到精通,彻底打通你的任督二脉!
linux·c语言·汇编·嵌入式硬件·算法·c
江山如画,佳人北望21 小时前
C#程序入门
开发语言·windows·c#