温少的日志

我希望我所作的事情对别人有所帮助!
随笔 - 184, 文章 - 1, 评论 - 1094, 引用 - 11
数据加载中……

MSIL指令速查表

最初阅读IL的时候,很多指令会记不住,你把以下这两个表格打印下来,备在案前,可供速查!

最初我阅读IL时,就是这么做的。后来我教别人反编译,都要别人先打印这份表格。

自己查文档也可以获得一下资料。不过,或许我整理的这个表格,速查更方便!

下载地址:http://files.cnblogs.com/jobs/msil.rar

Base Instructions

 

Instruction

Description

Stack Transition

1

add

add two values, returning a new value

…, value1, value2à…, result

2

add.ovf.<signed>

add integer value with overflow check

…, value1, value2à…, result

3

and

bitwise AND

…, value1, value2 à…, result

4

arglist

get argument list

à …, argListHandle

5

beq.<length>

branch on equal

…, value1, value2 à

6

bge.<length>

branch on greater than or equal to

…, value1, value2 à

7

bge.un.<length>

branch on greater/equal, unsigned or unordered

…, value1, value2 à

8

bgt.<length>

branch on greater than

…, value1, value2 à

9

bgt.un<length>

branch on greater than, unsigned or unordered

…, value1, value2 à

10

ble.<length>

branch on less than or equal to

…, value1, value2 à

11

ble..un<length>

branch on less/equal, unsigned or unordered

…, value1, value2 à

12

blt.<length>

branch on less than

…, value1, value2 à

13

blt.un.<length>

branch on less than, unsigned or unordered

…, value1, value2 à

14

bne.un<length>

branch on not equal or unorded

…, value1, value2 à

15

br.<length>

unconditional branch

…, à

16

break

breakpoint instruction

…, à

17

brfalse.<length>

branch on false, null, or zero

…, value à

18

brtrue.<length>

branch on non-false or non-null

…, value à

19

call

call a method

…, arg1, arg2 … argn à …, retVal (not always returned)

20

calli

indirect method call

…, arg1, arg2 … argn, ftn à …, retVal (not always returned)

21

ceq

compare equal

…, value1, value2à…, result

22

cgt

compare greater than

…, value1, value2à…, result

23

cgt.un

compare greater than, unsigned or unordered

…, value1, value2à…, result

24

ckfinite

check for a finite real number

…, value à …, value

25

clt

compare less than

…, value1, value2à…, result

26

clt.un

compare less than, unsigned or unordered

…, value1, value2à…, result

27

conv.<to type>

data conversion

…, value à …, result

28

conv.ovf<to type>

data conversion with overflow detection

…, value à …, result

29

conv.ovf.<to type>.un

unsigned data conversion with overflow detection

…, value à …, result

30

cpblk

copy data from memory to memory

…, destaddr, srcaddr, size à

31

div

divide values

…, value1, value2à…, result

32

div.un

divide integer values, unsigned

…, value1, value2à…, result

33

dup

duplicate the top value of the stack

…, value à …, value, value

34

endfilter

end filter clause of SEH

…, value à

35

endfinally

end the finally or fault clause of exception block

à

36

initblk

initialize a block of memory to a value

…, addr, value, size à

37

jmp

jump to method

à

38

ldarg.<length>

load argument onto the stack

à …, value

39

ldarga.<length>

load an argument address

…, à …, address of argument number argNum

40

ldc.<type>

load numeric constant

à …, num

41

ldftn

load method pointer

à …, ftn

42

ldind.<type>

load value indirect onto the stack

…, addr à …, value

43

ldloc

load local variable onto the stack

à …, value

44

ldloca.<length>

load local variable address

à …, address

45

ldnull

load a null pointer

à …, null value

46

leave.<length>

exit a protected region of code

…, à

47

localloc

allocate space in the local dynamic memory pool

size à address

48

mul

multiply values

…, value1, value2 à …, result

49

mul.ovf<type>

multiply integer values with overflow check

…, value1, value2 à …, result

50

neg

negate

…, value à …, result

51

nop

no operation

…, à …,

52

not

bitwise complement

…, value à …, result

53

or

bitwise OR

…, value1, value2 à …, result

54

pop

remove the top element of the stack

…, value à

55

rem

compute the remainder

…, value1, value2 à …, result

56

rem.un

compute integer remainder, unsigned

…, value1, value2 à …, result

57

ret

return from method

retVal on callee evaluation stack (not always present) à

…, retVal on caller evaluation stack (not always present)

58

shl

shift integer left

…, value, shiftAmount à …, result

59

shr

shift integer right

…, value, shiftAmount à …, result

60

shr.un

shift integer right, unsigned

…, value, shiftAmount à …, result

61

starg.<length>

store a value in an argument slot

…, value à …,

62

stind.<type>

store value indirect from stack

…, addr, val à

63

stloc

pop value from stack to local variable

…, value à

64

sub

substract numeric values

…, value1, value2 à …, result

65

sub.ovf.<type>

substract integer values, checking for overflow

…, value1, value2 à …, result

66

switch

table switch on value

…, value à …,

67

xor

bitwise XOR

..., value1, value2 à ..., result


Object Model Instructions

 

Instruction

Description

Stack Transition

1

box

convert value type to object reference

…, valueType à …, obj

2

callvirt

call a method associated, a runtime, with an object

…, obj, arg1, … argN à …, returnVal (not always returned)

3

cast class

cast an object to a class

…, obj à …, obj2

4

cpobj

copy a value type

…, destValObj, srcValObj à …,

