(JavaCard)JavaCard222VM Spec(JavaCard 2.2.2 虚拟机规范-中英文对照,第七章)

来源:互联网 发布:java工程师都考什么 编辑:程序博客网 时间:2024/06/07 23:29

Java Card Virtual Machine Instruction Set

java卡虚拟机指令集

 

A Java Card virtual machine instruction consists of an opcode specifying the 

operation to be performed, followed by zero or more operands embodying values to 

be operated upon. This chapter gives details about the format of each Java Card 

virtual machine instruction and the operation it performs.

java卡虚拟机指令由一个指定了操作类型的操作码,跟着零个或者多个操作相关的操作数组成。

这张给出了java卡虚拟机的每个指令和它执行的操作。

 

7.1 Assumptions: The Meaning of “Must”

7.1 假定:“Must”的意义

 

The description of each instruction is always given in the context of Java Card 

virtual machine code that satisfies the static and structural constraints of Chapter 6, 

“The CAP File Format”.

每个指令的描述总是满足第六章的“CAP文件格式”的静态和结构化约束。

 

In the description of individual Java Card virtual machine instructions, we 

frequently state that some situation “must” or “must not” be the case: “The value2 

must be of type int.” The constraints of Chapter 6 “The CAP File Format” guarantee 

that all such expectations will in fact be met. If some constraint (a “must” or “must 

not”) in an instruction description is not satisfied at run time, the behavior of the 

Java Card virtual machine is undefined.

在不同的Java卡虚拟机指令的描述中,我们经常声明一些情况“必须”或者“必须不”如下:“value2必须是int类型”

第六章的CAP文件结构的约束保证了这种异常事实中不会遇到。如果一些指令中的限制在运行态不被满足,java卡虚拟机的行为是未定义的。

 

7.2 Reserved Opcodes

7.2 保留的操作码

 

In addition to the opcodes of the instructions specified later this chapter, which are 

used in Java Card CAP files (see Chapter 6, “The CAP File Format”), two opcodes 

are reserved for internal use by a Java Card virtual machine implementation. If Sun 

Microsystems, Inc. extends the instruction set of the Java Card virtual machine in the 

future, these reserved opcodes are guaranteed not to be used.

除了这章后面提到的用到java卡CAP文件中的操作码指令,有两个指令保留作为java卡虚拟机实现的内部指令。

未来,如果Sun公司扩展了java卡虚拟机的指令集,这两个保留指令被担保不会使用。

 

The two reserved opcodes, numbers 254 (0xfe) and 255 (0xff), have the mnemonics 

impdep1 and impdep2, respectively. These instructions are intended to provide 

“back doors” or traps to implementation-specific functionality implemented in 

software and hardware, respectively.

Although these opcodes have been reserved, they may only be used inside a Java 

Card virtual machine implementation. They cannot appear in valid CAP files.

两个保留操作码:0xFE和0xFF,有着助记符impdep1和impdep2。这些指令是用来提供后门或者实现规范的软件和硬件功能性需求。

这些操作码被保留,他们只能用在Java卡虚拟机的实现中,不能出现在有效的CAP文件中。

 

7.3 Virtual Machine Errors

7.3 虚拟机错误

 

A Java Card virtual machine may encounter internal errors or resource limitations 

that prevent it from executing correctly written Java programs. While The Java 

Virtual Machine Specification allows reporting and handling of virtual machine 

errors, it also states that they cannot ordinarily be handled by application code. This 

Virtual Machine Specification for the Java Card Platform, v2.2.2 is more restrictive in 

that it does not allow for any reporting or handling of unrecoverable virtual machine 

errors at the application code level. A virtual machine error is considered 

unrecoverable if further execution could compromise the security or correct 

operation of the virtual machine or underlying system software. When an 

unrecoverable error occurs, the virtual machine will halt bytecode execution. 

Responses beyond halting the virtual machine are implementation-specific policies 

and are not mandated in this specification.

一个java卡虚拟机可能遇到内部错误或者资源限制它执行正确的java程序。然而java虚拟机规范允许虚拟机

报告和解决错误,它也标识了它们不能被代码普通解决。这个java卡平台v2.2.2版本则更有局限性。不允许

在应用程序层面报告和处理任何不可修复性的虚拟机错误。虚拟机错误被认为是不可修复的,当一个不可修复

的异常发生,虚拟机将会停止字节码的执行。虚拟机停止的报告是实现规范的方案,不在本规范范围内。

 

In the case where the virtual machine encounters a recoverable error, such as 

insufficient memory to allocate a new object, it will throw a SystemException with 

an error code describing the error condition. The Virtual Machine Specification for 

the Java Card Platform, v2.2.2 cannot predict where resource limitations or internal 

errors may be encountered and does not mandate precisely when they can be 

reported. Thus, a SystemException may be thrown at any time during the operation 

of the Java Card virtual machine.

在虚拟机遭遇到一个可修复的错误,比如没有足够的内存来申请一个新的对象,它将会抛出一个系统异常,

附带一个错误吗来描述错误情况。java卡虚拟机规范2.2.2不能预知资源的限制或者可能遭遇到的内部错误

不能掌握它们抛出的时机。因此,系统异常有可能在java虚拟机运行的任何时候抛出来。

 

7.4 Security Exceptions

7.4 安全异常

 

Instructions of the Java Card virtual machine throw an instance of the class 

SecurityException when a security violation has been detected. The Java Card virtual 

machine does not mandate the complete set of security violations that can or will 

result in an exception being thrown. However, there is a minimum set that must be 

supported.

Java卡虚拟机的指令在安全违例的时候抛出SecurityException的实例。Java卡虚拟机不能维护所有

可能在运行时抛出的安全违例。然而,有一个必须支持的最小集。

 

In the general case, any instruction that de-references an object reference must throw 

a SecurityException if the context (Section 3.4, “Contexts” on page 3-2) in which the 

instruction is executing is different than the owning context (Section 3.4, “Contexts” 

on page 3-2) of the referenced object. The list of instructions includes the instance 

field get and put instructions, the array load and store instructions, as well as the 

arraylength, invokeinterface, invokespecial, invokevirtual, checkcast, instanceof and 

athrow instructions.

在一般情况下,任何依赖对象引用的命令,在命令引用的对象执行在非所属上下文的时候应该抛出安全异常。

这种类型的指令包含:实例属性的put和get指令,数组的load和store指令,还有arraylength,invokeinterface,

invokespecial,invokevirtual,checkcast,instanceof和athrow指令。

 

There are several exceptions to this general rule that allow cross-context use of 

objects or arrays. These exceptions are detailed in Chapter 6 of the Runtime 

Environment Specification for the Java Card Platform, Version 2.2.2. An important detail 

to note is that any cross-context method  invocation will result in a context switch 

(Section 3.4, “Contexts” on page 3-2).

对这个一般逻辑有几个例外,允许跨上下文使用对象和数组。这些例外的细节在JCRE第六章有描述。

一个描述这种跨上下文访问的重要细节是方法调用将导致上下文切换。

 

The Java Card virtual machine may also throw a SecurityException if an instruction 

violates any of the static constraints of Chapter 6, “The CAP File Format”. The 

Virtual Machine Specification for the Java Card Platform, Version 2.2.2 does not mandate 

which instructions must implement these additional security checks, or to what 

level. Therefore, a SecurityException may be thrown at any time during the 

operation of the Java Card virtual machine.

如果违反了第六章“CAP文件结构”的静态约束,java卡虚拟机也会抛出一个安全异常。

虚拟机不要求指令必须实现这些额外的安全检查。然而,在java卡虚拟机的运行过程中,任何时候都有可能抛出一个安全异常。

 

7.5 The Java Card Virtual Machine 

Instruction Set

7.5 java卡虚拟机指令集

 

Java virtual machine instructions are represented in this chapter by entries of the 

form shown in TABLE 7-1, an example instruction page, in alphabetical order.

这章提供的Java虚拟机指令集见表7-1提供的入口,采用字母顺序。

 

mnemonic

Short description of the instruction.

助记符

对指令的短描述

 

Format

mnemonic

operand1

operand2

...

格式

助记符

操作数1

操作数2

...

 

Forms

mnemonic = opcode

Stack

..., value1, value2 ->

.../ value3

结构

助记符 = 操作码

操作数栈

..., value1, value2 ->

.../ value3

 

Description

A longer description detailing constraints on operand stack contents or constant pool 

entries, the operation performed, the type of the results, and so on.

描述

一个长点的细节描述,对操作栈的约束,对常量池入口的约束,对操作执行,对结果的返回值描述等等。

 

Runtime Exception

If any runtime exceptions can be thrown by the execution of an instruction, that 

instruction must not throw any runtime exceptions except for instances of System 

Exception.

运行态异常

如果在执行指令时,有任何异常可能被抛出,指令除了系统异常之外不能抛出任何运行态异常。

 

Notes 

Commands not strictly part of the specification of an instruction are set aside as notes at 

the end of the description.

注释

非直接规范和指令规定的命令,作为注释提供在描述的最后。

 

Each cell in the instruction format diagram represents a single 8-bit byte. The 

instruction’s mnemonic is its name. Its opcode is its numeric representation and is 

given in both decimal and hexadecimal forms. Only the numeric representation is 

actually present in the Java Card virtual machine code in a CAP file.

在指令格式表中提供的每个单元都是一个8-bit字节。指令的助记符是它的名字。它的操作码是它的数字表述,

分别以10进制和16进制两种形式给出。只有数字形式才是在java卡虚拟机CAP文件中真正的存在。

 

Keep in mind that there are “operands” generated at compile time and embedded 

within Java Card virtual machine instructions, as well as “operands” calculated at 

run time and supplied on the operand stack. Although they are supplied from 

several different areas, all these operands represent the same thing: values to be 

operated upon by the Java Card virtual machine instruction being executed. By 

implicitly taking many of its operands from its operand stack, rather than 

representing them explicitly in its compiled code as additional operand bytes, 

register numbers, etc., the Java Card virtual machine’s code stays compact.

Some instructions are presented as members of a family of related instructions 

sharing a single description, format, and operand stack diagram. As such, a family 

of instructions includes several opcodes and opcode mnemonics; only the family 

mnemonic appears in the instruction format diagram, and a separate forms line lists 

请谨记,操作数是在编译阶段生成的并嵌入java卡虚拟机的指令中,操作栈也一样。尽管他们从不同的区域提供,

所有的这些操作数提供了相同的东西:依赖于java卡虚拟机指令执行的待操作的数据。

通过隐含的操作栈提供的操作数,或者显式的在命令中增加操作数。

一些指令是作为一系列相关指令提供的,共享一个描述,格式和操作栈图标。与此同时,一系列的

命令包含不同的操作数和操作数的助记符。

 

all member mnemonics and opcodes. For example, the forms line for the sconst_<s> 

family of instructions, giving mnemonic and opcode information for the two 

instructions in that family (sconst_0 and sconst_1), is

Forms sconst_0 = 3 (0x3), 

sconst_1 = 4 (0x4)

所有的成员助记符和操作数。比如sconst_<s>指令集,给出了那个指令集的两个助记符和操作数,

sconst_0 = 3

sconst_1 = 4

 

In the description of the Java Card virtual machine instructions, the effect of an 

instruction’s execution on the operand stack (Section 3.5, “Frames” on page 3-3) of 

the current frame (Section 3.5, “Frames” on page 3-3) is represented textually, with 

the stack growing from left to right and each word represented separately. Thus,

Stack…, value1, value2 ->

…, result

shows an operation that begins by having a one-word value2 on top of the operand 

stack with a one-word value1 just beneath it. As a result of the execution of the 

instruction, value1 and value2 are popped from the operand stack and replaced by a 

one-word result, which has been calculated by the instruction. The remainder of the 

operand stack, represented by an ellipsis (…), is unaffected by the instruction’s 

execution.

在java卡虚拟机指令的描述中,一个指令在当前frame操作栈上操作的影响用文本表示,栈从左到右增长,

每个字用逗号分隔。比如:

Stack…, value1, value2 ->

…, result

表明了一个操作,开始的时候在栈顶有一个字:value2,另外一个字value1紧随它。作为指令操作的结果,

value1和value2被从操作栈弹出来,并被一个字的指令计算的返回结果所替代。被省略号描述剩余操作栈,

对指令的操作没有影响。

 

The type int takes two words on the operand stack. In the operand stack 

representation, each word is represented separately using a dot notation:

Stack…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

The Virtual Machine Specification for the Java Card Platform, v2.2.2 does not 

mandate how the two words are used to represent the 32-bit int value; it only 

requires that a particular implementation be internally consistent.

int类型在操作栈上使用两个字。在操作栈表述上,每个字用一个点标识符来区分。

Stack…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

java卡虚拟机规范不规定两个字怎么来表述一个32-bit的int值;它仅仅要求实现的内部一致性。

 

7.5.1 aaload

Load reference from array

从引用数组中读取引用

 

Format

aaload

 

Forms

aaload = 36 (0x24)

 

Stack

…, arrayref, index ->

…, value

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type reference. The index must be of type short. Both arrayref and index are 

popped from the operand stack. The reference value in the component of the array 

at index is retrieved and pushed onto the top of the operand stack.

描述

arrayref必须是reference类型,而且必须指向一个引用数组。index必须是一个short类型。

arrayref和index都是从操作栈弹出,对应引用数组下标位置的数据被查找到,并被压入操作数栈。

 

Runtime Exceptions

If arrayref is null, aaload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

aaload instruction throws an ArrayIndexOutOfBoundsException.

运行态异常

如果arrayref是null,aaload抛出一个空指针异常。

否则,如果下标不再数组范围内,aaload指令抛出一个ArrayIndexOutOfBoundsException.

 

Notes

In some circumstances, the aaload instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

注释

在一些环境下,如果当前上下文和arrayref对象所属的上下文不同,aaload指令可能抛出安全异常。

具体的情况参见JCRE规范,第六章。

 

7.5.2 aastore

Store into reference array

存储数据(引用)到引用数组

 

Format 

aastore

 

Forms

aastore = 55 (0x37)

Stack

…, arrayref, index, value ->

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type reference. The index must be of type short and the value must be of type 

reference. The arrayref, index and value are popped from the operand stack. The 

reference value is stored as the component of the array at index.

At runtime the type of value must be confirmed to be assignment compatible with 

the type of the components of the array referenced by arrayref. Assignment of a 

value of reference type S (source) to a variable of reference type T (target) is allowed 

only when the type S supports all of the operations defined on type T. The detailed 

rules follow:

■ If S is a class type, then:

■ If T is a class type, then S must be the same class as T, or S must be a subclass 

of T;

■ If T is an interface type, then S must implement interface T.

 

■ If S is an interface type, then:

■ If T is a class type, then T must be Object (Section 2.2.2.4, “Classes” on 

page 2-7);

■ If T is an interface type, T must be the same interface as S or a superinterface of 

S.

■ If S is an array type, namely the type SC[], that is, an array of components of type 

SC, then:

■ If T is a class type, then T must be Object.

■ If T is an array type, namely the type TC[], an array of components of type TC, 

then one of the following must be true:

TC and SC are the same primitive type (Section 3.1, “Data Types and Values” 

on page 3-1”).

TC and SC are reference types (Section 3.1, “Data Types and Values” on 

page 3-1) with type SC assignable to TC, by these rules.

■ If T is an interface type, T must be one of the interfaces implemented by arrays.

描述

arrayref必须是一个引用类型,指向引用数组。index必须是一个short类型的值,value必须是一个type类型的引用。

arrayref,index和value是从操作栈弹出。value的值被存在数组下标对应的位置。

在运行态,value的类型必须被确认和arrayref所指向的数组类型一致。把一个引用类型S分配给一个类型T只有类型S

支持所有定义在T中的操作。细节如下:

■ 如果S是一个类:

■ 如果T是一个类,T必须是S相同的类型,或者是S的父类

■ 如果T是一个接口,S必须实现了接口T

■ 如果S是一个接口:

■ 如果T是一个类,那么T必须是Object。

■ 如果T是一个接口,那么T必须是和S一样的接口,或者是S的父接口。

■ 如果S是一个数组类型,类型名为SC[],也就是说一个存储类型为SC的数组:

■ 如果T是一个类,那么T必须是Object

■ 如果T是一个数组类型,名为TC[],一个存储类型为TC的数组,那么如下的一条必须满足:

TC和SC是相同的基本类型。

TC和SC是引用类型,并且SC可分配给TC。

■如果T是一个接口类型,T必须是数组实现的接口之一。 

Runtime Exceptions

If arrayref is null, aastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

aastore instruction throws an ArrayIndexOutOfBoundsException.

Otherwise, if arrayref is not null and the actual type of value is not assignment 

compatible with the actual type of the component of the array, aastore throws an 

ArrayStoreException.

运行态异常

如果arrayref是null,aaload抛出一个空指针异常。

否则,如果下标不再数组范围内,aaload指令抛出一个ArrayIndexOutOfBoundsException.

另外,如果arrayref不是null,并且value的类型和数组元素的类型不匹配,抛出ArrayStoreException异常。

 

