开发者

CIL - What is the difference between ldc.i4 33 and ldc.i4.33?

I'm trying to figure out some CIL code. But it seems these two statements do the same thing (according to everything I have read).

ldc.i4 33

an开发者_运维百科d

ldc.i4.33

Both supposedly "load an int32 onto the stack of value 33".

Is this correct? Why? I would have thought that ldc.i4.33 would be "load an integer from local variable index 33 onto the stack".

Where am I going wrong here?


The opcode ldc.i4.33 doesn't exist.

There's a few special (called macro) opcodes, from:

ldc.i4.m1  // has the same effect as: ldc.i4 -1

to

ldc.i4.8   // has the same effect as: ldc.i4  8

But they are just a short form of the ldc.i4 opcode, for common cases, to optimize the CIL size.

Similarly, ldloc.0 is a short form (i.e. has a more compact CIL encoding, but is doing exactly the same as) ldloc 0, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