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

相关推荐
云草桑1 小时前
.net AI开发04 第八章 引入RAG知识库与文档管理核心能力及事件总线
数据库·人工智能·microsoft·c#·asp.net·.net·rag
曹牧3 小时前
C#:窗体构造函数无法引用窗体控件
开发语言·c#
iAkuya3 小时前
(leetcode)力扣100 54实现Trie树
算法·leetcode·c#
xb11323 小时前
C#使用Cancellation来取消异步任务
开发语言·c#
m0_748229993 小时前
C与C#:编程语言的核心差异解析
c语言·开发语言·c#
m0_748229994 小时前
Laravel7.x核心特性全解析
c语言·数据库·c#
阿蒙Amon4 小时前
C#每日面试题-Task和Thread的区别
java·面试·c#
ytttr8736 小时前
C#实现海康威视智能车牌识别
开发语言·c#
bubiyoushang8887 小时前
C#开发的TCP/UDP网络调试助手
tcp/ip·udp·c#
切糕师学AI7 小时前
ARM 汇编指令系列文章导读
汇编·arm开发