Notes

In some circumstances, the aastore instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

注释:

同上

 

7.5.3 aconst_null

Push null

压空对象

 

Format

aconst_null

Forms

aconst_null = 1 (0x1)

 

Stack

… -> 

…, null

 

Description

Push the null object reference onto the operand stack.

描述

压一个null对象引用到操作数栈上。

 

7.5.4 aload

Load reference from local variable

从本地变量中加载引用。

 

Format

aload

index

Forms

aload = 21 (0x15)

 

Stack

… ->

…, objectref

 

Description

The index is an unsigned byte that must be a valid index into the local variables of 

the current frame (Section 3.5, “Frames” on page 3-3). The local variable at index 

must contain a reference. The objectref in the local variable at index is pushed onto 

the operand stack.

描述

index是一个无符号的字节,必须是一个指向当前frame本地变量的下标。在对应下标位置的本地变量

必须是一个引用。对应位置的引用objectref被压倒操作栈上。

 

Notes

The aload instruction cannot be used to load a value of type returnAddress from a 

local variable onto the operand stack. This asymmetry with the astore instruction 

is intentional.

Each of the aload_<n> instructions is the same as aload with an index of <n>, except 

that the operand <n> is implicit.

注释

aload指令不能用来在本地变量中导入一个返回地址类型的值。这个和astore指令的不对称是故意的。

每个aload_<n>指令和aload使用<n>作为下标一样,操作数n是隐含的。

 

7.5.6 anewarray

Create new array of reference

创建一个指向引用的数组

 

Format

anewarray

indexbyte1

indexbyte2

Forms

anewarray = 145 (0x91)

Stack

…, count ->

…, arrayref

 

Description

The count must be of type short. It is popped off the operand stack. The count 

represents the number of components of the array to be created. The unsigned 

indexbyte1 and indexbyte2 are used to construct an index into the constant pool of 

the current package (Section 3.5, “Frames” on page 3-3), where the value of the index 

is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must 

be of type CONSTANT_Classref (Section 6.7.1, “CONSTANT_Classref” on 

page 6-16), a reference to a class or interface type. The reference is resolved. A new 

array with components of that type, of length count, is allocated from the heap, and 

a reference arrayref to this new array object is pushed onto the operand stack. All 

components of the new array are initialized to null, the default value for reference 

types.

描述

count必须是一个short类型,它从操作栈中弹出。count表明要创建的数组的元素个数。无符号indexbyte1和indexbyte2用来

创建一个指向当前包的constant pool的下标,对应下标的值是(indexbyte1<<8 | indexbyte2)。对应常量池的位置的对象必须

是CONSTANT_Classref类型,指向一个类或者接口类型。一个相应对象类型,长度的数组将会创建在堆中,并且指向这个新数组

对象的arrayref将会被压入操作栈。新数组的所有单元都被初始化为null,引用的默认类型。

 

Runtime Exception

If count is less than zero, the anewarray instruction throws a NegativeArraySizeException.

运行态异常

如果count小于0,anewarray命令抛出NegativeArraySizeException(负数组大小异常)。

 

7.5.7 areturn

Return reference from method

从方法返回引用

 

Format

areturn

Forms

areturn = 119 (0x77)

Stack

…, objectref ->

[empty]

 

Description

The objectref must be of type reference. The objectref is popped from the operand 

stack of the current frame (Section 3.5, “Frames” on page 3-3) and pushed onto the 

operand stack of the frame of the invoker. Any other values on the operand stack of 

the current method are discarded.

The virtual machine then reinstates the frame of the invoker and returns control to 

the invoker.

描述

objectref必须是一个引用类型,objectref从当前frame的操作栈弹出,并且push到调用者的操作栈。

当前操作栈的所有其它值都丢弃。

虚拟机然后恢复调用者的frame,并且返回调用者的控制。

 

7.5.8 arraylength

Get length of array

获得数组长度

 

Format

arraylength

Forms

arraylength = 146 (0x92)

stack

…, arrayref ->

…, length

 

Description

The arrayref must be of type reference and must refer to an array. It is popped from 

the operand stack. The length of the array it references is determined. That length is 

pushed onto the top of the operand stack as a short.

描述arrayref必须是一个引用类型,并且必须指向一个数组。它从操作栈弹出。数组的长度由它的引用就能确定了。

这个长度作为short压入操作栈。

 

Runtime Exception

If arrayref is null, the arraylength instruction throws a NullPointerException.

运行态异常

如果arrayref是空,arraylength指令抛出一个空指针异常。

 

Notes

In some circumstances, the arraylength instruction may throw a SecurityException if 

the current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2..

描述

在当前上下文和对象的上下文不同的时候,这个命令可能抛出一个SecurityException.

请参见JCRE规范第六章。

 

7.5.9 astore

Store reference into local variable

将引用存储本地变量

 

Format

astore

index

Forms

astore = 40 (0x28)

Stack

…, objectref ->

 

Description

The index is an unsigned byte that must be a valid index into the local variables of 

the current frame (Section 3.5, “Frames” on page 3-3). The objectref on the top of the 

operand stack must be of type returnAddress or of type reference. The objectref is 

popped from the operand stack, and the value of the local variable at index is set to 

objectref.

描述

index是一个无符号的字节,必须是一个指向当前frame的本地变量。操作栈顶的objectref必须是一个

返回地址型的类型或者引用类型。objectref从操作栈弹出,本地变量对应的下标将被设置为objectref

 

Notes

The astore instruction is used with an objectref of type returnAddress when 

implementing Java’s finally keyword. The aload instruction cannot be used to load a 

value of type returnAddress from a local variable onto the operand stack. This 

asymmetry with the astore instruction is intentional.

描述

astore命令在实现java的finally关键字的时候使用了返回地址类型的astore指令。aload命令不能

用来在本地变量中加载一个返回地址,这个不对称是故意的。

(astore和jsr,ret配合以实现frame内部意义的子模块概念,比如finally模块在每个try,catch的模块后都要执行。

但是考虑到运行环境的复杂性,子模块的调用的流程比预想的复杂很多。所以现在一般编译器的实现都是使用复制

子模块字节码的方式,而很少使用子模块的调用)

 

7.5.10 astore_<n>

Store reference into local variable

存储引用到本地变量(快速指令)

 

Format

astore_<n>

Forms

astore_0 = 43 (0x2b)

astore_1 = 44 (0x2c)

astore_2 = 45 (0x2d)

astore_3 = 46 (0x2e)

 

Stack

…, objectref ->

 

Description

The <n> must be a valid index into the local variables of the current frame 

(Section 3.5, “Frames” on page 3-3). The objectref on the top of the operand stack 

must be of type returnAddress or of type reference. It is popped from the operand 

stack, and the value of the local variable at <n> is set to objectref.

描述<n>必须是当前frame本地变量的有效索引。objectref在栈顶,有可能是返回地址和引用。

它从操作栈pop出来,并且存入<n>对应的本地变量中。

 

Notes

An astore_<n> instruction is used with an objectref of type returnAddress when 

implementing Java’s finally keyword. An aload_<n> instruction cannot be used to 

load a value of type returnAddress from a local variable onto the operand stack. 

This asymmetry with the corresponding astore_<n> instruction is intentional.

Each of the astore_<n> instructions is the same as astore with an index of <n>, 

except that the operand <n> is implicit.

注释

同上

 

 

7.5.11 athrow

Throw exception or error

抛出异常或者错误

 

Format

athrow

Forms

athrow = 147 (0x93)

Stack

…, objectref ->

objectref

 

Description

The objectref must be of type reference and must refer to an object that is an instance 

of class Throwable or of a subclass of Throwable. It is popped from the operand 

stack. The objectref is then thrown by searching the current frame (Section 3.5, 

“Frames” on page 3-3) for the most recent catch clause that catches the class of 

objectref or one of its superclasses.

If a catch clause is found, it contains the location of the code intended to handle this 

exception. The pc register is reset to that location, the operand stack of the current 

frame is cleared, objectref is pushed back onto the operand stack, and execution 

continues. If no appropriate clause is found in the current frame, that frame is 

popped, the frame of its invoker is reinstated, and the objectref is rethrown.

If no catch clause is found that handles this exception, the virtual machine exits.

objectref必须是一个引用类型,并且必须指向一个Trhowable类或者其子类。它从操作栈pop出来。

objectref通过搜寻当前frame适合的匹配。

如果找到一个catch条款,它指出了处理这个异常的代码位置。pc寄存器被重置到那个位置,当前frame的

操作栈清了,objectref押回操作栈。并且继续执行。如果当前frame没有找到匹配的catch条款,当前的frame

弹出,调用者的frame恢复,并且objectref重新抛出。如果没有catch来处理这个异常,虚拟机中止。

 

Runtime Exception

If objectref is null, athrow throws a NullPointerException instead of objectref.

运行态异常

如果objectref是空,athrow抛出一个空指针异常。来替换objectref。

 

Notes

In some circumstances, the athrow instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

注释

在抛出对象的上下文和当前对象的上下文不同的时候,athrow有可能抛出一个SecurityException。

参见JCRE规范第六章。

 

 

7.5.12 baload

Load byte or boolean from array

从数组中加载byte和boolean数据

 

Format

baload

Forms

baload = 37 (0x25)

Stack

…, arrayref, index ->

…, value

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type byte or of type boolean. The index must be of type short. Both arrayref 

and index are popped from the operand stack. The byte value in the component of 

the array at index is retrieved, sign-extended to a short value, and pushed onto the 

top of the operand stack.

描述

arrayref必须是一个引用类型,并且必须指向一个指向byte和boolean类型的数组。index必须是short类型。

arrayref和index都是从操作数栈上弹出。对应数组下标位置的数据得到,有负号扩展为short的值,并且压栈。

 

Runtime Exceptions

If arrayref is null, baload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

baload instruction throws an ArrayIndexOutOfBoundsException.

运行态异常

如果arrayref是null,baload抛出了一个空指针异常。

否则,如果index不再arrayref指向的数组下标范围内,baload指令抛出ArrayIndexOutOfBoundsException

 

Notes

In some circumstances, the baload instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

注释

在arrayref的上下文和当前的上下文不同的时候,athrow有可能抛出一个SecurityException。

参见JCRE规范第六章。

 

 

7.5.13 bastore

Store into byte or boolean array

存储byte或boolean数据到数组

 

Format

bastore

Forms

bastore = 56 (0x38)

Stack

…, arrayref, index, value ->

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type byte or of type boolean. The index and value must both be of type short. 

The arrayref, index and value are popped from the operand stack. The short value is 

truncated to a byte and stored as the component of the array indexed by index.

描述

arrayref必须是引用类型,并且必须指向一个byte或者boolean数组。index和value必须都是short类型。

arrayref,index和value都是从操作栈弹出。short的值将被截为一个byte,并存储到对应的下标位置。

 

Runtime Exceptions

If arrayref is null, bastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

bastore instruction throws an ArrayIndexOutOfBoundsException.

运行态异常

如果arrayref是空的,bastore抛出一个空指针异常。

否则,如果index不再arrayref所指的数组范围内,bastore指令抛出ArrayIndexOutOfBoundsException异常。

 

Notes

In some circumstances, the bastore instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

注释

在arrayref的上下文和当前的上下文不同的时候,athrow有可能抛出一个SecurityException。

参见JCRE规范第六章。

 

7.5.14 bipush

Push byte

压入byte数据为int类型

 

Format

bipush

byte

Forms

bipush = 18 (0x12)

Stack

…->

…, value.word1, value.word2

 

Description

The immediate byte is sign-extended to an int, and the resulting value is pushed 

onto the operand stack.

描述立即数由byte带符号扩展为int,并且转化的结果压入操作栈。

 

Note – If a virtual machine does not support the int data type, the bipush 

instruction will not be available.

注释

如果虚拟机不支持int数据类型,bipush指令无效。

 

7.5.15 bspush

Push byte

 

Format

bspush

byte

Forms

bspush = 16 (0x10)

Stack

…->

…, value

 

Description

The immediate byte is sign-extended to a short, and the resulting value is pushed 

onto the operand stack.

描述

立即数又byte带符号扩展为short,并且把转化的结果压入操作栈。

 

7.5.16 checkcast

Check whether object is of given type

检查是否对象是一个给定的类型

 

Format

checkcast

atype

indexbyte1

indexbyte2

Forms

checkcast = 148 (0x94)

 

Stack

…, objectref ->

…, objectref

 

Description

The unsigned byte atype is a code that indicates if the type against which the object 

is being checked is an array type or a class type. It must take one of the following 

values or zero:

TABLE 7-2  Array Values

Array Type atype

T_BOOLEAN 10

T_BYTE 11

T_SHORT 12

T_INT 13

T_REFERENCE 14

If the value of atype is 10, 11, 12, or 13, the values of the indexbyte1 and indexbyte2 

must be zero, and the value of atype indicates the array type against which to check 

the object. Otherwise the unsigned indexbyte1 and indexbyte2 are used to construct 

an index into the constant pool of the current package (Section 3.5, “Frames” on 

page 3-3), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item 

at that index in the constant pool must be of type CONSTANT_Classref 

(Section 6.7.1, “CONSTANT_Classref” on page 6-16), a reference to a class or 

interface type. The reference is resolved. If the value of atype is 14, the object is 

checked against an array type that is an array of object references of the type of the 

resolved class. If the value of atype is zero, the object is checked against a class or 

interface type that is the resolved class.

The objectref must be of type reference. If objectref is null or can be cast to the 

specified array type or the resolved class or interface type, the operand stack is 

unchanged; otherwise the checkcast instruction throws a ClassCastException.

The following rules are used to determine whether an objectref that is not null can 

be cast to the resolved type: if S is the class of the object referred to by objectref and 

T is the resolved class, array or interface type, checkcast determines whether 

objectref can be cast to type T as follows:

 

■ If S is a class type, then:

■ If T is a class type, then S must be the same class as T, or S must be a subclass 

of T;

■ If T is an interface type, then S must implement interface T.

■ If S is an interface type1, then:

■ If T is a class type, then T must be Object (Section 2.2.2.4, “Classes” on 

page 2-7);

■ If T is an interface type, T must be the same interface as S or a superinterface of 

S.

■ If S is an array type, namely the type SC[], that is, an array of components of type 

SC, then:

■ If T is a class type, then T must be Object.

■ If T is an array type, namely the type TC[], an array of components of type TC, 

then one of the following must be true:

TC and SC are the same primitive type (Section 3.1, “Data Types and Values” 

on page 3-1).

TC and SC are reference types1 (Section 3.1, “Data Types and Values” on 

page 3-1) with type SC assignable to TC, by these rules.

■ If T is an interface type, T must be one of the interfaces implemented by arrays.

描述

无符号字节atype是一个用来标识与被检查的对象相对的类型是否是数组类型或者类类型。它必须是如下的值或者0.

表 7-2  数组类型

Array Type atype

T_BOOLEAN 10

T_BYTE 11

T_SHORT 12

T_INT 13

T_REFERENCE 14

如果atype的值是10,11,12或者13,indexbyte1和indexbyte2的值必须是0,atype的值表明了和检查的object相对的数组类型。

否则,无符号的indexbyte1和indexbyte3组成了一个指向常量池的下标(indexbyte1<<8 | indexbyte2)。对应下标的常量池必须

是一个CONSTANT_Classref类型,指向一个类或接口类型。当类确定下来后,如果atype的类型是14,和object对应的类型是一个

数组类型,数组的内容是这个类。如果atype的值是0,和检查的object对应的类型就是这个类或者类实现的接口。

objectref必须是引用类型,如果objectref是null或者可以被转化为相应的类型,操作栈不变,否则checkcast将会抛出一个ClassCastException。

以下的规则用来决定一个非null的objectref是否可以被抓话为对应的类型。如下:

■ 如果S是一个类:

■ 如果T是一个类,T必须是S相同的类型,或者是S的父类

■ 如果T是一个接口,S必须实现了接口T

■ 如果S是一个接口:

■ 如果T是一个类,那么T必须是Object。

■ 如果T是一个接口,那么T必须是和S一样的接口,或者是S的父接口。

■ 如果S是一个数组类型,类型名为SC[],也就是说一个存储类型为SC的数组:

■ 如果T是一个类,那么T必须是Object

■ 如果T是一个数组类型,名为TC[],一个存储类型为TC的数组,那么如下的一条必须满足:

TC和SC是相同的基本类型。

TC和SC是引用类型,并且SC可分配给TC。

■如果T是一个接口类型,T必须是数组实现的接口之一。 

(等同于aastore的判断)

 

Runtime Exception

If objectref cannot be cast to the resolved class, array, or interface type, the checkcast 

instruction throws a ClassCastException.

运行态异常

如果objectref不能转化为给定的类,数组或者接口类型,checkcast指令抛出ClassCastException异常。

 

Notes

The checkcast instruction is fundamentally very similar to the instanceof instruction. 

It differs in its treatment of null, its behavior when its test fails (checkcast throws an 

exception, instanceof pushes a result code), and its effect on the operand stack.

In some circumstances, the checkcast instruction may throw a SecurityException if 

