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

相关推荐
Warson_L1 天前
.NET 8 速成笔记 16:API 框架到底怎么用,谁是自带的、谁是自己写的、配置和测试库如何关联
c#·.net
淡海水1 天前
01-10-认知篇-对比-方案选型矩阵
矩阵·c#·excel·游戏开发·luban
reasonsummer1 天前
【办公类-178-01】20261204医保需要“幼儿园园通学籍证明截图”(Python页面截图+转PDF)
开发语言·c#
yuzhiboyouye1 天前
我做web前端八年多了,转C#怎么样,而且我现在的java是初级水平,问的通义
c#
hookserver1 天前
企业微信 iPad 协议二次开发实战应用指南
java·汇编·微信·企业微信·ipad
yuzhiboyouye1 天前
我现在初级java,中高级web前端。那我C#的学习路径是?问的tare chat智能体
c#
看浪的路人2 天前
第10讲:运维 Agent——从「被动救火」到「自动驾驶」
c#·linq
Jazz_z2 天前
C# 实现 Word 文档内容复制
开发语言·c#·word
学逆向的3 天前
C++多态 汇编分析
开发语言·汇编·c++·网络安全
水饺编程3 天前
第1章,本专栏新增的可自由修改的 Linux 0.12 内核
linux·c语言·汇编