Site Tools

Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:3.10.1_types_and_the_java_card_virtual_machine

3.10.1 Types and the Java Card Virtual Machine

The Java Card virtual machine supports only a subset of the types supported by the Java virtual machine. This subset is described in Chapter 2. Type support is reflected in the instruction set, as instructions encode the data types on which they operate.

Given that the Java Card virtual machine supports fewer types than the Java virtual machine, there is an opportunity for better support for smaller data types. Lack of support for large numeric data types frees up space in the instruction set. This extra instruction space has been used to directly support arithmetic operations on the short data type.

Some of the extra instruction space has also been used to optimize common operations. Type information is directly encoded in field access instructions, rather than being obtained from an entry in the constant pool.

TABLE 3-1 summarizes the type support in the instruction set of the Java Card virtual machine. Only instructions that exist for multiple types are listed. Wide and composite forms of instructions are not listed either. A specific instruction, with type information, is built by replacing the T in the instruction template in the opcode column by the letter representing the type in the type column. If the type column for some instruction is blank, then no instruction exists supporting that operation on that type. For instance, there is a load instruction for type short, sload, but there is no load instruction for type byte.

opcode

byte

short

int

reference

Tspush

bspush

sspush

Tipush

bipush

sipush

iipush

Tconst

sconst

iconst

aconst

Tload

sload

iload

aload

Tstore

sstore

istore

astore

Tinc

sinc

iinc

Taload

baload

saload

iaload

aaload

Tastore

bastore

sastore

iastore

aastore

Tadd

sadd

iadd

Tsub

ssub

isub

Tmul

smul

imul

Tdiv

sdiv

idiv

Trem

srem

irem

Tneg

sneg

ineg

Tshl

sshl

ishl

Tshr

sshr

ishr

Tushr

sushr

iushr

Tand

sand

iand

Tor

sor

ior

Txor

sxor

ixor

s2T

s2b

s2i

i2T

i2b

i2s

Tcmp

icmp

if_TcmpOP

if_scmpOP

if_acmpOP

Tlookupswitch

slookupswitch

ilookupswitch

Ttableswitch

stableswitch

itableswitch

Treturn

sreturn

ireturn

areturn

getstatic_T

getstatic_b

getstatic_s

getstatic_i

getstatic_a

putstatic_T

putstatic_b

putstatic_s

putstatic_i

putstatic_a

getfield_T

getfield_b

getfield_s

getfield_i

getfield_a

putfield_T

putfield_b

putfield_s

putfield_i

putfield_a

The mapping between Java storage types and Java Card virtual machine computational types is summarized in TABLE 3-2.

Java (Storage) Type

Size in Bits

Computational Type

byte

8

short

short

16

short

int

32

int

Chapter 7 describes the Java Card virtual machine instruction set in detail.

Copyright © 2005, Sun Microsystems, Inc. All Rights Reserved.

javacard/jcvm/3.10.1_types_and_the_java_card_virtual_machine.txt · Last modified: 2017/05/13 04:10 (external edit)