Common Intermediate Language: Difference between revisions

Content deleted Content added
removed add-laden content-barren external link
Sample Code: Replaced with output of "csc /optimize" (which removes redundant instructions), and removed all untargeted labels ildasm generates for readability
Line 60:
 
<source lang="cil">
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 2
.locals init (int32 V_0,
[0] int32 num,V_1)
L_0006IL_0000: ldc.i4.2
[1] int32 num2,
[2] bool flag) stloc.0
br.s IL_001f
L_0000: nop
L_0001IL_0004: ldc.i4.2
L_0002: stloc.0 1
L_0003: br.s L_0033 IL_0011
L_0005IL_0008: nop ldloc.0
L_000c: ldloc.1
L_0006: ldc.i4.2
rem
L_0007: stloc.1
L_0008: br brfalse.s L_001f IL_0000
L_001f: ldloc.1
L_000a: nop
L_0030: ldc.i4.1
L_000b: ldloc.0
add
L_000c: ldloc.1
L_0007: stloc.1
L_000d: rem
L_000eIL_0011: ldc ldloc.i4.0 1
L_000b: ldloc.0
L_000f: ceq
blt.s IL_0008
L_0011: ldc.i4.0
L_0020: ldloc.0
L_0012: ceq
L_0028: call void [mscorlib]System.Console::WriteLine(int32)
L_0014: stloc.2
L_0015: ldloc.2 0
L_0011: ldc.i4.0 1
L_0016: brtrue.s L_001a
L_0018: br.s L_0001 add
L_0014: stloc.2 0
L_001a: nop
L_001bIL_001f: ldloc.1 0
L_001c: ldc.i4.1 0x3e8
blt.s IL_0004
L_001d: add
ret
L_001e: stloc.1
}
L_001f: ldloc.1
L_0020: ldloc.0
L_0021: clt
L_0023: stloc.2
L_0024: ldloc.2
L_0025: brtrue.s L_000a
L_0027: ldloc.0
L_0028: call void [mscorlib]System.Console::WriteLine(int32)
L_002d: nop
L_002e: nop
L_002f: ldloc.0
L_0030: ldc.i4.1
L_0031: add
L_0032: stloc.0
L_0033: ldloc.0
L_0034: ldc.i4 1000
L_0039: clt
L_003b: stloc.2
L_003c: ldloc.2
L_003d: brtrue.s L_0005
L_003f: ret
}
</source>