2007年10月5日星期五

[转]jvm opcode instruction

A.3 Instructions by Category

This section contains a listing of the instructions and what they do, grouped by category. Here is a key to the descriptions:

aThe top slot of the stack. May be an int, float, or reference.
bThe second stack slot. May be an int, float, or reference.
cThe third stack slot. May be an int, float, or reference.
dThe fourth stack slot. May be an int, float, or reference.
abThe long or double on top of the stack, made up of slots a and b.
cdThe long or double second on the stack, made up of slots c and d.

A.3.1 Arithmetic

MnemonicArgumentsDescription
daddAdd double (ab+cd)
dcmpgCompare double
dcmplCompare double
ddivDivide double (ab/cd)
dmulMultiply double (ab*cd)
dnegNegate double (-ab)
dremRemainder double (ab%cd)
dsubSubtract double (ab-cd)
faddAdd float (a+b)
fcmpgCompare float
fcmplCompare float
fdivDivide float (a/b)
fmulMultiply float (a*b)
fnegNegate float (-a)
fremRemainder float (a%b)
fsubSubtract float (a-b)
i2bConvert int to byte
i2cConvert int to char
i2sConvert int to short
iaddAdd int (a+b)
iandBitwise and ints (a & b)
idivDivide ints (a/b)
imulMultiply ints (a*b)
inegNegate int (-a)
iorBitwise or ints (a b)
iremRemainder int (a%b)
ishlShift int left (a << b)
ishrShift int right (a >> c)
isubSubtract int (a-b)
iushrUnsigned shift int right (a >>> c)
ixorBitwise xor ints (a ^ b)
laddAdd long (ab+cd)
landBitwise and longs (ab & cd)
lcmpCompare longs
ldivDivide long (ab/cd)
lmulMultiply long (ab*cd)
lnegNegate long (-ab)
lorBitwise or longs (ab cd)
lremRemainder longs (ab%cd)
lshlShift long left (bc << 9)
lshrShift long right (bc >> 9)
lsubSubtract long (ab-cd)
lushrUnsigned shift long right (bc >>> 9)
lxorBitwise x or longs (ab ^ cd)

A.3.2 Array

MnemonicArgumentsDescription
aaloadPush array element a from array b
aastoreStore a in array element b of array c
anewarrayclassCreate array of class, length a
arraylengthLength of array a
athrowThrow exception a
baloadPush array element a from array b
bastoreStore a in array element b of array c
caloadPush array element a from array b
castoreStore a in array element
daloadPush array element a from array b
dastoreStore ab in array element
faloadPush array element a from array b
fastoreStore a in array element b of array c
ialoadPush array element a from array b
iastoreStore a in array element
laloadPush array element a from array b
lastoreStore ab in array element c of array d
multianewarrayclass nCreate multidimensional array with first n dimensions initialized to lengths a, b, c. . .
newarraytypeCreate array of type, length a
saloadPush array element a from array b
sastoreStore a in array element b of array c

A.3.3 Constant

MnemonicArgumentsDescription
aconst_nullPush null reference
bipushnPush int between ?28 and 127
dconst_0Push 0 (double)
dconst_1Push 1 (double)
fconst_0Push 0 (float)
fconst_1Push 1 (float)
fconst_2Push 2 (float)
iconst_0Push 0 (int)
iconst_1Push 1 (int)
iconst_2Push 2 (int)
iconst_3Push 3 (int)
iconst_4Push 4 (int)
iconst_5Push 5 (int)
iconst_m1Push ?(int)
lconst_0Push 0 (long)
lconst_1Push 1 (long)
ldcxPush x (a constant int, float, or String)
ldc_wxPush x (a constant int, float, or String)
ldc2_wxPush x (a constant long or double)
sipushnPush int between ?2,768 and 32767

A.3.4 Control

