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

相关推荐
用户4488466710605 分钟前
.NET进阶——深入理解线程(2)Thread入门到精通
c#·.net
38242782716 分钟前
8086 CPU汇编伪操作汇总
汇编
民乐团扒谱机1 小时前
【微实验】基于Python实现的实时键盘鼠标触控板拾取检测(VS2019,附完整代码)
python·c#·计算机外设
CreasyChan1 小时前
Unity中C#状态模式详解
unity·c#·状态模式
工程师0071 小时前
线程同步的意义
c#·锁机制·线程同步
yugi9878382 小时前
基于C#实现的WiFi信号强度扫描程序
开发语言·c#
sali-tec2 小时前
C# 基于halcon的视觉工作流-章70 深度学习-Deep OCR
开发语言·人工智能·深度学习·算法·计算机视觉·c#·ocr
渡我白衣2 小时前
C++可变参数队列与压栈顺序:从模板语法到汇编调用约定的深度解析
c语言·汇编·c++·人工智能·windows·深度学习·硬件架构
武藤一雄2 小时前
C#中常见集合都有哪些?
开发语言·微软·c#·.net·.netcore
唐青枫2 小时前
C#.NET struct 全解析:什么时候该用值类型?
c#·.net