the current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the value of atype may not 

be 13 (array type = T_INT).

注释

checkcast指令根本上和instanceof命令非常相近。它们不同于对null的处理,它们对转化失败的处理(checkcast

抛出异常,instanceof压入结果值),和它们对操作栈的影响。

当objectref的上下文和当前上下文不同的时候,checkcast指令可能抛出安全异常。

如果虚拟机不支持int数据类型,atype的值不能是13(array type = T_INT)

 

7.5.17 dup

Duplicate top operand stack word

复制操作栈顶字

 

Format

dup

Forms

dup = 61 (0x3d)

 

Stack

…, word ->

…, word, word

 

Description

The top word on the operand stack is duplicated and pushed onto the operand 

stack.

The dup instruction must not be used unless word contains a 16-bit data type.

描述

操作栈顶的字复制并且被压入操作栈。

dup指令只有在字包含了16-bit数据类型的时候才能使用。

 

Notes

Except for restrictions preserving the integrity of 32-bit data types, the dup 

instruction operates on an untyped word, ignoring the type of data it contains.

注释

除了32-bit的数据类型限制,dup指令操作一个无类型的字,忽略包含的数据类型。

 

7.5.18 dup_x

Duplicate top operand stack words and insert below

复制栈顶数据插入下边

 

Format

dup_x

mn

Forms

dup_x = 63 (0x3f)

Stack

…, wordN, …, wordM, …, word1 ->

…, wordM, …, word1, wordN, …, wordM, …, word1

 

Description

The unsigned byte mn is used to construct two parameter values. The high nibble, 

(mn & 0xf0) >> 4, is used as the value m. The low nibble, (mn & 0xf), is used as the 

value n. Permissible values for m are 1 through 4. Permissible values for n are 0 and 

m through m+4.

For positive values of n, the top m words on the operand stack are duplicated and 

the copied words are inserted n words down in the operand stack. When n equals 0, 

the top m words are copied and placed on top of the stack.

The dup_x instruction must not be used unless the ranges of words 1 through m and 

words m+1 through n each contain either a 16-bit data type, two 16-bit data types, a 

32-bit data type, a 16-bit data type and a 32-bit data type (in either order), or two 32-

bit data types.

描述

无符号数msn用来构造两个参数值,高半个字节(mn & 0xf0) >> 4,作为数值m。低半个字节(mn & 0xf)

作为数值n。m允许的值为1到4,n允许的值为0和m到m+4之间。

对于确定的n,栈顶的m个字被复制到操作栈下面的n个字。当n等于0,m个字被复制并放置于栈顶。

dup_x指令只有在字的范围从1到m和字m+1到n每个都包含或者一个16-bit数据类型,两个16-bit数据类型,一个32-bit数据类型,

一个16-bit数据类型和一个32-bit数据类型,或者两个32-bit数据类型。

 

Notes

Except for restrictions preserving the integrity of 32-bit data types, the dup_x 

instruction operates on untyped words, ignoring the types of data they contain.

If a virtual machine does not support the int data type, the permissible values for m 

are 1 or 2, and permissible values for n are 0 and m through m+2.

注释

除了为32-bit数据类型的考虑,dup_x指令操作无类型数据,忽略它们存储的数据类型。如果虚拟机不支持int数据类型,

m的有效值只能是1或者2,n的有效值是0和m到m+2

 

 

7.5.19 dup2

Duplicate top two operand stack words

复制栈顶双字

 

Format

dup2

Forms

dup2 = 62 (0x3e)

Stack

…, word2, word1 ->

…, word2, word1, word2, word1

 

Description

The top two words on the operand stack are duplicated and pushed onto the 

operand stack, in the original order.

The dup2 instruction must not be used unless each of word1 and word2 is a word 

that contains a 16-bit data type or both together are the two words of a single 32-bit 

datum.

描述,操作栈顶的的两个字被复制并且按原来的顺序压入操作栈。

dup2命令只有在word1和word2都是一个16-bit数据类型或合为一个32-bit数据的时候才能使用。

 

Notes

Except for restrictions preserving the integrity of 32-bit data types, the dup2 

instruction operates on untyped words, ignoring the types of data they contain.

注释

除了为32-bit数据类型考虑,dup2也操作无类型数,忽略它们包含的数据类型。

 

7.5.20 getfield_<t>

Fetch field from object

获取对象的属性

 

Format

getfield_<t>

index

Forms

getfield_a = 131 (0x83)

getfield_b = 132 (0x84)

getfield_s = 133 (0x85)

getfield_i = 134 (0x86)

 

Stack

…, objectref ->

…, value

OR

…, objectref ->

…, value.word1, value.word2

 

Description

The objectref, which must be of type reference, is popped from the operand stack. 

The unsigned index is used as an index into the constant pool of the current package 

(Section 3.5, “Frames” on page 3-3). The constant pool item at the index must be of 

type CONSTANT_InstanceFieldref (Section 6.7.2, “CONSTANT_InstanceFieldref, 

CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref” on page 6-18), a 

reference to a class and a field token.

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The value at that 

offset into the class instance referenced by objectref is fetched. If the value is of type 

byte or type boolean, it is sign-extended to a short. The value is pushed onto the 

operand stack.

描述

objectref必须是引用类型,从操作栈弹出,无符号的下标是指向当前包的常量池下标。常量池对应位置

必须是CONSTANT_InstanceFieldref,指向一个类的引用和属性令牌。

objectref必须不能是数组。如果属性是保护的,并且是当前类的父类的,并且属性没和和当前包处于同一个包,

那么object的类必须是当前类或者当前类的父类。

对象被认为是符合t的类型,如下:

■ a 属性必须是引用类型

■ b 属性必须是byte或者boolean类型

■ s 属性必须是short类型

■ i 属性必须是int类型

 

Runtime Exception

If objectref is null, the getfield_<t> instruction throws a NullPointerException.

运行态异常

如果objectref是空,那么getfield_<t>指令抛出一个空指针异常。

 

Notes

In some circumstances, the getfield_<t> instruction may throw a SecurityException 

if the current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the getfield_i instruction will 

not be available.

注释

在objectref的上下文和当前的上下文不同的时候,getfield_<t>有可能抛出一个SecurityException。

参见JCRE规范第六章。

 

 

 

7.5.21 getfield_<t>_this

Fetch field from current object

从当前对象获取属性

 

Format

getfield_<t>_this

index

 

Forms

getfield_a_this = 173 (0xad)

getfield_b_this = 174 (0xae)

getfield_s_this = 175 (0xaf)

getfield_i_this = 176 (0xb0)

 

Stack

… ->

…, value

OR

… ->

…, value.word1, value.word2

 

Description

The currently executing method must be an instance method. The local variable at 

index 0 must contain a reference objectref to the currently executing method’s this 

parameter. The unsigned index is used as an index into the constant pool of the 

current package (Section 3.5, “Frames” on page 3-3). The constant pool item at the 

index must be of type CONSTANT_InstanceFieldref (Section 6.7.2, 

“CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and 

CONSTANT_SuperMethodref” on page 6-18), a reference to a class and a field 

token.

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class.

描述

当前执行的方法必须是一个实例方法。下标为0的本地变量一定是一个对象引用指向方法的this参数。

无符号下标是指向当前frame常量池的下标。常量池对应的位置必须是一个CONSTANT_InstanceFieldref类型。指向一个类和属性令牌。

objectref的类不能是一个数组,如果属性是protected,并且是父类的成员,并且不再本包被声明。

object的类或者是本类或者是父类。

 

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

对象被认为是符合t的类型,如下:

■ a 属性必须是引用类型

■ b 属性必须是byte或者boolean类型

■ s 属性必须是short类型

■ i 属性必须是int类型

 

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The value at that 

offset into the class instance referenced by objectref is fetched. If the value is of type 

byte or type boolean, it is sign-extended to a short. The value is pushed onto the 

operand stack.

类实例中属性的宽度是指令中属性的类型决定的。当对象确定后,决定了属性的偏移。对应实例中偏移位置的数据取出。

如果类型是byte或者boolean,它有符号扩展为short,值压入操作栈

 

Runtime Exception

If objectref is null, the getfield_<t>_this instruction throws a NullPointerException.

运行态异常

如果objectref是空,getfield_<t>_this 命令抛出空指针异常。

 

Notes

In some circumstances, the getfield_<t>_this instruction may throw a 

SecurityException if the current context (Section 3.4, “Contexts” on page 3-2) is not 

the owning context (Section 3.4, “Contexts” on page 3-2) of the object referenced by 

objectref. The exact circumstances when the exception will be thrown are specified in 

Chapter 6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the getfield_i_this instruction 

will not be available.

注释

同上

 

7.5.22 getfield_<t>_w

Fetch field from object (wide index)

从对象中获取属性(宽下标)

 

Format

getfield_<t>_w

indexbyte1

indexbyte2

Forms

getfield_a_w = 169 (0xa9)

getfield_b_w = 170 (0xaa)

getfield_s_w = 171 (0xab)

getfield_i_w = 172 (0xac)

Stack

…, objectref ->

…, value

OR

…, objectref ->

…, value.word1, value.word2

 

Description

The objectref, which must be of type reference, is popped from the operand stack. 

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the 

index must be of type CONSTANT_InstanceFieldref (Section 6.7.2, 

“CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and 

CONSTANT_SuperMethodref” on page 6-18), a reference to a class and a field 

token. The item must resolve to a field of type reference.

 

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The value at that 

offset into the class instance referenced by objectref is fetched. If the value is of type 

byte or type boolean, it is sign-extended to a short. The value is pushed onto the 

operand stack.

描述

同上,不同的是index是16-bit。

 

Runtime Exception

If objectref is null, the getfield_<t>_w instruction throws a NullPointerException.

运行态异常

同上

 

Notes

In some circumstances, the getfield_<t>_w instruction may throw a 

SecurityException if the current context (Section 3.4, “Contexts” on page 3-2) is not 

the owning context Section 3.4, “Contexts” on page 3-2) of the object referenced by 

objectref. The exact circumstances when the exception will be thrown are specified in 

Chapter 6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the getfield_i_w instruction 

will not be available.

注释

同上

 

 

7.5.23 getstatic_<t>

Get static field from class

从类中获得静态属性

 

Format

getstatic_<t>

indexbyte1

indexbyte2

Forms

getstatic_a = 123 (0x7b)

getstatic_b = 124 (0x7c)

getstatic_s = 125 (0x7d)

getstatic_i = 126 (0x7e)

Stack

… ->

…, value

OR

… ->

…, value.word1, value.word2

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the 

index must be of type CONSTANT_StaticFieldref (Section 6.7.3, 

“CONSTANT_StaticFieldref and CONSTANT_StaticMethodref” on page 6-19), a 

reference to a static field.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

The width of a class field is determined by the field type specified in the instruction. 

The item is resolved, determining the field offset. The item is resolved, determining 

the class field. The value of the class field is fetched. If the value is of type byte or 

boolean, it is sign-extended to a short. The value is pushed onto the operand stack.

描述

无符号的indexbyte1和indexbyte2用来构造一个指向当前包常量池的下标,下标的值为(indexbyte1<<8 | indexbyte2)。

对应常量池的位置类型为CONSTANT_StaticFieldref,指向一个静态属性。

对象被认为是符合t的类型,如下:

■ a 属性必须是引用类型

■ b 属性必须是byte或者boolean类型

■ s 属性必须是short类型

■ i 属性必须是int类型

类属性的长度是由属性类型决定的。对象确定了属性的偏移。如果值的类型是byte或者boolean,带符号扩展为short,压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the getstatic_i instruction 

will not be available.

注释

如果虚拟机不支持int数据类型,getstatic_i 命令将无效。

 

 

 

7.5.24 goto

Branch always

跳转

 

Format

goto

branch

 

Forms

goto = 112 (0x70)

 

Stack

No change

 

Description

The value branch is used as a signed 8-bit offset. Execution proceeds at that offset 

from the address of the opcode of this goto instruction. The target address must be 

that of an opcode of an instruction within the method that contains this goto 

instruction.

描述

branch的值是作为一个有符号的8-bit偏移来使用。执行的偏移是这个goto指令的操作码的地址。目标地址必须是

包含这个goto指令的方法中的一个指令的操作码。

 

 

 

7.5.25 goto_w

Branch always (wide index)

跳转(宽下标)

 

Format

goto_w

branchbyte1

branchbyte2

Forms

goto_w = 168 (0xa8)

Stack

No change

 

Description

The unsigned bytes branchbyte1 and branchbyte2 are used to construct a signed 16-

bit branchoffset, where branchoffset is (branchbyte1 << 8) | branchbyte2. Execution 

proceeds at that offset from the address of the opcode of this goto instruction. The 

target address must be that of an opcode of an instruction within the method that 

contains this goto instruction.

描述

无符号的字节branchbyte1和branchbyte2用来组成一个有符号的16-bit跳转偏移branchoffset=(branchbyte1<<8 | branchbyte2)。

执行的偏移是goto指令的操作码的地址,目标地址必须是包含这个goto指令的方法中的一个指令的操作码。

 

 

7.5.26 i2b

Convert int to byte

转化int到byte

 

Format

i2b

Forms

i2b = 93 (0x5d)

 

Stack

…, value.word1, value.word2 ->

…, result

 

Description

The value on top of the operand stack must be of type int. It is popped from the 

operand stack and converted to a byte result by taking the low-order 16 bits of the 

int value, and discarding the high-order 16 bits. The low-order word is truncated to 

a byte, then sign-extended to a short result. The result is pushed onto the operand 

stack.

操作栈顶的值必须是int类型,它从操作栈弹出并且通过获得int值的低16-bit,丢弃高16-bit的方式转化为byte结果,

低字截取为一个byte,并且有负号扩展为一个short结果。结果压入操作栈。

 

Notes

The i2b instruction performs a narrowing primitive conversion. It may lose 

information about the overall magnitude of value. The result may also not have the 

same sign as value.

If a virtual machine does not support the int data type, the i2b instruction will not be 

available.

描述

i2b指令执行了一个窄型基本转化。有可能会失去数据中的重要信息。结果也可能和值的符号不同。

如果虚拟机不支持int数据类型,i2b指令将无效。

 

 

7.5.27 i2s

Convert int to short

转化int到short类型

 

Format

i2s

Forms

i2s = 94 (0x5e)

Stack

…, value.word1, value.word2 ->

…, result

 

Description

The value on top of the operand stack must be of type int. It is popped from the 

operand stack and converted to a short result by taking the low-order 16 bits of the 

int value and discarding the high-order 16 bits. The result is pushed onto the 

operand stack.

描述

操作栈顶的值必须是int类型,它从操作栈弹出并通过获得int值的低16-bit,丢弃高16-bit的方式转化为short结果。

结果压入操作栈。

 

Notes

The i2s instruction performs a narrowing primitive conversion. It may lose 

information about the overall magnitude of value. The result may also not have the 

same sign as value.

If a virtual machine does not support the int data type, the i2s instruction will not be 

available.

i2s指令执行了一个窄型基本转化。有可能会失去数据中的重要信息。结果也可能和值的符号不同。

如果虚拟机不支持int数据类型,i2s指令将无效。

 

7.5.28 iadd

Add int

int加法

 

Format

iadd

Forms

iadd = 66 (0x42)

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. The int result is value1 + value2. The result is pushed onto the 

operand stack.

If an iadd instruction overflows, then the result is the low-order bits of the true 

mathematical result in a sufficiently wide two’s-complement format. If overflow 

occurs, then the sign of the result may not be the same as the sign of the 

mathematical sum of the two values.

value1和value2必须都是int类型,数据从操作栈中弹出,结果是value1+value2的int值,结果压入操作栈。

如果一个iadd命令溢出,那么结果将是真正数学结果的有限宽的低字节格式。如果溢出发生,那么

结果的符号可能和两个数的数学结果的符号不符。

 

Notes

If a virtual machine does not support the int data type, the i2s instruction will not be 

available.

如果虚拟机不支持int数据类型,iadd指令将无效。

 

7.5.29 iaload

Load int from array

从数组中加载整数

 

Format

iaload

 

Forms

iaload = 39 (0x27)

 

Stack

…, arrayref, index ->

…, value.word1, value.word2

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type int. The index must be of type short. Both arrayref and index are popped 

from the operand stack. The int value in the component of the array at index is 

retrieved and pushed onto the top of the operand stack.

描述

arrayref必须是引用类型,并且必须指向一个int类型的数组。index必须是short类型,arrayref和index都是

从操作栈弹出,数组中对应下标的int值读出,并压入操作栈。

 

Runtime Exceptions

If arrayref is null, iaload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

iaload instruction throws an ArrayIndexOutOfBoundsException.

运行态异常

如果arrayref是null,iaload抛出一个空指针异常。

否则,如果index不再arrayref的范围内,iaload命令抛出ArrayIndexOutOfBoundsException。

 

Notes

In some circumstances, the iaload instruction may throw a SecurityException if the 

current context Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the iaload instruction will 

not be available.

注释