MnemonicArgumentsDescription
areturnReturn reference from method
dreturnReturn double from method
freturnReturn float from method
gotolabelBranch always
goto_wlabelBranch always to label
if_acmpeqlabelBranch if a == b
if_acmpnelabelBranch if a != b
if_icmpeqlabelBranch if a > b
if_icmpgelabelBranch if a >= b
if_icmpgtlabelBranch if a > b
if_icmplelabelBranch if a <= b
if_icmpltlabelBranch if a < b
if_icmpnelabelBranch if a != b
ifeqlabelBranch if a == 0
ifgelabelBranch if a >= 0
ifgtlabelBranch if a > 0
iflelabelBranch if a <= 0
ifltlabelBranch if a < 0
ifnelabelBranch if a != 0
ifnonnulllabelBranch if a is not null
ifnulllabelBranch if a is null
ireturnReturn int from method
jsrlabelBranch to label; push return location
jsr_wlabelJump to label
lookupswitch

tag1: label1

tag2: label2...

default: labeln

Branch to label1 on tag1, label2 on tag2, . . . , labeln otherwise
lreturnReturn long from method
nopDo nothing
retnBranch to location in variable n
returnReturn from method
tableswitch

n

label1

label2

. . .

default: labeln

Branch to label1 on n, label2 on n+1, . . . , labeln otherwise

A.3.5 Data Type Conversion

MnemonicArgumentsDescription
d2fConvert double ab to float
d2iConvert double ab to int
d2lConvert double ab to long
f2dConvert float a to double
f2iConvert float a to int
f2lConvert float a to long
i2dConvert int a to double
i2fConvert int a to float
i2lConvert int a to long
l2dConvert long ab to double
l2fConvert long ab to float
l2iConvert long ab to int

A.3.6 Object

MnemonicArgumentsDescription
checkcastclassThrow exception if a is not an instance of class
getfieldclass/field descPush object field from object a
getstaticclass/field descPush static field
instanceofclassPush 1 if a is class, 0 otherwise
invokeinterfaceclass/method desc nInvoke method through interface with n argument words
invokespecialclass/method descInvoke method directly
invokestaticclass/method descInvoke static method
invokevirtualclass/method descInvoke method virtually
newclassCreate new object of class
putfieldclass/field descStore a in object field
putstaticclass/field descStore a in static field

A.3.7 Stack Manipulation

MnemonicArgumentsDescription
dupDuplicate a
dup_x1Duplicate a, insert under b
dup_x2Duplicate a, insert under c
dup2Duplicate ab
dup2_x1Duplicate ab, insert under c
dup2_x2Duplicate ab, insert under d
popRemove a
pop2Remove ab
swapSwap a and b

A.3.8 Synchronization

MnemonicArgumentsDescription
monitorenterGain control of monitor of a
monitorexitRelease monitor of a

A.3.9 Variable

MnemonicArgumentsDescription
aloadnPush local variable n
aload_0Push local variable 0
aload_1Push local variable 1
aload_2Push local variable 2
aload_3Push local variable 3
astorenStore a in local variable n
astore_0Store a in local variable 0
astore_1Store a in local variable 1
astore_2Store a in local variable 2
astore_3Store a in local variable 3
dloadnPush local variable n
dload_0Push local variable 0
dload_1Push local variable 1
dload_2Push local variable 2
dload_3Push local variable 3
dstorenStore ab in local variable n
dstore_0Store ab in local variable 0
dstore_1Store ab in local variable 1
dstore_2Store ab in local variable 2
dstore_3Store ab in local variable 3
floadnPush local variable n
fload_0Push local variable 0
fload_1Push local variable 1
fload_2Push local variable 2
fload_3Push local variable 3
fstorenStore a in local variable n
fstore_0Store a in local variable 0
fstore_1Store a in local variable 1
fstore_2Store a in local variable 2
fstore_3Store a in local variable 3
iincn incrementIncrement local variable
iloadnPush local variable n
iload_0Push local variable 0
iload_1Push local variable 1
iload_2Push local variable 2
iload_3Push local variable 3
istorenStore a in local variable n
istore_0Store a in local variable 0
istore_1Store a in local variable 1
istore_2Store a in local variable 2
istore_3Store a in local variable 3
lloadnPush local variable n
lload_0Push local variable 0
lload_1Push local variable 1
lload_2Push local variable 2
lload_3Push local variable 3
lstorenStore ab in local variable n
lstore_0Store ab in local variable 0
lstore_1Store ab in local variable 1
lstore_2Store ab in local variable 2
lstore_3Store ab in local variable 3
wideinstruction argumentsLike instruction, except using wider range of values

没有评论:

free counters