zoukankan      html  css  js  c++  java
  • MSIL条件跳转(简单注释)

    c# code:

    复制代码
    using System;
    public class aidd2008
    {
    public static void Main(String[] argv)
    {
    int x = 10;
    int y = 6;
    if (x > y)
    {
    Console.WriteLine(x);
    }
    else
    {
    Console.WriteLine(y);
    }
    Console.Read();
    }
    }
    复制代码

    MSIL code:

    复制代码
    // =============== CLASS MEMBERS DECLARATION ===================

    .class public auto ansi beforefieldinit aidd2008
    extends [mscorlib]System.Object
    {
    .method public hidebysig static void Main(string[] argv) cil managed
    {
    .entrypoint
    // 代码大小 44 (0x2c)
    .maxstack 2
    .locals init (int32 V_0,
    int32 V_1,
    bool V_2)//定义三个变量
    IL_0000: nop
    IL_0001: ldc.i4.s 10//把整型值10载入堆栈
    IL_0003: stloc.0//把刚才载入堆栈的10赋值给第一个local变量,int x=10
    IL_0004: ldc.i4.6//把整型值6载入堆栈
    IL_0005: stloc.1//把刚才载入堆栈的6赋值给第二个local变量,int y=6
    IL_0006: ldloc.0
    IL_0007: ldloc.1//这两句,把x,y两个local变量载入堆栈
    IL_0008: cgt//比较x,y的大小,结果会保存在堆栈最上方(结果以0或1表示true ,false)
    IL_000a: ldc.i4.0//把0载入堆栈
    IL_000b: ceq//比较0和cgt的运算结果是否相等,结果会保存在堆栈最上方(结果以0或1表示true ,false)
    IL_000d: stloc.2//ceq的运算结果保存入bool变量中
    IL_000e: ldloc.2//再把ceq运算结果载入
    IL_000f: brtrue.s IL_001c//判断跳转,若跳转显式Y,不跳转显式X
    IL_0011: nop
    IL_0012: ldloc.0
    IL_0013: call void [mscorlib]System.Console::WriteLine(int32)
    IL_0018: nop
    IL_0019: nop
    IL_001a: br.s IL_0025

    IL_001c: nop
    IL_001d: ldloc.1
    IL_001e: call void [mscorlib]System.Console::WriteLine(int32)
    IL_0023: nop
    IL_0024: nop
    IL_0025: call int32 [mscorlib]System.Console::Read()
    IL_002a: pop
    IL_002b: ret
    } // end of method aidd2008::Main
    复制代码
  • 相关阅读:
    手动封装 时间选择器(只显示时分)
    页面跳转问题-button 确定提交按钮
    java String类型转 java.sql.time类型
    Mysql 时间处理
    微信-商城商品的图文/商品链接分享(后台数据合成图片+二维码生成)
    np.nan 1.0 2.0 df.apply
    pandas math.isnan
    df.apply
    pandas多条件行数据筛选
    pandas cumsum/sum calc percentage
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/2656780.html
Copyright © 2011-2022 走看看