Question

Please have a look at the MSIL code below:

IL_00:  ldstr      "Hello World"
IL_05:  call       void [mscorlib]System.Console::WriteLine(string)
IL_10:  ret

What is meant by IL_00, IL_05 and IL_10? I read Operating System concepts at university so I understood at the time how the Windows operating system allocates virtual memory to a process. I also don't understand why in the case of the above; the addresses increment by 5.

The managed code was generated from a VB.NET application.

I have spent some time Googling this and I have read a few articles on MSDN. I am still not clear and hence the reason for the question.

Was it helpful?

Solution

They are just fake "addresses" generated by your IL disassembler. The LDSTR opcode requires one byte for the opcode, 0x72, and 4 bytes for the operand. Which is a token value that selects the string from the metadata table that stores string literals. So the next IL opcode starts at offset 5. Same recipe there, CALL requires one byte for the opcode, 0x28, and 4 bytes for the operand, the method token. So the next IL opcode starts at offset 10. RET requires 1 byte, 0x2A and has no operand. Total IL code size is 11 bytes.

Your disassembler generates these "addresses" to show you the target of a branch instruction. You don't have one, try disassembling code that uses an if() statement to see that. They are otherwise immaterial since the jitter translates this code to machine code which looks very different.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top