Friday, May 8, 2015

.method private hidebysig static void Main (string [] args) cil managed {// first paragraph stateme


class Program {static void Main (string [] args) {// will be a + b + c, printed results int a = 3; int b = 19; double c = 443.25; Console.WriteLine (a + b + c); // to print d, e, d + e string d = "Hello World!"; string e = "Print Word!"; Console.WriteLine (e); Console.WriteLine (d); Console.WriteLine (d + e );}}
.method private hidebysig static void Main (string [] args) cil managed {// first paragraph statement .entrypoint // Code size 71 (0x47) at home .maxstack 2 .locals init ([0] int32 a, [1] int32 b , [2] float64 c, [3] string d, [4] string e) // the second paragraph of value type memory storage case IL_0000: nop IL_0001:. ldc.i4 3 IL_0002: stloc 0 IL_0003:. ldc.i4. s 19 IL_0005: stloc 1 IL_0006:. ldc.r8 443.25 IL_000f:. stloc 2 IL_0010: ldloc 0 IL_0011:. ldloc 1 IL_0012:. add IL_0013: conv.r8 IL_0014: ldloc 2 IL_0015:. add IL_0016: call void [mscorlib ] System.Console :: WriteLine (float64) // third reference type memory storage case IL_001b: nop IL_001c: ldstr "Hello World!" IL_0021: stloc 3 IL_0022:. ldstr "! Print Word" IL_0027: stloc.se IL_0029 : ldloc.se IL_002b: call void [mscorlib] System.Console :: WriteLine (string) IL_0030: nop IL_0031: at home ldloc 3 IL_0032:. call void [mscorlib] System.Console :: WriteLine (string) IL_0037: nop IL_0038: ldloc . 3 IL_0039: ldloc.se IL_003b: call string [mscorlib] System.String :: Concat (string, string) IL_0040: call void [mscorlib] at home System.Console :: WriteLine (string) at home IL_0045: nop IL_0046: ret} // end of method Program at home :: Main
// Second paragraph value type memory storage case IL_0000: nop // int a = 3; // integer value 3 as int32 push on the computing stack IL_0001: ldc.i4 3 // 3 pop the top of the stack and store. to obtain an index of a local variable b IL_0002: stloc 0 // int b = 19; // integer 19 as int32 push on the computer stack IL_0003:. ldc.i4.s 19 // 19 will pop up and the top of the stack stored at home in the index have a local variable b IL_0005: stloc 1 // double c = 443.25; // the value of the type provided float64 443.25 as F (float) type pushed // You can see here the computing stack. at home the C # Double type == MSIL inside at home float64 type IL_0006: ldc.r8 443.25 // 443.25 eject the top of the stack and stored in the index for the two to give local variables b IL_000f:. stloc 2 // a + b // index Local variables a value of 0 to 3 is loaded on the computing at home stack IL_0010: ldloc 0 // The index value of a local variable b 19 is loaded into the computing stack IL_0011:.. ldloc 1 // add two values and The results pushed on the computing stack, the result is 22 IL_0012: add // a + b value obtained 22 + c // calculate the stack will be in the top 22 value is converted to float64 IL_0013: conv.r8 // The index of the local 2 variable b value 443.25 loaded onto the computing stack IL_0014: ldloc 2 // add two values and the results pushed on the computing stack 465.25 IL_0015:. add // call the function to print the value mscorlib assembly within 465.25 IL_0016: call void [mscorlib] System.Console :: WriteLine (float64)
// Third reference type memory storage case IL_001b: nop // allocate memory for the string Hello World, and push its object reference to the computing stack!. IL_001c: ldstr "! at home Hello World" // Hello World will be top of the stack and pop reference to the string stored in the index is 3 to give local variables d IL_0021:!.! Stloc 3 // allocate memory for the Print Word string, and Push its object reference to the computing stack. IL_0022: "! Print Word"! Ldstr // The top of the stack Print Word character references pop up and stored in the index as a local variable 4 of e IL_0027:! at home Stloc.se // the index of the local variable 4 Print Word character string loaded onto the computing stack and print it out IL_0029: ldloc.se IL_002b: call void [mscorlib] System.Console :: WriteLine (string) at home IL_0030:! Local variables nop // index 3 of Hello World string loaded into computing Stack and print out IL_0031: ldloc 3 IL_0032:. call void [mscorlib] System.Console :: WriteLine (string) IL_0037: nop // d and e of the string at home will be extracted at home and call [mscorlib] System.String :: Concat (string, string) // string a value of two copies of the sum, and then saved to the stack reference IL_0038: ldloc 3 IL_0039:. ldloc.se IL_003b: call string [mscorlib] System.String :: Concat ( string, at home string) // there will be a new string pop stack displayed IL_0040: call void [mscorlib] System.Console :: WriteLine (string) IL_0045: nop IL_0046: ret


No comments:

Post a Comment