Integer Java Virtual Machine emulator

Home
Users's guides
Assembly
Download


The main method

An IJVM program must have a main method to be executed, other methods (or the main itself) could be called from it.
The main method must be declared as follows:

.main

Without any parameter... obviously.
And it must be closed by the following directive

.end-main

Declaring a method

The following directive must be used to declare a method:

.method name(par1, par2....)

Where name is the method's name, and par1, par2 .... are formal parameters.
Each method must be closed by the following directive:

.end-method

Local Variables

Local variables could be declared as follows:

.var
var1
var2
.end-var

The .var directive must be the first line of the method.

Global Constants

emIJVM uses a default global constant: objref (the value is 0).
It is possible to declare other global constants as follows:

.constant
constName1 value
constName2 value

.end-constant

Comments

It is possible to insert comments, you just need to type "//" before the text

What is ignored

The assembler will ignore spaces, tabs and empty instrunctions.

Examble

.constant
c1 100
c2 152
.end-constant
.main
.var
var1
var2
.end-var
BIPUSH 10
ISTORE var1
BIPUSH 15 //This is a comment
ISTORE var2
LDCW objref
ILOAD var1
ILOAD var2
INVOKEVIRTUAL met
.end-method

.method met(p1, p2)//This is another comment
ILOAD p1
ILOAD p2
IADD
LDCW c1
IADD
IRETURN
.end-method
.