Jasmin statements are comments, directives, and instructions:
STATEMENT ::= COMMENT | DIRECTIVE | INSTRUCTION
Comments begin with a semi-colon. The assembler ignores everything between the semi-colon and the next end of line:
; this is a comment
Directives begin with a period and are executed by the assembler rather than the JVM.
For example, suppose the file Car.java contains the following class declaration:
public class Car extends Vehicle implements Carrier {
private double speed;
public void start() {
// etc.
}
}
A compiler that translated Java to Jasmin would translate Car.java into a file called Car.j that looked like this:
.class public Car ;
public class Car
.super Vehicle ; extends
Vehicle
.implements Carrier ; implements
Carrier
.field private speed D ; private
double speed;
.method public start()V ; public void
start() {
.limit stack 4 ; start
requires a 4 word stack
.limit locals 2 ; start
requires space for 2 locals
; instruction go here
.end ; } // end of
start
The typical format of a Jasmin instruction is:
LABEL: OPERATOR OPERAND(S) ; COMMENT
Labels are needed if the instruction will be the target of a goto instruction. Otherwise they are optional. The operator (iadd for example) is also called the mnemonic. Some operators require inputs, which are called operands, arguments, or parameters. Comments are optional. Don't under-use or over-use them.
A complete list of Jasmin instructions can be found at:
http://jasmin.sourceforge.net/instructions.html
Instructions are executed by the JVM and can roughly be grouped into four categories: