Contents Prev Next Up


The Virtual Machine Instruction Set


Arithmetic Instructions

iadd
ladd
fadd
dadd
isub
lsub
fsub
dsub
imul
lmul
fmul
dmul
idiv
ldiv
fdiv
ddiv
imod
lmod
fmod
dmod
ineg
lneg
fneg
dneg

iadd

Integer add

..., value1, value2 => ..., result

value1 and value2 should be integers. The values are added and are replaced on the stack by their integer sum.

ladd

Long integer add

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be long integers. The values are added and are replaced on the stack by their long integer sum.

fadd

Single float add

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. The values are added and are replaced on the stack by their single precision floating point sum.

dadd

Double float add

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be double precision floating point numbers. The values are added and are replaced on the stack by their double precision floating point sum.

isub

Integer subtract

..., value1, value2 => ..., result

value1 and value2 should be integers. value2 is subtracted from value1, and both values are replaced on the stack by their integer difference.

lsub

Long integer subtract

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be long integers. value2 is subtracted from value1, and both values are replaced on the stack by their long integer difference.

fsub

Single float subtract

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. value2 is subtracted from value1, and both values are replaced on the stack by their single precision floating point difference.

dsub

Double float subtract

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be double precision floating point numbers. value2 is subtracted from value1, and both values are replaced on the stack by their double precision floating point difference.

imul

Integer multiply

..., value1, value2 => ..., result

value1 and value2 should be integers. Both values are replaced on the stack by their integer product.

lmul

Long integer multiply

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be long integers. Both values are replaced on the stack by their long integer product.

fmul

Single float multiply

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. Both values are replaced on the stack by their single precision floating point product.

dmul

Double float multiply

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be double precision floating point numbers. Both values are replaced on the stack by their double precision floating point product.

idiv

Integer divide

..., value1, value2 => ..., result

value1 and value2 should be integers. value1 is divided by value2, and both values are replaced on the stack by their integer quotient.

The result is truncated to the nearest integer that is between it and 0. An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

ldiv

Long integer divide

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be long integers. value1 is divided by value2, and both values are replaced on the stack by their long integer quotient.

The result is truncated to the nearest integer that is between it and 0. An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

fdiv

Single float divide

..., value1, value2 => ..., result

value1 and value2 should be single precision floating point numbers. value1 is divided by value2, and both values are replaced on the stack by their single precision floating point quotient.

Divide by zero results in the quotient being NaN.

ddiv

Double float divide

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should be double precision floating point numbers. value1 is divided by value2, and both values are replaced on the stack by their double precision floating point quotient.

Divide by zero results in the quotient being NaN.

imod

Integer mod

..., value1, value2 => ..., result

value1 and value2 should both be integers. value1 is divided by value2, and both values are replaced on the stack by their integer remainder.

An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

lmod

Long integer mod

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should both be long integers. value1 is divided by value2, and both values are replaced on the stack by their long integer remainder.

An attempt to divide by zero results in a "/ by zero" ArithmeticException being thrown.

fmod

Single float mod

..., value1, value2 => ..., result

value1 and value2 should both be single precision floating point numbers. value1 is divided by value2, and the quotient is truncated to an integer, and then multiplied by value2. The product is subtracted from value1.The result, as a single precision floating point number, replaces both values on the stack. That is, result = value1 - ((int)(value1/value2)) * value2.

An attempt to divide by zero results in NaN.

dmod

Double float mod

..., value1-word1, value1-word2, value2-word1, value2-word2 => ..., result-word1, result-word2

value1 and value2 should both be double precision floating point numbers. value1 is divided by value2, and the quotient is truncated to an integer, and then multiplied by value2. The product is subtracted from value1.The result, as a double precision floating point number, replaces both values on the stack. That is, result = value1 - ((int)(value1/value2)) * value2.

An attempt to divide by zero results in NaN.

ineg

Integer negate

..., value => ..., result

value should be an integer. It is replaced on the stack by its arithmetic negation.

lneg

Long integer

negate

..., value-word1, value-word2 => ..., result-word1, result-word2

value should be a long integer. It is replaced on the stack by its arithmetic negation.

fneg

Single float negate

..., value => ..., result

value should be a single precision floating point number. It is replaced on the stack by its arithmetic negation.

dneg

Double float negate

..., value-word1, value-word2 => ..., result-word1, result-word2

value should be a double precision floating point number. It is replaced on the stack by its arithmetic negation.


Contents Prev Next Up

Generated with CERN WebMaker