JVM Tutorials - Herong's Tutorial Examples - v5.14, by Herong Yang
What Is Jasmin
This section provides a quick introduction on Jasmin as a JVM assembler tool with a tutorial on how to write a Jasmin assembly program, compile it into bytecode file and run it on JVM.
What Is Jasmin? Jasmin is a JVM assembler developed in 1996 by Jonathan Meyer, who wrote the book "Java Virtual Machine" with Troy Downing. It is considered as the oldest and original JVM assembler. Main features of Jasmin are:
Here is what I did to download and install Jasmin assembler on my home computer.
1. Go to sourceforge.net/projects/jasmin/
2. Click "Files > jasmin > jasmin-2.4" to open the download folder.
3. Download the jasmin-2.4.zip (2010-05-07) file.
4. Unzip jasmin-2.4.zip. You will see the jasmin.jar file with user guide and examples in the sub-directory ./jasmin-2.4.
Now let's try to create a Jasmin program, compile and run it:
1. Copy the assembly example program from Jasmin user guide, remove comments and save it in a file called HelloWorld.j.
.class public HelloWorld .super java/lang/Object .method public <init>()V aload_0 invokenonvirtual java/lang/Object/<init>()V return .end method .method public static main([Ljava/lang/String;)V .limit stack 2 getstatic java/lang/System/out Ljava/io/PrintStream; ldc "Hello World!" invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V return .end method
2. Compile HelloWorld.j into HelloWorld.class with Jasmin compiler provided in jasmin.jar.
herong> java -jar jasmin-2.4/jasmin.jar HelloWorld.j Generated: HelloWorld.class herong> ls -l -rw-r--r-- 1 herong staff 377 Nov 4 10:10 HelloWorld.class -rw-r--r-- 1 herong staff 380 Nov 4 09:14 HelloWorld.j
3. Run HelloWorld.class on JVM.
herong> java HelloWorld Hello World!
Cool, it works!
Table of Contents
JVM (Java Virtual Machine) Specification
Java HotSpot VM - JVM by Oracle/Sun
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
JVM Stack, Frame and Stack Overflow
Thread Testing Program and Result
CPU Impact of Multi-Thread Applications
I/O Impact of Multi-Thread Applications
Micro Benchmark Runner and JVM Options
Micro Benchmark Tests on "int" Operations
Micro Benchmark Tests on "long" Operations
Micro Benchmark Tests in JIT Compilation Mode
Micro Benchmark Tests on "float" and "double" Operations
JRockit JVM 28.2.7 by Oracle Corporation
JVM Bytecode and Instruction Set
►JVM Assembler/Disassembler Tools
Compare HelloWorld.j with "javap" Output
JASM Example - Calculator.jasm
AsmTools/JASM Assembly Statements
AsmTools/JASM Example - Calculator.jasm
AsmTools/JASM Disassembler: "jdis"
AsmTools/JCOD Assembly File Format
AsmTools/JCOD Example - HelloWorld.jcod
AsmTools/JCOD Disassembler: "jdec"