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

相关推荐
bugcome_com1 小时前
bugcome —— 个人独立开发 6 年商业计划书
c#
real_ben_ladeng5 小时前
程序人生—Hello’s P2P 2dc736403375808d93f9c97fc816f2f8
c语言·汇编·硬件架构
bugcome_com6 小时前
C# 中的封装与访问修饰符
c#
游乐码7 小时前
c#成员属性
开发语言·c#
切糕师学AI8 小时前
ARM标准汇编(armasm)中的“定义”(Assembler Directive)
汇编·arm开发
Never_Satisfied8 小时前
在c#中,如何删除字符串中的第x个字符
开发语言·c#
Never_Satisfied9 小时前
在c#中,缩放jpg文件的尺寸
算法·c#
Never_Satisfied9 小时前
在c#中,控件的事件执行耗时操作导致窗体无法及时处理绘制、鼠标点击
开发语言·c#
切糕师学AI9 小时前
ARM标准汇编(armasm)中的标号(Label)
汇编·arm
zls36536510 小时前
C# WPF canvas中绘制缺陷分布map并实现缩放
开发语言·c#·wpf