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

相关推荐
njsgcs13 小时前
c# solidworks 工程图获得展开视图不在固定面螺纹特征的位置
开发语言·c#·solidworks
深海潜水员16 小时前
【从零开始的C#游戏开发课程】- FarmStory1.0 日志系统和游戏资源的管理
游戏·c#·monogame
叶帆16 小时前
【YFIOs】用C#开发硬件之WiFi网络
开发语言·网络·c#
天下无敌笨笨熊17 小时前
C# LINQ开发心得
c#·linq
小白不白11118 小时前
Invoke的用法
开发语言·人工智能·数码相机·计算机视觉·c#
疯狂打码的少年19 小时前
【程序语言与编译】程序设计语言分类(机器/汇编/高级)
汇编·笔记
FuckPatience19 小时前
C# 链表元素的引用地址分析
链表·c#
hoiii18719 小时前
C# Txt/Excel/Access 导入导出工具
开发语言·c#·excel
专注VB编程开发20年20 小时前
TFTP 与FTP核心区别:UDP和TCP
c#·tftp