在iaload命令的arrayref的上下文和当前上下文不符的时候,iaload指令会抛出安全异常。参见JCRE第六章。

如果一个虚拟机不支持int数据类型,iaload命令将无效。

 

7.5.30 iand

Boolean AND int

int类型的布尔AND

 

Format

iand

Forms

iand = 84 (0x54)

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. They are popped from the operand 

stack. An int result is calculated by taking the bitwise AND (conjunction) of value1 

and value2. The result is pushed onto the operand stack.

value1和value2必须是int类型,它们从操作栈弹出。int类型的结果是通过value1和value2的比特级与操作得到。

结果压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the iand instruction will not 

be available.

注意

如果虚拟机不支持int数据类型,iand命令将无效。

 

 

7.5.31 iastore

Store into int array

 

Format

iastore

Forms

iastore = 58 (0x3a)

Stack

…, arrayref, index, value.word1, value.word2 ->

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type int. The index must be of type short and value must be of type int. The 

arrayref, index and value are popped from the operand stack. The int value is stored 

as the component of the array indexed by index.

描述

arrayref必须是引用类型,并且必须指向int类型的数组。index必须是short类型,value必须是int类型。

arrayref,index和value从操作栈弹出,int值是存储在数组对应下标的位置。

 

Runtime Exception

If arrayref is null, iastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

iastore instruction throws an ArrayIndexOutOfBoundsException.

运行态异常

如果arrayref是null,iastore抛出一个空指针异常。

否则,如果index不再arrayref指向的数组范围内,iastore命令抛出ArrayIndexOutOfBoundsException异常。

 

Notes

In some circumstances, the iastore instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the iastore instruction will 

not be available.

注释

在iastore命令的arrayref的上下文和当前上下文不符的时候,iastore指令会抛出安全异常。参见JCRE第六章。

如果一个虚拟机不支持int数据类型,iaload命令将无效。

 

7.5.32 icmp

Compare int

比较int值

 

Format

icmp

Forms

icmp = 95 (0x5f)

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result

 

Description

Both value1 and value2 must be of type int. They are both popped from the operand 

stack, and a signed integer comparison is performed. If value1 is greater than value2, 

the short value 1 is pushed onto the operand stack. If value1 is equal to value2, the 

short value 0 is pushed onto the operand stack. If value1 is less than value2, the 

short value –1 is pushed onto the operand stack.

描述

value1和value2必须是int类型,他们都是从操作栈弹出,然后执行有符号整数比较。如果value1比value2大,

short值1被压入操作栈,如果value1等于value2,short值0压入操作栈,如果value1小于value2,short值-1压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the icmp instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,icmp指令将无效。

 

7.5.33 iconst_<i>

Push int constant

压入int常量

 

Format

iconst_<i>

Forms

iconst_m1 = 10 (0x09)

iconst_0 = 11 (0xa)

iconst_1 = 12 (0xb)

iconst_2 = 13 (0xc)

iconst_3 = 14 (0xd)

iconst_4 = 15 (0xe)

iconst_5 = 16 (0xf)

Stack

…->

…, <i>.word1, <i>.word2

 

Description

Push the int constant <i> (-1, 0, 1, 2, 3, 4, or 5) onto the operand stack.

描述

将int常量<i> (-1, 0, 1, 2, 3, 4, or 5)压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the iconst_<i> instruction 

will not be available.

注释

如果虚拟机不支持int数据类型,iconst_<i>指令无效

 

7.5.34 idiv

Divide int

int除法

 

Format

idiv

Forms

idiv = 72 (0x48)

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. The int result is the value of the Java expression value1 / value2. The 

result is pushed onto the operand stack.

An int division rounds towards 0; that is, the quotient produced for int values in 

n/d is an int value q whose magnitude is as large as possible while satisfying | d · q 

| <= | n |. Moreover, q is a positive when | n | >= | d | and n and d have the 

same sign, but q is negative when | n | >= | d | and n and d have opposite signs.

There is one special case that does not satisfy this rule: if the dividend is the negative 

integer of the largest possible magnitude for the int type, and the divisor is –1, then 

overflow occurs, and the result is equal to the dividend. Despite the overflow, no 

exception is thrown in this case.

描述

value1和value2必须是int类型。数据从操作栈弹出。结果为value1/value2的int值。结果压入操作栈。

n/d的结果为q,当|n|>=|d|并且,n和d符号相同的时候q为正数。当|n|>=|d|并且n和d符号不同的时候,

q为负数。有一个特殊情况不满足这个规则。如果被除数是负数最大值,而除数是-1的时,由于int的溢出

结果等于被除数。在这种情况下无视溢出,没有异常抛出。

 

Runtime Exception

If the value of the divisor in an int division is 0, idiv throws an ArithmeticException.

运行态异常

如果被除数的值是0,idiv抛出一个ArithmeticException。

 

Notes

If a virtual machine does not support the int data type, the idiv instruction will not 

be available.

注释

如果虚拟机不支持int数据类型。idiv命令将无效。

 

 

7.5.35 if_acmp<cond>

Branch if reference comparison succeeds.

如果引用比较成功,跳转

 

Format

if_acmp<cond>

branch

 

Forms

if_acmpeq = 104 (0x68)

if_acmpne = 105 (0x69)

 

Stack

…, value1, value2 ->

 

Description

Both value1 and value2 must be of type reference. They are both popped from the 

operand stack and compared. The results of the comparisons are as follows:

■ eq succeeds if and only if value1 = value2

■ ne succeeds if and only if value1 ? value2

If the comparison succeeds, branch is used as signed 8-bit offset, and execution 

proceeds at that offset from the address of the opcode of this if_acmp<cond> 

instruction. The target address must be that of an opcode of an instruction within the 

method that contains this if_acmp<cond> instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if_acmp<cond> instruction.

描述

value1和value2必须是引用类型。他们都是从操作栈弹出,并比对。比对的结果如下:

■ 只有value1=value2,eq成功。

■ 只有value1!=value2,ne成功

如果比对成功,branch是一个8-bit有符号的偏移,起始偏移为if_acmp操作吗的地址,目标偏移必须指向

包含if_acmp命令的方法的某个字节码。

否则,继续执行if_acmp后边的命令。

 

7.5.36 if_acmp<cond>_w

Branch if reference comparison succeeds (wide index)

如果引用比较成功,跳转(宽下标)

 

Format

if_acmp<cond>_w

branchbyte1

branchbyte2

Forms

if_acmpeq_w = 160 (0xa0)

if_acmpne_w = 161 (0xa1)

Stack

…, value1, value2 ->

 

Description

Both value1 and value2 must be of type reference. They are both popped from the 

operand stack and compared. The results of the comparisons are as follows:

■ eq succeeds if and only if value1 = value2

■ ne succeeds if and only if value1 ? value2

If the comparison succeeds, the unsigned bytes branchbyte1 and branchbyte2 are 

used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 

8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of 

this if_acmp<cond>_w instruction. The target address must be that of an opcode of 

an instruction within the method that contains this if_acmp<cond>_w instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if_acmp<cond>_w instruction.

描述

value1和value2都必须是引用类型。它们从操作栈弹出和比对。比对的结果如下:

■ 只有value1=value2,eq成功。

■ 只有value1!=value2,ne成功

如果比对成功,branch是一个16-bit有符号(branchbyte1<<8|branchbyte2)的偏移,起始偏移为if_acmp_w操作吗的地址,目标偏移必须指向

包含if_acmp_w命令的方法的某个字节码。

否则,继续执行if_acmp_w后边的命令。

 

 

7.5.37 if_scmp<cond>

Branch if short comparison succeeds

short类型比较跳转。

 

Format

if_scmp<cond>

branch

 

Forms

if_scmpeq = 106 (0x6a)

if_scmpne = 107 (0x6b)

if_scmplt = 108 (0x6c)

if_scmpge = 109 (0x6d)

if_scmpgt = 110 (0x6e)

if_scmple = 111 (0x6f)

Stack

…, value1, value2 ->

 

Description

Both value1 and value2 must be of type short. They are both popped from the 

operand stack and compared. All comparisons are signed. The results of the 

comparisons are as follows:

■ eq succeeds if and only if value1 = value2

■ ne succeeds if and only if value1 != value2

■ lt succeeds if and only if value1 < value2

■ le succeeds if and only if value1 <= value2

■ gt succeeds if and only if value1 > value2

■ ge succeeds if and only if value1 >= value2

If the comparison succeeds, branch is used as signed 8-bit offset, and execution 

proceeds at that offset from the address of the opcode of this if_scmp<cond> 

instruction. The target address must be that of an opcode of an instruction within the 

method that contains this if_scmp<cond> instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if_scmp<cond> instruction.

描述

同上。比较short类型。

 

7.5.38 if_scmp<cond>_w

Branch if short comparison succeeds (wide index)

short比较成功跳转(宽下标)

 

Format

if_scmp<cond>_w

branchbyte1

branchbyte2

Forms

if_scmpeq_w = 162 (0xa2)

if_scmpne_w = 163 (0xa3)

if_scmplt_w = 164 (0xa4)

if_scmpge_w = 165 (0xa5)

if_scmpgt_w = 166 (0xa6)

if_scmple_w = 167 (0xa7)

Stack

…, value1, value2 ->

 

Description

Both value1 and value2 must be of type short. They are both popped from the 

operand stack and compared. All comparisons are signed. The results of the 

comparisons are as follows:

■ eq succeeds if and only if value1 = value2

■ ne succeeds if and only if value1 != value2

■ lt succeeds if and only if value1 < value2

■ le succeeds if and only if value1 <= value2

■ gt succeeds if and only if value1 > value2

■ ge succeeds if and only if value1 >= value2

If the comparison succeeds, the unsigned bytes branchbyte1 and branchbyte2 are 

used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 

8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of 

this if_scmp<cond>_w instruction. The target address must be that of an opcode of 

an instruction within the method that contains this if_scmp<cond>_w instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if_scmp<cond>_w instruction.

描述

同上

 

 

7.5.39 if<cond>

Branch if short comparison with zero succeeds

short和0比较成功跳转

 

Format

if<cond>

branch

Forms

ifeq = 96 (0x60)

ifne = 97 (0x61)

iflt = 98 (0x62)

ifge = 99 (0x63)

ifgt = 100 (0x64)

ifle = 101 (0x65)

 

Stack

…, value ->

 

Description

The value must be of type short. It is popped from the operand stack and compared 

against zero. All comparisons are signed. The results of the comparisons are as 

follows:

■ eq succeeds if and only if value = 0

■ ne succeeds if and only if value != 0

■ lt succeeds if and only if value < 0

■ le succeeds if and only if value <= 0

■ gt succeeds if and only if value > 0

■ ge succeeds if and only if value >= 0

If the comparison succeeds, branch is used as signed 8-bit offset, and execution 

proceeds at that offset from the address of the opcode of this if<cond> instruction. 

The target address must be that of an opcode of an instruction within the method 

that contains this if<cond> instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if<cond> instruction.

描述

同上

 

 

7.5.40 if<cond>_w

Branch if short comparison with zero succeeds (wide index)

short和0比较成功跳转(宽下标)

 

Format

if<cond>_w

branchbyte1

branchbyte2

Forms

ifeq_w = 152 (0x98)

ifne_w = 153 (0x99)

iflt_w = 154 (0x9a)

ifge_w = 155 (0x9b)

ifgt_w = 156 (0x9c)

ifle_w = 157 (0x9d)

Stack

…, value ->

 

Description

The value must be of type short. It is popped from the operand stack and compared 

against zero. All comparisons are signed. The results of the comparisons are as 

follows:

■ eq succeeds if and only if value = 0

■ ne succeeds if and only if value != 0

■ lt succeeds if and only if value < 0

■ le succeeds if and only if value <= 0

■ gt succeeds if and only if value > 0

■ ge succeeds if and only if value >= 0

If the comparison succeeds, the unsigned bytes branchbyte1 and branchbyte2 are 

used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 

8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of 

this if<cond>_w instruction. The target address must be that of an opcode of an 

instruction within the method that contains this if<cond>_w instruction.

Otherwise, execution proceeds at the address of the instruction following this 

if<cond>_w instruction.

描述

同上

 

 

7.5.41 ifnonnull

Branch if reference not null

如果引用不是null跳转

 

Format

ifnonnull

branch

Forms

ifnonnull = 103 (0x67)

Stack

…, value ->

 

Description

The value must be of type reference. It is popped from the operand stack. If the 

value is not null, branch is used as signed 8-bit offset, and execution proceeds at that 

offset from the address of the opcode of this ifnonnull instruction. The target 

address must be that of an opcode of an instruction within the method that contains 

this ifnonnull instruction.

Otherwise, execution proceeds at the address of the instruction following this 

ifnonnull instruction.

描述

同上,比对引用是否为非null

 

7.5.42 ifnonnull_w

Branch if reference not null (wide index)

比对引用是否不是null(宽下标)

 

Format

ifnonnull_w

branchbyte1

branchbyte2

Forms

ifnonnull_w = 159 (0x9f)

Stack

…, value ->

 

Description

The value must be of type reference. It is popped from the operand stack. If the 

value is not null, the unsigned bytes branchbyte1 and branchbyte2 are used to 

construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 8) | 

branchbyte2. Execution proceeds at that offset from the address of the opcode of this 

ifnonnull_w instruction. The target address must be that of an opcode of an 

instruction within the method that contains this ifnonnull_w instruction.

Otherwise, execution proceeds at the address of the instruction following this 

ifnonnull_w instruction.

描述

同上。

 

 

7.5.43 ifnull

Branch if reference is null

如果引用是null跳转

 

Format

ifnull

branch

Forms

ifnull = 102 (0x66)

Stack

…, value ->

 

Description

The value must be of type reference. It is popped from the operand stack. If the 

value is null, branch is used as signed 8-bit offset, and execution proceeds at that 

offset from the address of the opcode of this ifnull instruction. The target address 

must be that of an opcode of an instruction within the method that contains this 

ifnull instruction.

Otherwise, execution proceeds at the address of the instruction following this ifnull 

instruction.

描述

同上

 

7.5.44 ifnull_w

Branch if reference is null (wide index)

如果引用是null跳转(宽下标)

 

Format

ifnull_w

branchbyte1

branchbyte2

Forms

ifnull_w = 158 (0x9e)

 

Stack

…, value ->

 

Description

The value must be of type reference. It is popped from the operand stack. If the 

value is null, the unsigned bytes branchbyte1 and branchbyte2 are used to construct 

a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 8) | 

branchbyte2. Execution proceeds at that offset from the address of the opcode of this 

ifnull_w instruction. The target address must be that of an opcode of an instruction 

within the method that contains this ifnull_w instruction.

Otherwise, execution proceeds at the address of the instruction following this 

ifnull_w instruction.

描述

同上

 

 

7.5.45 iinc

Increment local int variable by constant

本地int变量加常数

 

Format

iinc

index

const

 

Forms 

iinc = 90 (0x5a)

Stack

No change

 

Description

The index is an unsigned byte. Both index and index + 1 must be valid indices into 

the local variables of the current frame (Section 3.5, “Frames” on page 3-3). The local 

variables at index and index + 1 together must contain an int. The const is an 

immediate signed byte. The value const is first sign-extended to an int, then the int 

contained in the local variables at index and index + 1 is incremented by that 

amount.

描述

index是一个无符号byte。index和index+1必须是当前frame的本地变量中有效的下标。本地变量中的

index和index+1合并成一个int。const是一个立即型有符号byte。const值首先有符号扩展为一个int,

然后index和index+1的本地变量加上这个数字。

 

Notes

If a virtual machine does not support the int data type, the iinc instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,iinc命令将无效。

 

7.5.46 iinc_w

Increment local int variable by constant

本地int变量加常数(宽)

 

Format

iinc_w

index

byte1

byte2

Forms

iinc_w = 151 (0x97)

 

Stack

No change

 

Description

The index is an unsigned byte. Both index and index + 1 must be valid indices into 

the local variables of the current frame (Section 3.5, “Frames” on page 3-3). The local 

variables at index and index + 1 together must contain an int. The immediate 

unsigned byte1 and byte2 values are assembled into an intermediate short where the 

value of the short is (byte1 << 8) | byte2. The intermediate value is then sign-

extended to an int const. The int contained in the local variables at index and index 

+ 1 is incremented by const.

描述

同上,区别是立即数为(byte1<<8 | byte2)的short值。

 

Notes

If a virtual machine does not support the int data type, the iinc_w instruction will 

not be available.

注释

如果虚拟机不支持int数据类型,iinc命令将无效。

 

 

7.5.47 iipush

Push int

压入int数值

 

Format

iipush

byte1

byte2

byte3

byte4

Forms

iipush = 20 (0x14)

Stack

…->

…, value1.word1, value1.word2

 

Description

The immediate unsigned byte1, byte2, byte3, and byte4 values are assembled into a 