5

initobj

Initialize a value type

…,addrOfValObj à …,

6

isinst

test if an object is is an instance of a class or interface

…, obj à …, result

7

ldelem.<type>

load an element fo an array

…, array, index à …, value

8

ldelema

load address of an element of an array

…, array, index à …, address

9

ldfld

load field of an object

…, obj à …, value

10

ldflda

load field address

…, obj à …, address

11

ldlen

load the length of an array

…, array à …, length

12

ldobj

copy value type to the stack

…, addrOfValObj à …, valObj

13

ldsfld

load static field of a class

…, à …, value

14

ldsflda

load static field address

…, à …, address

15

ldstr

load a literal string

…, à …, string

16

ldtoken

load the runtime representation of metadata token

à …, RuntimeHandle

17

ldvirtfn

load a virtual method pointer

… object à …, ftn

18

mkrefany

push a typed reference on the stack

…, ptr à …, typedRef

19

newarr

Create a zero-base, on-dimensional array

…, numElems à …, array

20

newobj

create a new object

…, arg1, … argN à …, obj

21

refanytype

load the type out of a typed reference

…, TypedRef à …, type

22

refanyval

load the address out of a typed reference

…, TypedRef à …, address

23

rethrow

rethrow the current exception

…, à …,

24

sizeof

load the size in bytes of a value type

…, à …, size (4 bytes, unsigned)

25

stelem.<type>

store an element of an array

…, array, index, value à …,

26

stfld

store into a field of an object

…, obj, value à …,

27

stobj

store a value type from the stack into memory

…, addr, valObj à …,

28

stsfld

store a static field of class

…, val à …,

29

throw

throw an exception

…, object à …,

30

unbox

convert boxed value type to its raw form

 

posted on 2004-07-21 02:45 温少 阅读(2363) 评论(12)  编辑 收藏 网摘 所属分类: .NET推荐阅读

评论

#1楼   回复  引用    

Good..上次偶写了一个Emit使用(1)来着了,一直没时间去写下面的..:)

过几天,等事搞定了.再完成吧:)
2004-07-21 03:04 | hBifTs

#2楼   回复  引用    

thx 共享 ,不错
2004-07-21 07:22 | lion

#3楼   回复  引用    

正在寻找,以后大家什么都可以坐享其成了,感谢
2004-07-21 08:12 | bestcomy

#4楼   回复  引用    

呵呵,其实在
E:\VS.NET 2003\SDK\v1.1\Tool Developers Guide\docs

这个下面就有好多的东西,都是关于IL/CLR之类的资料,算是很详细的了,Google都很难找到比这个更详细的信息了。
2004-07-21 09:24 | sumtec

#5楼   回复  引用    

如果你曾经花时间阅读IL,你就会发现我这个文档速查非常方便,比Tool Developers Guide\docs 下的文档要好查,好用 :)
2004-07-21 09:57 | 温少

#6楼   回复  引用    

的确是个好东西~~(虽然我很少看IL。。。。呵呵)
2004-07-21 13:05 | twodays

#7楼   回复  引用    

温少这个贴在电脑旁速查很好。
另外,Inside Microsoft .NET IL Assemble是案头必备手册,虽说作者的文笔不敢恭维,内容可够全的。和win32asm比,IL确实容易多了,字面上也能猜出个八九不离十,看一段时间的话基本上就没多少障碍了。
2004-07-22 00:57 | 古风

#8楼   回复  引用    

“古风”前辈也来捧场,大大的欢迎!!
2004-07-22 00:58 | 温少

#9楼   回复  引用    

我经常要反汇编自己做的程序,以便学习的更深入。
我发现编译出来的il代码.net 1.1的确实不如.net 2.0。

1.1:
// 代码大小 34 (0x22)
.maxstack 2
.locals init ([0] class [mscorlib]System.Exception ex)
IL_0000: nop
IL_0001: nop
.try
{
IL_0002: call void [mscorlib]System.Console::WriteLine()
IL_0007: nop
IL_0008: leave.s IL_001f
} // end .try
catch [mscorlib]System.Exception
{
IL_000a: dup
IL_000b: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(class [mscorlib]System.Exception)
IL_0010: stloc.0
IL_0011: nop
IL_0012: call void [mscorlib]System.Console::WriteLine()
IL_0017: nop
IL_0018: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_001d: leave.s IL_001f
} // end handler
IL_001f: nop
IL_0020: nop
IL_0021: ret

2.0:
// 代码大小 27 (0x1b)
.maxstack 2
.locals init ([0] class [mscorlib]System.Exception ex)
.try
{
IL_0000: call void [mscorlib]System.Console::WriteLine()
IL_0005: leave.s IL_001a
} // end .try
catch [mscorlib]System.Exception
{
IL_0007: dup
IL_0008: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(class [mscorlib]System.Exception)
IL_000d: stloc.0
IL_000e: call void [mscorlib]System.Console::WriteLine()
IL_0013: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_0018: leave.s IL_001a
} // end handler
IL_001a: ret


少了不少看起来没用的指令。
2007-09-28 14:42 | idreamer[未注册用户]

#10楼   回复  引用    

我理解错啦,nop是空指令,为了调试方便
2007-11-08 16:51 | idreamer[未注册用户]

#11楼   回复  引用  查看    

转了...谢谢!
2008-08-17 22:41 | gecko      

#12楼   回复  引用    

谢谢,正好用上
2008-12-25 09:28 | 将军[未注册用户]



发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 26022




相关文章:

相关链接: