मुझे लगता है मैं तो मैं मैं प्रत्येक पंक्ति क्या करता है सही है अगर पूछ रहा हूँ से पहले विधानसभा क्रमादेशित कभी नहीं किया है सी #क्या मैं इस एमएसआईएल कोड को सही ढंग से समझता हूं?
// test.Program
private static void Main()
{
int x = 5;
int y = 100;
Console.WriteLine(y + ", " + x);
}
में निम्न कोड है और मैं आईएल कोड पढ़ रहा हूँ,।
.method private hidebysig static
void Main() cil managed
{
// Method begins at RVA 0x2058
// Code size 33 (0x21)
.maxstack 3 // maximum stack in this method is 3
.entrypoint // method is initial entry point
.locals init (// reserves memory for x and y variables
[0] int32 x, // x variable is reserved on position 0 of the stack
[1] int32 y // y variable is reserved on position 1 of the stack
)
IL_0000: ldc.i4.5 // integer of 4 bytes in size and the value of 5 is loaded onto the evaluation stack position 0
IL_0001: stloc.0 // put evaluation stack position 0 into the stack position 0, the evaluation stack is emptied
IL_0002: ldc.i4.s 100 // integer of 4 bytes in size and the value of 100 is loaded onto the evaluation stack position 0
IL_0004: stloc.1 // put evaluation stack position 0 onto the stack position 1, the evaluation stack is emptied
IL_0005: ldloc.1 // load stack position 1 into the evaluation stack position 0
IL_0006: box [mscorlib]System.Int32 // box last valuetype placed on evaluation stack, replace valuetype with reference on evaluation stack position 0, do not empty stack
IL_000b: ldstr ", " // put reference to string on evaluation stack position 1
IL_0010: ldloc.0 // load stack position 0 into the evaluation stack position 2
IL_0011: box [mscorlib]System.Int32 // box last valuetype placed on evaluation stack, replace valuetype with reference on evaluation stack position 0, do not empty stack
IL_0016: call string [mscorlib]System.String::Concat(object, object, object) // call Concat, pass values on evaluation stack, empty evaluation stack, put result of concat on evaluationstack
IL_001b: call void [mscorlib]System.Console::WriteLine(string) // pass first value in evaluation stack
IL_0020: ret // return
} // end of method Program::Main
क्या मैं इस कार्यक्रम को सही ढंग से समझता हूं?
जब कुछ पदों की संख्या किसी चीज से खाई जाती है (उदाहरण के लिए कॉल करें), केवल शीर्ष पदों का उपभोग किया जाता है? और फिर मूल्यांकन स्टैक पर कई मूल्य वापस रखता है? मुझे लगता है कि यह सच है, क्योंकि यह सब के बाद 'स्टैक' है, लेकिन मैं बस यह सुनिश्चित करने के लिए कह रहा हूं। – ProgrammerAtWork
हां। एक काल्पनिक ऑपरेशन जो ए, बी, सी, डी और वाई, जेड का उत्पादन करेगा, स्टैक * से 4 प्रविष्टियों को पॉप करेगा, परिणाम की गणना करें *, और उसके बाद 2 नई प्रविष्टियों को धक्का देगा। (*) उस क्रम में संक्षेप में नहीं, लेकिन धक्का हमेशा आखिरी होते हैं। – quetzalcoatl