signed int where the value of the int is (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | 

byte4. The resulting value is pushed onto the operand stack.

描述

立即数byte1,2,3,4组成一个有符号的int值((byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4)。

结果压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the iipush instruction will 

not be available.

注释

如果虚拟机不支持int数据类型,iipush命令将无效。

 

 

7.5.48 iload

Load int from local variable

从本地变量导入int值

 

Format

iload

index

Forms

iload = 23 (0x17)

 

Stack

… ->

…, value1.word1, value1.word2

 

Description

The index is an unsigned byte. Both index and index + 1 must be valid indices into 

the local variables of the current frame (Section 3.5, “Frames” on page 3-3). The local 

variables at index and index + 1 together must contain an int. The value of the local 

variables at index and index + 1 is pushed onto the operand stack.

描述

index是一个无符号byte,index和index+1都必须是指向当前frame的本地变量的有效下标。在index和index+1

位置的本地变量一起组成一个int值。这个值被压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the iload instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,iload命令将无效。

 

 

7.5.49 iload_<n>

Load int from local variable

 

Format

iload_<n>

Forms

iload_0 = 32 (0x20)

iload_1 = 33 (0x21)

iload_2 = 34 (0x22)

iload_3 = 35 (0x23)

Stack

… ->

…, value1.word1, value1.word2

 

Description

Both <n> and <n> + 1 must be a valid indices into the local variables of the current 

frame (Section 3.5, “Frames” on page 3-3). The local variables at <n> and <n> + 1 

together must contain an int. The value of the local variables at <n> and <n> + 1 is 

pushed onto the operand stack.

描述

同上,iload快速版。

 

Notes

Each of the iload_<n> instructions is the same as iload with an index of <n>, except 

that the operand <n> is implicit.

If a virtual machine does not support the int data type, the iload_<n> instruction 

will not be available.

 

 

7.5.50 ilookupswitch

Access jump table by key match and jump

通过关键字吻合访问跳转表并且跳转

 

Format

ilookupswitch

defaultbyte1

defaultbyte2

npairs1

npairs2

match-offset pairs…

 

Pair Format

matchbyte1

matchbyte2

matchbyte3

matchbyte4

offsetbyte1

offsetbyte2

Forms

ilookupswitch = 118 (0x76)

 

Stack

…, key.word1, key.word2 ->

 

Description

An ilookupswitch instruction is a variable-length instruction. Immediately after the 

ilookupswitch opcode follow a signed 16-bit value default, an unsigned 16-bit value 

npairs, and then npairs pairs. Each pair consists of an int match and a signed 16-bit 

offset. Each match is constructed from four unsigned bytes as (matchbyte1 << 24) | 

(matchbyte2 << 16) | (matchbyte3 << 8) | matchbyte4. Each offset is constructed 

from two unsigned bytes as (offsetbyte1 << 8) | offsetbyte2.

The table match-offset pairs of the ilookupswitch instruction must be sorted in 

increasing numerical order by match.

The key must be of type int and is popped from the operand stack and compared 

against the match values. If it is equal to one of them, then a target address is 

calculated by adding the corresponding offset to the address of the opcode of this 

ilookupswitch instruction. If the key does not match any of the match values, the 

target address is calculated by adding default to the address of the opcode of this 

ilookupswitch instruction. Execution then continues at the target address.

The target address that can be calculated from the offset of each match-offset pair, as 

well as the one calculated from default, must be the address of an opcode of an 

instruction within the method that contains this ilookupswitch instruction.

描述

ilookupswitch指令是一个变长指令。在ilookupswitch操作码后跟着一个有符号16-bit的默认值。一个无符号

16-bit的npairs,然后是npairs个npair。每个pair由一个int匹配数和一个有符号的16-bit偏移组成。

每个匹配数由4个无符号byte组成((matchbyte1 << 24) | (matchbyte2 << 16) | (matchbyte3 << 8) | matchbyte4),

每个偏移由两个无符号byte组成((offsetbyte1 << 8) | offsetbyte2.)

key必须是int类型,从操作栈弹出,并且和匹配数进行相比。如果等于其中一个,那么目标地址就可以通过

ilookupswitch的操作码地址加偏移值的方式获得。如果key和匹配数都不同,那么目标地址可以通过在ilookupswitch

操作吗地址加default值的方式获得。

目标地址必须指向包含ilookupswitch指令的方法中的某个操作码。

 

Notes

The match-offset pairs are sorted to support lookup routines that are quicker than 

linear search.

If a virtual machine does not support the int data type, the ilookupswitch instruction 

will not be available.

注释

match-offset对儿存储支持比线性查找更迅速的查找过程。

如果虚拟机不支持int数据类型,ilookupswitch指令将无效。

 

 

7.5.51 imul

Multiply int

int乘法

 

Format

imul

Forms

imul = 70 (0x46)

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. The int result is value1 * value2. The result is pushed onto the 

operand stack.

If an imul instruction overflows, then the result is the low-order bits of the 

mathematical product as an int. If overflow occurs, then the sign of the result may 

not be the same as the sign of the mathematical product of the two values.

描述

value1和value2必须是int类型,数据从操作栈弹出,结果为value1×value2的int值。结果压入操作栈。

如果imul指令溢出,那么数学结果的低比特将作为结果。如果溢出发生,那么结果的符号和数学结果的符号可能不一致。

 

Notes

If a virtual machine does not support the int data type, the imul instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,imul指令将无效。

 

 

7.5.52 ineg

Negate int

int求负

 

Format

ineg

Forms

ineg = 76 (0x4c)

 

Stack

…, value.word1, value.word2 ->

…, result.word1, result.word2

 

Description

The value must be of type int. It is popped from the operand stack. The int result is 

the arithmetic negation of value, -value. The result is pushed onto the operand stack.

For int values, negation is the same as subtraction from zero. Because the Java Card 

virtual machine uses two’s-complement representation for integers and the range of 

two’s-complement values is not symmetric, the negation of the maximum negative 

int results in that same maximum negative number. Despite the fact that overflow 

has occurred, no exception is thrown.

For all int values x, -x equals (~x) + 1.

描述

value必须是int类型,它从操作栈弹出,结果是value的负数。结果压入操作栈。

对int数值来说,负值和0-值的结果相同。因为java卡虚拟机使用两的补位来描述整数,最大负数的负数

就是它自己。无视溢出的发生,不抛出异常。

 

Notes

If a virtual machine does not support the int data type, the ineg instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,ineg指令将无效。

 

7.5.53 instanceof

Determine if object is of given type

判断对象是否给定的类型

 

Format

instanceof

atype

indexbyte1

indexbyte2

Forms

instanceof = 149 (0x95)

 

Stack

…, objectref ->

…, result

 

Description

The unsigned byte atype is a code that indicates if the type against which the object 

is being checked is an array type or a class type. It must take one of the following 

values or zero:

 

TABLE 7-3  Array Values

Array Type atype

T_BOOLEAN 10

T_BYTE 11

T_SHORT 12

T_INT 13

T_REFERENCE 14

 

If the value of atype is 10, 11, 12, or 13, the values of the indexbyte1 and indexbyte2 

must be zero, and the value of atype indicates the array type against which to check 

the object. Otherwise the unsigned indexbyte1 and indexbyte2 are used to construct 

an index into the constant pool of the current package (Section 3.5, “Frames” on 

page 3-3), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item 

at that index in the constant pool must be of type CONSTANT_Classref 

(Section 6.7.1, “CONSTANT_Classref” on page 6-16), a reference to a class or 

interface type. The reference is resolved. If the value of atype is 14, the object is 

checked against an array type that is an array of object references of the type of the 

resolved class. If the value of atype is zero, the object is checked against a class or 

interface type that is the resolved class.

The objectref must be of type reference. It is popped from the operand stack. If 

objectref is not null and is an instance of the resolved class, array or interface, the 

instanceof instruction pushes a short result of 1 on the operand stack. Otherwise it 

pushes a short result of 0.

The following rules are used to determine whether an objectref that is not null is an 

instance of the resolved type: if S is the class of the object referred to by objectref and 

T is the resolved class, array or interface type, instanceof determines whether 

objectref is an instance of T as follows:

 

■ If S is a class type, then:

■ If T is a class type, then S must be the same class as T, or S must be a subclass 

of T;

■ If T is an interface type, then S must implement interface T.

■ If S is an interface type1, then:

■ If T is a class type, then T must be Object (Section 2.2.2.4, “Classes” on 

page 2-7);

■ If T is an interface type, T must be the same interface as S or a superinterface of 

S.

■ If S is an array type, namely the type SC[], that is, an array of components of type 

SC, then:

■ If T is a class type, then T must be Object.

■ If T is an array type, namely the type TC[], an array of components of type TC, 

then one of the following must be true:

TC and SC are the same primitive type (Section 3.1, “Data Types and Values” 

on page 3-1).

TC and SC are reference types1 (Section 3.1, “Data Types and Values” on 

page 3-1) with type SC assignable to TC, by these rules.

■ If T is an interface type, T must be one of the interfaces implemented by arrays.

描述

无符号字节atype是一个用来表示与被检查对象相对的是否是一个数组类型或者一个类。它必须是以下的值或者0:

TABLE 7-3  Array Values

Array Type atype

T_BOOLEAN 10

T_BYTE 11

T_SHORT 12

T_INT 13

T_REFERENCE 14

如果atype的值是10,11,12,或者13,indexbyte1和indexbyte2的值必须是0,atype的值标识了检查对象

对应的数组类型。否则indexbyte1和indexbyte2用来构建一个指向当前包常量池的下标,(indexbyte1<<8 | indexbyte2)。

对应下标位置必须是一个CONSTANT_Classref类型。指向一个类或者接口类型。如果atype的值是14,那个对应检查对象的类型

是指向index对应的类和接口的数组。

objectref必须是引用类型。它从操作栈弹出。如果object不是null,并且是一个类,数组或者接口的实例,instanceof指令

压入一个short结果1到操作栈,否则,压入结果0.

以下的规则用来决定是否objectref不是null,是一个已知类型的实例:如果S是objectref的类,T是比较类,数组或者接口类型。

instanceof判断是否objectref是T的实例遵从:

■ 如果S是一个类

■ 如果T是一个类,那么S必须是和T一样的类,或者S必须是T的子类。

■ 如果T是一个接口,那么S必须实现了接口T。

■ 如果S是一个接口

■ 如果T是一个类,那么T必须是Object类

■ 如果T是一个接口,那么S必须是和T一样的接口,或者S必须是T的子接口。

■ 如果S一个数组类型,命名为SC[],也就是数组内容为SC类型

■ 如果T是一个类,那么T必须是Object

■ 如果T是一个数组类型,命名为TC[],数组内容为TC类型,那么一下的必须有一个是真:

TC和SC是相同的基本类型。

TC和SC是引用类型,SC可分配给TC。

■ 如果T是一个接口,T必须是数组实现的接口。

 

Notes

The instanceof instruction is fundamentally very similar to the checkcast instruction. 

It differs in its treatment of null, its behavior when its test fails (checkcast throws an 

exception, instanceof pushes a result code), and its effect on the operand stack.

In some circumstances, the instanceof instruction may throw a SecurityException if 

the current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the value of atype may not 

be 13 (array type = T_INT).

注意

instanceof命令功能性和checkcast命令非常相近。它们在对待null上存在不同,它们对待测试失败也不同(checkcast抛出异常,

instanceof返回结果),而且他们对栈的影响也不同。

在instanceof的objectref的上下文和当前上下文不同的时候,instanceof命令可能抛出安全异常。详见JCRE第六章。

如果虚拟机不支持int数据类型,atype的值不能是13。

 

 

7.5.54 invokeinterface

Invoke interface method

执行接口方法

 

Format

invokeinterface

nargs

indexbyte1

indexbyte2

method

Forms

invokeinterface = 142 (0x8e)

Stack

…, objectref, [arg1, [arg2 …]] ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at that 

index must be of type CONSTANT_Classref (Section 6.7.1, “CONSTANT_Classref” 

on page 6-16), a reference to an interface class. The specified interface is resolved. 

The nargs operand is an unsigned byte that must not be zero. 

The method operand is an unsigned byte that is the interface method token for the 

method to be invoked. The interface method must not be <init> or an instance 

initialization method.

The objectref must be of type reference and must be followed on the operand stack 

by nargs – 1 words of arguments. The number of words of arguments and the type 

and order of the values they represent must be consistent with those of the selected 

interface method.

The interface table of the class of the type of objectref is determined. If objectref is an 

array type, then the interface table of class Object (Section 2.2.2.4, “Classes” on 

page 2-7) is used. The interface table is searched for the resolved interface. The result 

of the search is a table that is used to map the method token to a index.

The index is an unsigned byte that is used as an index into the method table of the 

class of the type of objectref. If the objectref is an array type, then the method table 

of class Object is used. The table entry at that index includes a direct reference to the 

method’s code and modifier information.

The nargs – 1 words of arguments and objectref are popped from the operand stack. 

A new stack frame is created for the method being invoked, and objectref and the 

arguments are made the values of its first nargs words of local variables, with 

objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame 

is then made current, and the Java Card virtual machine pc is set to the opcode of 

the first instruction of the method to be invoked. Execution continues with the first 

instruction of the method.

描述

无符号的indexbyte1和indexbyte2用来组成一个指向当前包的常量池的下标。对应下标必须是一个CONSTANT_Classref类型,

指向一个接口。nargs操作数是一个无符号的byte,必须不能是0.

method操作数是一个无符号的byte,也就是调用方法的接口方法令牌。接口方法必须不是<init>或者实例初始化方法。

objectref必须是一个引用类型,并且必须在操作栈的nargs-1参数位置。参数的个数和类型与接口函数的调用顺序一致。

object的接口表确定了,如果objectref是一个数组类型,那么将使用Object类的接口表。在接口表中查找接口,查找的结果

是一个对应下标的方法令牌。

index是一个无符号的byte,用来指向object的类的方法表。对应方法表的入口包含了方法代码和描述信息的直接引用。

nargs-1个参数和objectref从操作栈弹出,一个新的栈为调用的方法创建,objectref和参数放入新栈的参数区。

objectref在本地变量0,arg1在本地变量1 。。。然后新的栈帧被设置为当前栈帧。java卡虚拟机的pc也被设置指向被执行

的方法的第一个命令的操作码上。继续执行。

 

Runtime Exception

If objectref is null, the invokeinterface instruction throws a NullPointerException.

运行态异常

如果objectref是null,invokeinterface指令抛出空指针异常。

 

Notes

In some circumstances, the invokeinterface instruction may throw a 

SecurityException if the current context (Section 3.4, “Contexts” on page 3-2) is not 

the context (Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. 

The exact circumstances when the exception will be thrown are specified in Chapter 

6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2. If the 

current context is not the object’s context and the Java Card RE permits invocation of 

the method, the invokeinterface instruction will cause a context switch (Section 3.4, 

“Contexts” on page 3-2) to the object’s context before invoking the method, and will 

cause a return context switch to the previous context when the invoked method 

returns.

注释

在objectref的上下文和当前上下文不同的时候,invokeinterface可能抛出一个安全异常。具体参见JCRE第六章。

如果当前上下文和对象的上下文不同,并且JCRE允许方法的调用,invokeinterface指令将会导致在方法执行前执行一次上下文切换。

并且在方法返回时,执行一次之前上下文切换。

 

 

7.5.55 invokespecial

Invoke instance method; special handling for superclass, private, and instance 

initialization method invocations

调用实例方法;特定处理父类,私有和实例初始化方法调用

 

Format

invokespecial

indexbyte1

indexbyte2

Forms

invokespecial = 140 (0x8c)

Stack

…, objectref, [arg1, [arg2 …]] ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. If the invoked method is a 

private instance method or an instance initialization method, the constant pool item 

at index must be of type CONSTANT_StaticMethodref (Section 6.7.3, 

“CONSTANT_StaticFieldref and CONSTANT_StaticMethodref” on page 6-19), a 

reference to a statically linked instance method. If the invoked method is a 

superclass method, the constant pool item at index must be of type 

CONSTANT_SuperMethodref (Section 6.7.2, “CONSTANT_InstanceFieldref, 

CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref” on page 6-18), a 

reference to an instance method of a specified class. The reference is resolved. The 

resolved method must not be <clinit>, a class or interface initialization method. If 

the method is <init>, an instance initialization method, then the method must only 

be invoked once on an uninitialized object, and before the first backward branch 

following the execution of the new instruction that allocated the object. Finally, if the 

resolved method is protected, and it is a member of a superclass of the current class, 

and the method is not declared in the same package as the current class, then the 

class of objectref must be either the current class or a subclass of the current class.

The resolved method includes the code for the method, an unsigned byte nargs that 

must not be zero, and the method’s modifier information.

The objectref must be of type reference, and must be followed on the operand stack 

by nargs – 1 words of arguments, where the number of words of arguments and the 

type and order of the values they represent must be consistent with those of the 

selected instance method.

The nargs – 1 words of arguments and objectref are popped from the operand stack. 

A new stack frame is created for the method being invoked, and objectref and the 

arguments are made the values of its first nargs words of local variables, with 

objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame 

is then made current, and the Java Card virtual machine pc is set to the opcode of 

the first instruction of the method to be invoked. Execution continues with the first 

instruction of the method.

描述

无符号indexbyte1和indexbyte2用来组成一个指向当前包常量池的下标。如果调用的方法是一个私有实例方法或者实例初始化方法,

常量池对应的位置是CONSTANT_StaticMethodref类型,指向静态链接的实例方法。如果调用的方法是一个父类方法,常量池对应

的位置是CONSTANT_SuperMethodref,指向一个特定类的实例方法。方法不能是<clinit>,一个类或者接口初始化方法。

如果方法是<init>,一个实例初始化方法,那么方法只能被执行在一个未初始化的对象上,方法执行前的指令必须是new--用来给对象申请空间

的指令。最终,如果确定的方法是proctected,并且是当前类的父类的成员,并且方法不和当前类定义在同一个包内,那么

objectref必须或者是当前类,或者是当前类的父类。确定的方法包含了方法的代码,一个无符号byte非0的nargs来表示方法的信息。

objectref必须是引用类型,必须跟在操作栈nargs-1个字之后。

nargs-1个参数和objectref从操作栈弹出,一个为调用方法需要的新的栈帧创建,objectref和参数作为新栈帧0-nargs的本地变量。

pc指向被调用方法的第一个指令的操作码。继续执行。

 

Runtime Exception

If objectref is null, the invokespecial instruction throws a NullPointerException.

运行态异常

如果objectref是null,invokespecial命令抛出空指针异常。

 

 

7.5.56 invokestatic

Invoke a class (static) method

Format

invokestatic

indexbyte1

indexbyte2

Forms

invokestatic = 141 (0x8d)

 

Stack

…, [arg1, [arg2 …]] ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at that 

index must be of type CONSTANT_StaticMethodref (Section 6.7.3, 

“CONSTANT_StaticFieldref and CONSTANT_StaticMethodref” on page 6-19), a 

reference to a static method. The method must not be <init>, an instance 

initialization method, or <clinit>, a class or interface initialization method. It must be 

static, and therefore cannot be abstract.

The resolved method includes the code for the method, an unsigned byte nargs that 

may be zero, and the method’s modifier information.

The operand stack must contain nargs words of arguments, where the number of 

words of arguments and the type and order of the values they represent must be 

consistent with those of the resolved method.

The nargs words of arguments are popped from the operand stack. A new stack 

frame is created for the method being invoked, and the words of arguments are 

made the values of its first nargs words of local variables, with arg1 in local variable 

0, arg2 in local variable 1, and so on. The new stack frame is then made current, and 

the Java Card virtual machine pc is set to the opcode of the first instruction of the 

method to be invoked. Execution continues with the first instruction of the method.

描述

无符号indexbyte1和indexbyte2用来组成一个指向当前包常量池的下标(indexbyte1<<8 | indexbyte2)。

对应位置的常量池对象必须是CONSTANT_StaticMethodref。方法不能是<init>实例初始化方法,也不能是

<clinit>类初始化方法。它必须是静态的,也不能是虚的方法。

确定的方法包含了方法的代码,一个无符号byte非0的nargs,以及方法描述信息。

操作栈必须包含nargs个参数,按调用顺序排列。

nargs个参数从操作栈弹出。被调用方法的新栈帧被创建,参数按顺序放入本地变量区。新的栈帧变成当前的,

并且Java卡虚拟机pc被设置为被调用方法的首命令的操作码,继续执行。

 

7.5.57 invokevirtual

Invoke instance method; dispatch based on class

调用实例方法,基于类派发

 

Format

invokevirtual

indexbyte1

indexbyte2

Forms

invokevirtual = 139 (0x8b)

 

Stack

…, objectref, [arg1, [arg2 …]] ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at that 

index must be of type CONSTANT_VirtualMethodref (Section 6.7.2, 

“CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and 

CONSTANT_SuperMethodref” on page 6-18), a reference to a class and a virtual 

method token. The specified method is resolved. The method must not be <init>, an 

instance initialization method, or <clinit>, a class or interface initialization method. 

Finally, if the resolved method is protected, and it is a member of a superclass of the 

current class, and the method is not declared in the same package as the current 

class, then the class of objectref must be either the current class or a subclass of the 

current class.

The resolved method reference includes an unsigned index into the method table of 

the resolved class and an unsigned byte nargs that must not be zero.

The objectref must be of type reference. The index is an unsigned byte that is used as 

an index into the method table of the class of the type of objectref. If the objectref is 

an array type, then the method table of class Object (Section 2.2.2.4, “Classes” on 

page 2-7) is used. The table entry at that index includes a direct reference to the 

method’s code and modifier information.

The objectref must be followed on the operand stack by nargs – 1 words of 

arguments, where the number of words of arguments and the type and order of the 

values they represent must be consistent with those of the selected instance method.

The nargs – 1 words of arguments and objectref are popped from the operand stack. 

A new stack frame is created for the method being invoked, and objectref and the 

arguments are made the values of its first nargs words of local variables, with 

objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame 

is then made current, and the Java Card virtual machine pc is set to the opcode of 

the first instruction of the method to be invoked. Execution continues with the first 

instruction of the method.

描述

无符号的indexbyte1和indexbyte2用来构成一个指向当前包常量池的下标,(indexbyte1 << 8) | indexbyte2。

对应位置的常量池必须是一个CONSTANT_VirtualMethodref,指向一个类和一个虚方法令牌。方法是确定的,

方法不能是<init>实例初始化函数或者<clinit>类初始化函数。

并且,如果方法是proctected,并且它是当前类的父类的成员,并且方法定义的类和当前类不同包,那么

objectref的类或者是当前类或者是当前类的父类。

确定的方法引用包含了一个指向method表的无符号下标,并且获得了无符号非0的nargs。

objectref必须是引用类型,index是用来指向objectref对应的类的method表的。表对应的位置包含了一个对方法

代码和描述信息的直接引用。

objectref必须跟在操作栈nargs-1的参数后,参数按调用顺序在操作栈排列。

nargs-1个参数和objectref从操作栈弹出,为被调用函数创建一个新的栈帧,将参数按顺序放入本地变量,pc设置为

新方法的第一个指令的操作码,继续执行。

 

Runtime Exception

If objectref is null, the invokevirtual instruction throws a NullPointerException.

In some circumstances, the invokevirtual instruction may throw a SecurityException 

if the current context (Section 3.4, “Contexts” on page 3-2) is not the context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2. If the current 

context is not the object’s context and the Java Card RE permits invocation of the 

method, the invokevirtual instruction will cause a context switch (Section 3.4, 

“Contexts” on page 3-2) to the object’s context before invoking the method, and will 

cause a return context switch to the previous context when the invoked method 

returns.

运行态异常

如果objectref是null,invokevirtual指令抛出空指针异常。在当前上下文和objectref的上下文不同,

invokevirtual有可能抛出安全异常。详细参见JCRE 第六章。如果当前上下文和object的上下文不同,

并且JCRE允许调用方法。invokevirtual指令将引发一个上下文切换。并在调用函数返回的时候切换回来。

 

 

7.5.58 ior

Boolean OR int

int的布尔或操作

 

Format

ior

Forms

ior = 86 (0x56)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. An int result is calculated by taking the bitwise inclusive OR of 

value1 and value2. The result is pushed onto the operand stack.

描述

value1和value2必须是int类型,value从操作栈弹出,通过value1和value2做比特级或操作得到int结果,结果压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the ior instruction will not be 

available.

注释

如果虚拟机不支持int数据类型,ior命令将无效。

 

 

7.5.59 irem

Remainder int

int求余

 

Format

irem

Forms

irem = 74 (0x4a)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. The int result is the value of the Java expression value1 – (value1 / 

value2) * value2. The result is pushed onto the operand stack.

The result of the irem instruction is such that (a/b)*b + (a%b) is equal to a. This 

identity holds even in the special case that the dividend is the negative int of largest 

possible magnitude for its type and the divisor is –1 (the remainder is 0). It follows 

from this rule that the result of the remainder operation can be negative only if the 

dividend is negative and can be positive only if the dividend is positive. Moreover, 

the magnitude of the result is always less than the magnitude of the divisor.

描述

value1和value2必须是int类型,value从操作栈弹出。value1-(value1/value2)*value2。结果被压入操作栈。

因为中间设计除法,也有溢出的可能

 

Runtime Exception

If the value of the divisor for a short remainder operator is 0, irem throws an 

ArithmeticException.

运行态异常

如果余数是0,irem抛出数学异常。

 

Notes

If a virtual machine does not support the int data type, the irem instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,irem指令将无效。

 

 

7.5.60 ireturn

Return int from method

 

Format

ireturn

 

Forms

ireturn = 121 (0x79)

 

Stack

…, value.word1, value.word2 ->

[empty]

 

Description

The value must be of type int. It is popped from the operand stack of the current 

frame (Section 3.5, “Frames” on page 3-3) and pushed onto the operand stack of the 

frame of the invoker. Any other values on the operand stack of the current method 

are discarded.

The virtual machine then reinstates the frame of the invoker and returns control to 

the invoker.

描述

value必须是int类型,它从当前frame的操作栈中弹出,并且压入调用frame的操作栈,当前方法操作栈

的其它值都抛弃。

虚拟机然后回复调用者的frame,恢复调用者的控制权。

 

Notes

If a virtual machine does not support the int data type, the ireturn instruction will 

not be available.

描述

如果虚拟机不支持int数据类型,ireturn命令无效。

 

 

7.5.61 ishl

Shift left int

int类型左移

 

Format

ishl

 

Forms

ishl = 78 (0x4e)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. An int result is calculated by shifting value1 left by s bit positions, 

where s is the value of the low five bits of value2. The result is pushed onto the 

operand stack.

描述

value1和value2都必须是int类型,values从操作栈弹出,左移value1 value2个bit获得结果,并把结果压入操作栈

 

Notes

This is equivalent (even if overflow occurs) to multiplication by 2 to the power s. 

The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 

were subjected to a bitwise logical AND with the mask value 0x1f.

If a virtual machine does not support the int data type, the ishl instruction will not 

be available.

注释

这个操作等于乘法2的s次方。移动的距离一般是0到31.就像value2和0x1f与过一致。

如果虚拟机不支持int类型,ishl命令将无效。

 

7.5.63 istore

Store int into local variable

存储int到本地变量

 

Format

istore

index

 

Forms

istore = 42 (0x2a)

 

Stack

…, value.word1, value.word2 ->

 

Description

The index is an unsigned byte. Both index and index + 1 must be a valid index into 

the local variables of the current frame (Section 3.5, “Frames” on page 3-3). The 

value on top of the operand stack must be of type int. It is popped from the operand 

stack, and the local variables at index and index + 1 are set to value.

描述

index是一个无符号字节,index和index+1必须是一个有效的指向当前frame的本地变量的下标。

操作栈顶的值必须是int类型。它从操作栈弹出,并且在index和index+1的本地变量设置为这个值。

 

Notes

If a virtual machine does not support the int data type, the istore instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,istore命令将无效。

 

7.5.64 istore_<n>

Store int into local variable

存储int到本地变量

 

Format

istore_<n>

Forms

istore_0 = 51 (0x33)

istore_1 = 52 (0x34)

istore_2 = 53 (0x35)

istore_3 = 54 (0x36)

 

Stack

…, value.word1, value.word2 ->

 

Description

Both <n> and <n> + 1 must be a valid indices into the local variables of the current 

frame (Section 3.5, “Frames” on page 3-3). The value on top of the operand stack 

must be of type int. It is popped from the operand stack, and the local variables at 

index and index + 1 are set to value.

描述

n和n+1必须是一个有效的指向当前frame的本地变量的下标。操作栈顶的值必须是int类型。它从操作栈

弹出,在index和index+1的本地变量被设置为这个值。

 

Notes

If a virtual machine does not support the int data type, the istore_<n> instruction 

will not be available.

注释

如果虚拟机不支持int数据类型,istore_<n>命令将无效。

 

 

7.5.65 isub

Subtract int

int减法

 

Format

isub

Forms

isub = 68 (0x44)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. The int result is value1 - value2. The result is pushed onto the 

operand stack.

For int subtraction, a – b produces the same result as a + (–b). For int values, 

subtraction from zeros is the same as negation.

Despite the fact that overflow or underflow may occur, in which case the result may 

have a different sign than the true mathematical result, execution of an isub 

instruction never throws a runtime exception.

描述

value1和value2都是int类型,值从操作栈弹出value1-value2的结果被压入操作栈。

对int减法,a-b和a+(-b)的结果相同。对int值来说,0的减法和求负数相同。

不管事实上操作有没有溢出,在每种情况下结果可能和真正的数学结果符号不一致。减法操作从来不抛出运行态异常。

 

Notes

If a virtual machine does not support the int data type, the isub instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,isub指令将无效。

 

7.5.66 itableswitch

Access jump table by int index and jump

通过下标访问跳转表跳转

 

Format

itableswitch

defaultbyte1

defaultbyte2

lowbyte1

lowbyte2

lowbyte3

lowbyte4

highbyte1

highbyte2

highbyte3

highbyte4

jump offsets…

 

Offset Format

offsetbyte1

offsetbyte2

Forms

itableswitch = 116 (0x74)

 

Stack

…, index ->

 

Description

An itableswitch instruction is a variable-length instruction. Immediately after the 

itableswitch opcode follow a signed 16-bit value default, a signed 32-bit value low, a 

signed 32-bit value high, and then high – low + 1 further signed 16-bit offsets. The 

value low must be less than or equal to high. The high – low + 1 signed 16-bit offsets 

are treated as a 0-based jump table. Each of the signed 16-bit values is constructed 

from two unsigned bytes as (byte1 << 8) | byte2. Each of the signed 32-bit values is 

constructed from four unsigned bytes as (byte1 << 24) | (byte2 << 16) | (byte3 << 8) 

| byte4.

The index must be of type int and is popped from the stack. If index is less than low 

or index is greater than high, then a target address is calculated by adding default to 

the address of the opcode of this itableswitch instruction. Otherwise, the offset at 

position index – low of the jump table is extracted. The target address is calculated 

by adding that offset to the address of the opcode of this itableswitch instruction. 

Execution then continues at the target address.

The target addresses that can be calculated from each jump table offset, as well as 

the one calculated from default, must be the address of an opcode of an instruction 

within the method that contains this itableswitch instruction.

描述

itableswitch命令是个变长的指令,在itableswitch操作码后跟着一个有符号的16-bit默认值,一个有符号

的32-bit低值,一个有符号32-bit高值,然后high-low+1个有符号的16-bit便宜,被当作0偏移的跳转表。

每个16-bit的有符号值由4个无符号byte组成(byte1 << 24) | (byte2 << 16) | (byte3 << 8)| byte4.

index必须是int类型,从操作栈弹出。如果index小于low或者index大于high,那么目标地址就是通过itableswitch

的操作码地址+default值获得。否则,在跳转表偏移index-low的下标位置的偏移有效。目标地址通过itableswitch

的操作码地址+此偏移值获得。

目标地址可以被跳转表的每个偏移算出,和default一样,每个目标地址都必须是一个指向包含itableswitch的方法

中的一个操作码。

 

Notes

If a virtual machine does not support the int data type, the itableswitch instruction 

will not be available.

 

7.5.67 iushr

Logical shift right int

逻辑int右移

 

Format

iushr

Forms

iushr = 82 (0x52)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. An int result is calculated by shifting the result right by s bit 

positions, with zero extension, where s is the value of the low five bits of value2. The 

result is pushed onto the operand stack.

描述

value1和value2必须是int类型。values从操作栈弹出,通过比特右移得到结果,只关心value2的低5个比特。

结果压入操作栈。

 

Notes

If value1 is positive and s is value2 & 0x1f, the result is the same as that of value1 >> 

s; if value1 is negative, the result is equal to the value of the expression (value1 >> s) 

+ (2 << ~s). The addition of the (2 << ~s) term cancels out the propagated sign bit. 

The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 

were subjected to a bitwise logical AND with the mask value 0x1f.

If a virtual machine does not support the int data type, the iushr instruction will not 

be available.

注释

如果value1是正的,s私活value2 & 0x1F,那么结果等于value1>>s;如果value1是负数,结果等于value1>>s + (2<<~s).

2<<~s的加数去掉了符号位的扩展。移动范围实际上只有0到31之间,那么和value2被比特与了0x1F一致。

如果虚拟机不支持int数据类型,iushr指令无效。

 

 

7.5.68 ixor

Boolean XOR int

int的布尔异或

 

Format

ixor

Forms

ixor = 88 (0x58)

 

Stack

…, value1.word1, value1.word2, value2.word1, value2.word2 ->

…, result.word1, result.word2

 

Description

Both value1 and value2 must be of type int. The values are popped from the 

operand stack. An int result is calculated by taking the bitwise exclusive OR of 

value1 and value2. The result is pushed onto the operand stack.

value1和value2必须是int类型,值从操作栈弹出。通过value1和value2的比特级别异或得到int结果。

结果压入操作栈。

 

Notes

If a virtual machine does not support the int data type, the ixor instruction will not 

be available.

注释

如果虚拟机不支持int数据类型,ixor指令无效。

 

 

7.5.69 jsr

Jump subroutine

 

Format

jsr

branchbyte1

branchbyte2

 

Forms

jsr = 113 (0x71)

 

Stack

…->

…, address

 

Description

The address of the opcode of the instruction immediately following this jsr 

instruction is pushed onto the operand stack as a value of type returnAddress. The 

unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, 

where the offset is (branchbyte1 << 8) | branchbyte2. Execution proceeds at that 

offset from the address of this jsr instruction. The target address must be that of an 

opcode of an instruction within the method that contains this jsr instruction.

 

描述

跟随着jsr命令的下一个命令的opcode的地址作为returnAddress被压入操作栈。无符号branchbyte1

和branchbyte2用来组成一个有符号的16-bit偏移(branchbyte1 << 8) | branchbyte2.执行地址切换

到jsr命令加这个偏移的地址上。目标地址必须是包含着jsr命令方法的某个操作码。

 

Notes

The jsr instruction is used with the ret instruction in the implementation of the 

finally clause of the Java language. Note that jsr pushes the address onto the stack 

and ret gets it out of a local variable. This asymmetry is intentional.

注释

jsr命令用来和ret命令一起实现java语言的finally段。jsr把地址压入操作栈,ret把它从本地变量里面取出。这个不对称是故意的。

 

 

7.5.70 new

Create new object

 

Format

new

indexbyte1

indexbyte2

 

Forms

new = 143 (0x8f)

 

Stack

…->

…, objectref

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the 

constant pool must be of type CONSTANT_Classref (Section 6.7.1, 

“CONSTANT_Classref” on page 6-16), a reference to a class or interface type. The 

reference is resolved and must result in a class type (it must not result in an interface 

type). Memory for a new instance of that class is allocated from the heap, and the 

instance variables of the new object are initialized to their default initial values. The 

objectref, a reference to the instance, is pushed onto the operand stack.

描述

无符号indexbyte1和indexbyte2用来构建一个指向当前包常量池的下标,index = (indexbyte1 << 8) | indexbyte2。

对应下标位置必须是一个CONSTANT_Classref,指向一个类。(不能是接口)。创建一个新对象的的内存在堆里面申请,

并且实例的变量初始化成默认值。指向实例的objectref被压入操作栈。

 

Notes

The new instruction does not completely create a new instance; instance creation is 

not completed until an instance initialization method has been invoked on the 

uninitialized instance.

注释

new指令不完全创建一个新的实例,实例的创建在调用实例初始化方法之后才完成。

 

7.5.71 newarray

Create new array

创建一个新的基本类型数组

 

Format

newarray

atype

 

Forms

newarray = 144 (0x90)

 

Stack

…, count ->

…, arrayref

 

Description

The count must be of type short. It is popped off the operand stack. The count 

represents the number of elements in the array to be created.

The unsigned byte atype is a code that indicates the type of array to create. It must 

take one of the following values: 

描述

count必须是int类型,从操作栈弹出。count表示数组元素的个数。

无符号byteatype用来标识创建数组的类型。它必须是如下的值。

TABLE 7-4  Array Values

Array Type atype

T_BOOLEAN 10

T_BYTE 11

T_SHORT 12

T_INT 13

A new array whose components are of type atype, of length count, is allocated from 

the heap. A reference arrayref to this new array object is pushed onto the operand 

stack. All of the elements of the new array are initialized to the default initial value 

for its type.

一个内容为atype的数组在堆上创建出来,指向这个新数组对象的arrayref压入操作栈。新数组的所有

对象都初始化为默认值。

 

Runtime Exception

If count is less than zero, the newarray instruction throws a 

NegativeArraySizeException.

运行态异常

如果count小于0,newarray指令抛出NegativeArraySizeException。

 

Notes

If a virtual machine does not support the int data type, the value of atype may not 

be 13 (array type = T_INT).

注释

如果虚拟机不支持int数据类型,atype的值不能是13.

 

7.5.72 nop

Do nothing

毛都不做

 

Format

nop

Forms

nop = 0 (0x0)

Stack

No change

 

Description

Do nothing.

描述

什么都不做

 

 

7.5.73 pop

Pop top operand stack word

从操作栈弹出一个字

 

Format

pop

 

Forms

pop = 59 (0x3b)

 

Stack

…, word ->

Description

The top word is popped from the operand stack. The pop instruction must not be 

used unless the word contains a 16-bit data type.

操作栈顶的字弹出。pop命令只能在弹出的字是16-bit数据类型的时候使用。

 

Notes

The pop instruction operates on an untyped word, ignoring the type of data it 

contains.

描述

pop命令操作一个无符号字,忽视数据类型。

 

7.5.74 pop2

Pop top two operand stack words

弹出栈顶的两个字

 

Format

pop2

Forms

pop2 = 60 (0x3c)

 

Stack

…, word2, word1 ->

 

Description

The top two words are popped from the operand stack.

The pop2 instruction must not be used unless each of word1 and word2 is a word 

that contains a 16-bit data type or both together are the two words of a single 32-bit 

datum.

描述

同上

 

Notes

Except for restrictions preserving the integrity of 32-bit data types, the pop2 

instruction operates on an untyped word, ignoring the type of data it contains.

注释

同上

 

 

7.5.75 putfield_<t>

Set field in object

 

Format

putfield_<t>

index

Forms

putfield_a = 135 (0x87)

putfield_b = 136 (0x88)

putfield_s = 137 (0x89)

putfield_i = 138 (0x8a)

 

Stack

…, objectref, value ->

OR

…, objectref, value.word1, value.word2 ->

 

Description

The unsigned index is used as an index into the constant pool of the current package 

(Section 3.5, “Frames” on page 3-3). The constant pool item at the index must be of 

type CONSTANT_InstanceFieldref (Section 6.7.2, “CONSTANT_InstanceFieldref, 

CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref” on page 6-18), a 

reference to a class and a field token.

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class. If the field is final, it must be declared in the 

current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

value must be of a type that is assignment compatible with the field descriptor (t) 

type.

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The objectref, 

which must be of type reference, and the value are popped from the operand stack. 

If the field is of type byte or type boolean, the value is truncated to a byte. The field 

at the offset from the start of the object referenced by objectref is set to the value.

描述

无符号index用来指向当前包的常量池下标。对应位置必须是一个CONSTANT_InstanceFieldref,指向一个类和属性令牌。

objectref的类不能是一个数组。如果field是保护的,并且和当前类不在同一个包内声明,那么objectref的类

必须或者是当前类,或者是当前类的父类。如果field是final的,它必须被定义在当前类。

对象必须要符合一个类型如下:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

类型的值和类型的描述符匹配。

类实例的宽度是由属性类型决定的。objectref必须是一个引用类型,从操作栈弹出。如果属性是byte或者boolean类型,

value被截取为一个byte。对应偏移的数据被设置为这个值。

 

Runtime Exception

If objectref is null, the putfield_<t> instruction throws a NullPointerException.

运行态异常

如果objectref是空的,putfield_<t>命令抛出空指针异常。

 

Notes

In some circumstances, the putfield_<t> instruction may throw a SecurityException 

if the current context Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object referenced by objectref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the putfield_i instruction will 

not be available.

注释

如果当前上下文和objectref的上下文不同。命令有可能抛出安全异常。参见JCRE第六章。

如果虚拟机不支持int数据类型。putfield_i命令将无效。

 

 

7.5.76 putfield_<t>_this

Set field in current object

设置当前对象的属性

 

Format

putfield_<t>_this

index

 

Forms

putfield_a_this = 181 (0xb5)

putfield_b_this = 182 (0xb6)

putfield_s_this = 183 (0xb7)

putfield_i_this = 184 (0xb8)

 

Stack

…, value ->

OR

…, value.word1, value.word2 ->

Description

The currently executing method must be an instance method that was invoked using 

the invokevirtual, invokeinterface or invokespecial instruction. The local variable at 

index 0 must contain a reference objectref to the currently executing method’s this 

parameter. The unsigned index is used as an index into the constant pool of the 

current package (Section 3.5, “Frames” on page 3-3). The constant pool item at the 

index must be of type CONSTANT_InstanceFieldref (Section 6.7.2, 

“CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and 

CONSTANT_SuperMethodref” on page 6-18), a reference to a class and a field 

token.

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class. If the field is final, it must be declared in the 

current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

value must be of a type that is assignment compatible with the field descriptor (t) 

type.

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The value is 

popped from the operand stack. If the field is of type byte or type boolean, the value 

is truncated to a byte. The field at the offset from the start of the object referenced by 

objectref is set to the value.

描述

同上,objectref从临时变量0取出。

 

Runtime Exception

If objectref is null, the putfield_<t>_this instruction throws a NullPointerException.

Notes

In some circumstances, the putfield_<t>_this instruction may throw a 

SecurityException if the current context (Section 3.4, “Contexts” on page 3-2) is not 

the owning context (Section 3.4, “Contexts” on page 3-2) of the object referenced by 

objectref. The exact circumstances when the exception will be thrown are specified in 

Chapter 6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the putfield_i_this 

instruction will not be available.

 

7.5.77 putfield_<t>_w

Set field in object (wide index)

设置对象属性(宽下标)

 

Format

putfield<t>_w

indexbyte1

indexbyte2

 

Forms

putfield_a_w = 177 (0xb1)

putfield_b_w = 178 (0xb2)

putfield_s_w = 179 (0xb3)

putfield_i_w = 180 (0xb4)

 

Stack

…, objectref, value ->

OR

…, objectref, value.word1, value.word2 ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) |  indexbyte2. The constant pool item at the 

index must be of type CONSTANT_InstanceFieldref (Section 6.7.2, 

“CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and 

CONSTANT_SuperMethodref” on page 6-18), a reference to a class and a field 

token.

 

The class of objectref must not be an array. If the field is protected, and it is a 

member of a superclass of the current class, and the field is not declared in the same 

package as the current class, then the class of objectref must be either the current 

class or a subclass of the current class. If the field is final, it must be declared in the 

current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

value must be of a type that is assignment compatible with the field descriptor (t) 

type.

The width of a field in a class instance is determined by the field type specified in 

the instruction. The item is resolved, determining the field offset1. The objectref, 

which must be of type reference, and the value are popped from the operand stack. 

If the field is of type byte or type boolean, the value is truncated to a byte. The field 

at the offset from the start of the object referenced by objectref is set to the value.

描述

同上

Runtime Exception

If objectref is null, the putfield_<t>_w instruction throws a NullPointerException.

Notes

In some circumstances, the putfield_<t>_w instruction may throw a 

SecurityException if the current context (Section 3.4, “Contexts” on page 3-2) is not 

the owning context (Section 3.4, “Contexts” on page 3-2) of the object referenced by 

objectref. The exact circumstances when the exception will be thrown are specified in 

Chapter 6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the putfield_i_w instruction 

will not be available.

 

 

7.5.78 putstatic_<t>

Set static field in class

设置类的静态属性

 

Format

putstatic_<t>

indexbyte1

indexbyte2

 

Forms

putstatic_a = 127 (0x7f)

putstatic_b = 128 (0x80)

putstatic_s = 129 (0x81)

putstatic_i = 130 (0x82)

Stack

…, value ->

OR

…, value.word1, value.word2 ->

 

Description

The unsigned indexbyte1 and indexbyte2 are used to construct an index into the 

constant pool of the current package (Section 3.5, “Frames” on page 3-3), where the 

value of the index is (indexbyte1 << 8) |  indexbyte2. The constant pool item at the 

index must be of type CONSTANT_StaticFieldref (Section 6.7.3, 

“CONSTANT_StaticFieldref and CONSTANT_StaticMethodref” on page 6-19), a 

reference to a static field. If the field is final, it must be declared in the current class.

The item must resolve to a field with a type that matches t, as follows:

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

value must be of a type that is assignment compatible with the field descriptor (t) 

type.

The width of a class field is determined by the field type specified in the instruction. 

The item is resolved, determining the class field. The value is popped from the 

operand stack. If the field is of type byte or type boolean, the value is truncated to a 

byte. The field is set to the value.

描述

无符号indexbyte1和indexbyte2用来构建一个指向当前包常量池的下标,(indexbyte1 << 8) |  indexbyte2。

常量池对象对应的必须是CONSTANT_StaticFieldref,指向一个静态属性。如果属性是final的,它必须被定义在当前类。

对象属性的类型和t匹配

■ a field must be of type reference

■ b field must be of type byte or type boolean

■ s field must be of type short

■ i field must be of type int

value从操作栈弹出,如果属性是byte或者boolean,值被截为一个byte。属性设置为这个值。

 

Notes

In some circumstances, the putstatic_a instruction may throw a SecurityException if 

the current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the object being stored in the field. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the putstatic_i instruction 

will not be available.

注释

如果当前上下文和对象的上下文不同,可能会抛出安全异常。参见JCRE。

如果虚拟机不支持int数据类型,putstatic_i命令将无效。

 

 

7.5.79 ret

Return from subroutine

从子过程返回

 

Format

ret

index

Forms

ret = 114 (0x72)

Stack

No change

 

Description

The index is an unsigned byte that must be a valid index into the local variables of 

the current frame (Section 3.5, “Frames” on page 3-3). The local variable at index 

must contain a value of type returnAddress. The contents of the local variable are 

written into the Java Card virtual machine’s pc register, and execution continues 

there.

描述

index是无符号的字节指向当前栈帧的本地变量。对应位置的本地变量必须包含一个returnAddress类型的值。

这个值写入java卡虚拟机的pc寄存器,继续执行。

 

Notes

The ret instruction is used with the jsr instruction in the implementation of the 

finally keyword of the Java language. Note that jsr pushes the address onto the stack 

and ret gets it out of a local variable. This asymmetry is intentional.

The ret instruction should not be confused with the return instruction. A return 

instruction returns control from a Java method to its invoker, without passing any 

value back to the invoker.

描述

ret命令用来和jsr命令在一起实现finally关键字。jsr把地址压入栈,ret从本地变量中获得。这个不对称是故意的。

ret命令和return命令不同。return命令把控制权交给java方法的调用者,不传任何值。

 

7.5.80 return

Return void from method

从方法空返回

 

Format

return

Forms

return = 122 (0x7a)

 

Stack

… ->

[empty]

 

Description

Any values on the operand stack of the current method are discarded. The virtual 

machine then reinstates the frame of the invoker and returns control to the invoker.

当前方法的操作栈全部放弃。虚拟机回到调用者的栈帧,返回调用者的控制。

 

 

7.5.81 s2b

Convert short to byte

转化short到byte

 

Format

s2b

Forms

s2b = 91 (0x5b)

Stack

…, value ->

…, result

 

Description

The value on top of the operand stack must be of type short. It is popped from the 

top of the operand stack, truncated to a byte result, then sign-extended to a short 

result. The result is pushed onto the operand stack.

描述

操作栈顶必须是short类型。它从操作栈顶弹出,截为一个byte的结果,然后有符号扩展为short的结果。

结果压入操作栈。

 

Notes

The s2b instruction performs a narrowing primitive conversion. It may lose 

information about the overall magnitude of value. The result may also not have the 

same sign as value.

注释

s2b命令执行了一个窄型基本类型转化。它可能会丢失值的部分信息。结果也可能和值的符号不同。

 

 

7.5.82 s2i

Convert short to int

转化short到int

 

Format

s2i

Forms

s2i = 92 (0x5c)

Stack

…, value ->

…, result.word1, result.word2

 

Description

The value on top of the operand stack must be of type short. It is popped from the 

operand stack and sign-extended to an int result. The result is pushed onto the 

operand stack.

描述

操作栈顶必须是short类型数据,从操作栈弹出,有符号扩展为一个int结果,结果压入操作栈。

 

Notes

The s2i instruction performs a widening primitive conversion. Because all values of 

type short are exactly representable by type int, the conversion is exact.

If a virtual machine does not support the int data type, the s2i instruction will not be 

available.

注释

s2i命令执行了一个宽型基本类型转化。因为short的所有值都可以被int表示。转化是精确的。

如果虚拟机不支持int数据类型,s2i命令将无效。

 

 

7.5.83 sadd

Add short

short加法

 

Format

sadd

Forms

sadd = 65 (0x41)

 

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. The short result is value1 + value2. The result is pushed onto the 

operand stack.

If a sadd instruction overflows, then the result is the low-order bits of the true 

mathematical result in a sufficiently wide two’s-complement format. If overflow 

occurs, then the sign of the result may not be the same as the sign of the 

mathematical sum of the two values.

描述

同:iadd

 

7.5.84 saload

Load short from array

从数组加载short

 

Format

saload

Forms

saload = 38 (0x46)

Stack

…, arrayref, index ->

…, value

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type short. The index must be of type short. Both arrayref and index are 

popped from the operand stack. The short value in the component of the array at 

index is retrieved and pushed onto the top of the operand stack.

Runtime Exceptions

If arrayref is null, saload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

saload instruction throws an ArrayIndexOutOfBoundsException.

描述

参见baload,aaload

 

Notes

In some circumstances, the saload instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

 

7.5.85 sand

Boolean AND short

 

Format

sand

Forms

sand = 83 (0x53)

 

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 are popped from the operand stack. A short result is 

calculated by taking the bitwise AND (conjunction) of value1 and value2. The result 

is pushed onto the operand stack.

描述

参见iand

 

 

7.5.86 sastore

Store into short array

存储short到数组

 

Format 

sastore

Forms

sastore = 57 (0x39)

Stack

…, arrayref, index, value ->

 

Description

The arrayref must be of type reference and must refer to an array whose components 

are of type short. The index and value must both be of type short. The arrayref, 

index and value are popped from the operand stack. The short value is stored as the 

component of the array indexed by index.

描述

参见iastore

 

Runtime Exception

If arrayref is null, sastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the 

sastore instruction throws an ArrayIndexOutOfBoundsException.

Notes

In some circumstances, the sastore instruction may throw a SecurityException if the 

current context (Section 3.4, “Contexts” on page 3-2) is not the owning context 

(Section 3.4, “Contexts” on page 3-2) of the array referenced by arrayref. The exact 

circumstances when the exception will be thrown are specified in Chapter 6 of the 

Runtime Environment Specification, Java Card Platform, Version 2.2.2.

 

7.5.87 sconst_<s>

Push short constant

压入short常量

 

Format

sconst_<s>

Forms

sconst_m1 = 2 (0x2)

sconst_0 = 3 (0x3)

sconst_1 = 4 (0x4)

sconst_2 = 5 (0x5)

sconst_3 = 6 (0x6)

sconst_4= 7 (0x7)

sconst_5 = 8 (0x8)

Stack

…->

…, <s>

 

Description

Push the short constant <s> (-1, 0, 1, 2, 3, 4, or 5) onto the operand stack.

描述

把short常量(-1,0,1,2,3,4,5)压入操作栈。

 

7.5.88 sdiv

Divide short

short除法

 

Format

sdiv

Forms

sdiv = 71 (0x47)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. The short result is the value of the Java expression value1 / value2. 

The result is pushed onto the operand stack.

A short division rounds towards 0; that is, the quotient produced for short values in 

n/d is a short value q whose magnitude is as large as possible while satisfying | d · 

q | <= | n |. Moreover, q is a positive when | n | >= | d | and n and d have the 

same sign, but q is negative when | n | >= | d | and n and d have opposite signs.

There is one special case that does not satisfy this rule: if the dividend is the negative 

integer of the largest possible magnitude for the short type, and the divisor is –1, 

then overflow occurs, and the result is equal to the dividend. Despite the overflow, 

no exception is thrown in this case.

 

Runtime Exception

If the value of the divisor in a short division is 0, sdiv throws an 

ArithmeticException.

 

描述

参见idiv

 

7.5.89 sinc

Increment local short variable by constant

short本地变量自加

 

Format

sinc

index

const

Forms

sinc = 89 (0x59)

 

Stack

No change

 

Description

The index is an unsigned byte that must be a valid index into the local variable of 

the current frame (Section 3.5, “Frames” on page 3-3). The const is an immediate 

signed byte. The local variable at index must contain a short. The value const is first 

sign-extended to a short, then the local variable at index is incremented by that 

amount.

描述

参见iinc

 

7.5.90 sinc_w

Increment local short variable by constant

 

Format

sinc_w

index

byte1

byte2

Forms

sinc_w = 150 (0x96)

Stack

No change

 

Description

The index is an unsigned byte that must be a valid index into the local variable of 

the current frame (Section 3.5, “Frames” on page 3-3). The immediate unsigned 

byte1 and byte2 values are assembled into a short const where the value of const is 

(byte1 << 8) | byte2. The local variable at index, which must contain a short, is 

incremented by const.

描述

同上

 

7.5.91 sipush

Push short

把short扩展为int压入

 

Format

sipush

byte1

byte2

Forms

sipush = 19 (0x13)

 

Stack

…->

…, value1.word1, value1.word2

 

Description

The immediate unsigned byte1 and byte2 values are assembled into a signed short 

where the value of the short is (byte1 << 8) | byte2. The intermediate value is then 

sign-extended to an int, and the resulting value is pushed onto the operand stack.

描述

参见bipush

Notes

If a virtual machine does not support the int data type, the sipush instruction will 

not be available.

 

7.5.92 sload

Load short from local variable

从本地变量中加载short

 

Format

sload

index

 

Forms

sload = 22 (0x16)

Stack

… ->

…, value

 

Description

The index is an unsigned byte that must be a valid index into the local variables of 

the current frame (Section 3.5, “Frames” on page 3-3). The local variable at index 

must contain a short. The value in the local variable at index is pushed onto the 

operand stack.

描述

参见aload,iload

 

 

7.5.93 sload_<n>

Load short from local variable

 

Format

sload_<n>

Forms

sload_0 = 28 (0x1c)

sload_1 = 29 (0x1d)

sload_2 = 30 (0x1e)

sload_3 = 31 (0x1f)

Stack

… ->

…, value

 

Description

The <n> must be a valid index into the local variables of the current frame 

(Section 3.5, “Frames” on page 3-3). The local variable at <n> must contain a short. 

The value in the local variable at <n> is pushed onto the operand stack.

描述

参见aload_<n>,iload_<n>

 

Notes

Each of the sload_<n> instructions is the same as sload with an index of <n>, except 

that the operand <n> is implicit.

 

7.5.94 slookupswitch

Access jump table by key match and jump

关键字匹配跳转表并跳转

 

Format

slookupswitch

defaultbyte1

defaultbyte2

npairs1

npairs2

match-offset pairs…

Pair Format

matchbyte1

matchbyte2

offsetbyte1

offsetbyte2

Forms

slookupswitch = 117 (0x75)

Stack

…, key ->

 

Description

A slookupswitch instruction is a variable-length instruction. Immediately after the 

slookupswitch opcode follow a signed 16-bit value default, an unsigned 16-bit value 

npairs, and then npairs pairs. Each pair consists of a short match and a signed 16-bit 

offset. Each of the signed 16-bit values is constructed from two unsigned bytes as 

(byte1 << 8) | byte2.

The table match-offset pairs of the slookupswitch instruction must be sorted in 

increasing numerical order by match.

The key must be of type short and is popped from the operand stack and compared 

against the match values. If it is equal to one of them, then a target address is 

calculated by adding the corresponding offset to the address of the opcode of this 

slookupswitch instruction. If the key does not match any of the match values, the 

target address is calculated by adding default to the address of the opcode of this 

slookupswitch instruction. Execution then continues at the target address.

The target address that can be calculated from the offset of each match-offset pair, as 

well as the one calculated from default, must be the address of an opcode of an 

instruction within the method that contains this slookupswitch instruction.

描述

参见ilookupswitch

 

7.5.95 smul

Multiply short

short乘法

 

Format

smul

Forms

smul = 69 (0x45)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. The short result is value1 * value2. The result is pushed onto the 

operand stack.

If a smul instruction overflows, then the result is the low-order bits of the 

mathematical product as a short. If overflow occurs, then the sign of the result may 

not be the same as the sign of the mathematical product of the two values.

描述

参见imul

 

Notes

The match-offset pairs are sorted to support lookup routines that are quicker than 

linear search.

 

7.5.96 sneg

Negate short

short负数

 

Format

sneg

 

Forms

sneg = 72 (0x4b)

 

Stack

…, value ->

…, result

 

Description

The value must be of type short. It is popped from the operand stack. The short 

result is the arithmetic negation of value, -value. The result is pushed onto the 

operand stack.

For short values, negation is the same as subtraction from zero. Because the Java 

Card virtual machine uses two’s-complement representation for integers and the 

range of two’s-complement values is not symmetric, the negation of the maximum 

negative short results in that same maximum negative number. Despite the fact that 

overflow has occurred, no exception is thrown.

For all short values x, -x equals (~x) + 1.

描述

参见ineg

 

7.5.97 sor

Boolean OR short

short布尔或

 

Format

sor

Forms

sor = 85 (0x55)

 

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. A short result is calculated by taking the bitwise inclusive OR of 

value1 and value2. The result is pushed onto the operand stack.

描述

参见ior

 

7.5.98 srem

Remainder short

short求余

 

Format

srem

 

Forms

srem = 73 (0x49)

 

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. The short result is the value of the Java expression value1 – (value1 / 

value2) * value2. The result is pushed onto the operand stack.

The result of the irem instruction is such that (a/b)*b + (a%b) is equal to a. This 

identity holds even in the special case that the dividend is the negative short of 

largest possible magnitude for its type and the divisor is –1 (the remainder is 0). It 

follows from this rule that the result of the remainder operation can be negative only 

if the dividend is negative and can be positive only if the dividend is positive. 

Moreover, the magnitude of the result is always less than the magnitude of the 

divisor.

描述

参见irem

 

Runtime Exception

If the value of the divisor for a short remainder operator is 0, srem throws an 

ArithmeticException.

 

7.5.99 sreturn

Return short from method

方法返回short

 

Format

sreturn

Forms

sreturn = 120 (0x78)

Stack

…, value ->

[empty]

 

Description

The value must be of type short. It is popped from the operand stack of the current 

frame (Section 3.5, “Frames” on page 3-3) and pushed onto the operand stack of the 

frame of the invoker. Any other values on the operand stack of the current method 

are discarded.

The virtual machine then reinstates the frame of the invoker and returns control to 

the invoker.

描述

参见areturn,ireturn

 

7.5.100 sshl

Shift left short

short左移

 

Format

sshl

Forms

sshl = 77 (0x4d)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. A short result is calculated by shifting value1 left by s bit positions, 

where s is the value of the low five bits of value2. The result is pushed onto the 

operand stack.

描述

参见ishl

 

Notes

This is equivalent (even if overflow occurs) to multiplication by 2 to the power s. 

The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 

were subjected to a bitwise logical AND with the mask value 0x1f.

The mask value of 0x1f allows shifting beyond the range of a 16-bit short value. It is 

used by this instruction, however, to ensure results equal to those generated by the 

Java instruction ishl.

 

7.5.101 sshr

Arithmetic shift right short

 

Format

sshr

Forms

sshr = 79 (0x4f)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. A short result is calculated by shifting value1 right by s bit positions, 

with sign extension, where s is the value of the low five bits of value2. The result is 

pushed onto the operand stack.

描述

参见ishr

 

Notes

The resulting value is ?(value1) / 2s°, where s is value2 & 0x1f. For nonnegative 

value1, this is equivalent (even if overflow occurs) to truncating short division by 2 

to the power s. The shift distance actually used is always in the range 0 to 31, 

inclusive, as if value2 were subjected to a bitwise logical AND with the mask value 

0x1f.

The mask value of 0x1f allows shifting beyond the range of a 16-bit short value. It is 

used by this instruction, however, to ensure results equal to those generated by the 

Java instruction ishr.

 

7.5.102 sspush

Push short

压入short

 

Format

sspush

byte1

byte2

Forms

sspush = 17 (0x11)

 

Stack

…->

…, value

 

Description

The immediate unsigned byte1 and byte2 values are assembled into a signed short 

where the value of the short is (byte1 << 8) | byte2. The resulting value is pushed 

onto the operand stack.

描述

参考bipush,bspush,iipush

 

7.5.103 sstore

Store short into local variable

把short存入本地变量

 

Format

sstore

index

Forms

sstore = 41 (0x29)

Stack

…, value ->

 

Description

The index is an unsigned byte that must be a valid index into the local variables of 

the current frame (Section 3.5, “Frames” on page 3-3). The value on top of the 

operand stack must be of type short. It is popped from the operand stack, and the 

value of the local variable at index is set to value.

描述

参考astore,istore

 

7.5.104 sstore_<n>

Store short into local variable

存储short到本地变量

 

Format

sstore_<n>

Forms

sstore_0 = 47 (0x2f)

sstore_1 = 48 (0x30)

sstore_2 = 49 (0x31)

sstore_3 = 50 (0x32)

Stack

…, value ->

 

Description

The <n> must be a valid index into the local variables of the current frame 

(Section 3.5, “Frames” on page 3-3). The value on top of the operand stack must be 

of type short. It is popped from the operand stack, and the value of the local variable 

at <n> is set to value.

描述

参见astore_<n>,istore_<n>

 

7.5.105 ssub

Subtract short

 

Format

ssub

Forms

ssub = 67 (0x43)

 

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. The short result is value1 - value2. The result is pushed onto the 

operand stack.

For short subtraction, a – b produces the same result as a + (–b). For short values, 

subtraction from zeros is the same as negation.

Despite the fact that overflow or underflow may occur, in which case the result may 

have a different sign than the true mathematical result, execution of a ssub 

instruction never throws a runtime exception.

描述

参见isub

 

 

7.5.106 stableswitch

Access jump table by short index and jump

访问跳转表,通过短索引和跳转

 

Format

stableswitch

defaultbyte1

defaultbyte2

lowbyte1

lowbyte2

highbyte1

highbyte2

jump offsets…

Offset Format

offsetbyte1

offsetbyte2

Forms

stableswitch = 115 (0x73)

 

Stack

…, index ->

 

Description

A stableswitch instruction is a variable-length instruction. Immediately after the 

stableswitch opcode follow a signed 16-bit value default, a signed 16-bit value low, a 

signed 16-bit value high, and then high – low + 1 further signed 16-bit offsets. The 

value low must be less than or equal to high. The high – low + 1 signed 16-bit offsets 

are treated as a 0-based jump table. Each of the signed 16-bit values is constructed 

from two unsigned bytes as (byte1 << 8) | byte2.

The index must be of type short and is popped from the stack. If index is less than 

low or index is greater than high, than a target address is calculated by adding 

default to the address of the opcode of this stableswitch instruction. Otherwise, the 

offset at position index – low of the jump table is extracted. The target address is 

calculated by adding that offset to the address of the opcode of this stableswitch 

instruction. Execution then continues at the target address.

The target addresses that can be calculated from each jump table offset, as well as 

the one calculated from default, must be the address of an opcode of an instruction 

within the method that contains this stableswitch instruction.

描述

参见itableswitch

 

7.5.107 sushr

Logical shift right short

short类型逻辑右移

 

Format

sushr

Forms

sushr = 81 (0x51)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. A short result is calculated by sign-extending value1 to 32 bits1 and 

shifting the result right by s bit positions, with zero extension, where s is the value 

of the low five bits of value2. The resulting value is then truncated to a 16-bit result. 

The result is pushed onto the operand stack.

描述

参见iushr

 

Notes

If value1 is positive and s is value2 & 0x1f, the result is the same as that of value1 >> 

s; if value1 is negative, the result is equal to the value of the expression (value1 >> s) 

+ (2 << ~s). The addition of the (2 << ~s) term cancels out the propagated sign bit. 

The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 

were subjected to a bitwise logical AND with the mask value 0x1f.

The mask value of 0x1f allows shifting beyond the range of a 16-bit short value. It is 

used by this instruction, however, to ensure results equal to those generated by the 

Java instruction iushr.

 

7.5.108 swap_x

Swap top two operand stack words

把操作栈顶的两个字节互换

 

Format

swap_x

mn

Forms

swap_x = 64 (0x40)

Stack

…, wordM+N, …, wordM+1, wordM, …, word1 ->

…, wordM, …, word1, wordM+N, …, wordM+1

 

Description

The unsigned byte mn is used to construct two parameter values. The high nibble, 

(mn & 0xf0) >> 4, is used as the value m. The low nibble, (mn & 0xf), is used as the 

value n. Permissible values for both m and n are 1 and 2.

The top m words on the operand stack are swapped with the n words immediately 

below.

The swap_x instruction must not be used unless the ranges of words 1 through m 

and words m+1 through n each contain either a 16-bit data type, two 16-bit data 

types, a 32-bit data type, a 16-bit data type and a 32-bit data type (in either order), or 

two 32-bit data types.

描述

无符号字节mn用来构建两个参数。高半字节(mn & 0xf0) >> 4,是m。低半字节(mn & 0xf),是n。

m和n允许的值是1和2.操作栈顶的m个字和下边的n个字交换。

swap_x指令只能在字1到m,字m+1到n每个都包含了或者一个16-bit数据,2个16-bit数据,或者一个32bit数据,1个16-bit数据1个32-bit数据,

或者2个32-bit数据。

 

Notes

Except for restrictions preserving the integrity of 32-bit data types, the swap_x 

instruction operates on untyped words, ignoring the types of data they contain.

If a virtual machine does not support the int data type, the only permissible value 

for both m and n is 1.

描述

除了为了处理32-bit的数据类型,swap_x命令操作无符号字,忽视数据类型。

如果虚拟机不支持int数据类型,m和n允许的值只能是1.

 

7.5.109 sxor

Boolean XOR short

short布尔XOR

 

Format

sxor

Forms

sxor = 87 (0x57)

Stack

…, value1, value2 ->

…, result

 

Description

Both value1 and value2 must be of type short. The values are popped from the 

operand stack. A short result is calculated by taking the bitwise exclusive OR of 

value1 and value2. The result is pushed onto the operand stack.

描述

参考ixor

原创粉丝点击