∟What Is JASM

This section provides a quick introduction on JASM as a JVM assembler/disassembler tool with a tutorial on how to write a JASM assembly program, compile it into bytecode file and run it on JVM.

What Is JASM? JASM is an assembler/disassembler for JVM bytecode developed by Ross Bamford. Main features of JASM are:

Here is what I did to download and install JASM on my home computer.

1. Go to github.com/roscopeco/jasm/releases.

2. Download the jasm-0.7.0.zip (Sep 17, 2022) file.

3. Unzip jasm-0.7.0.zip You will see the bin/jasm command in the jasm-0.7.0 sub-directory.

Now let's try to create a JASM program, compile and run it:

1. Copy the assembly example program from JASM README page, remove the package name com/example/ and save it in a file called HelloWorld.jasm.

public class HelloWorld {
  public static main([java/lang/String)V {
    getstatic java/lang/System.out java/io/PrintStream
    ldc "Hello, World"
    invokevirtual java/io/PrintStream.println(java/lang/String)V
    return
  }
}

2. Compile HelloWorld.jasm into HelloWorld.class with the JASM compiler.

herong> ./jasm-0.7.0/bin/jasm HelloWorld.jasm

herong> ls -l
  -rw-r--r--  1 herong  staff       353 Nov 11 09:47 HelloWorld.class
  -rw-r--r--@ 1 herong  staff       248 Nov 11 09:20 HelloWorld.jasm

3. Run HelloWorld.class on JVM.

herong> java HelloWorld

Hello, World

Cool, it works!

Table of Contents

 About This Book

 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 Runtime Data Areas

 JVM Stack, Frame and Stack Overflow

 Thread Testing Program and Result

 CPU Impact of Multi-Thread Applications

 I/O Impact of Multi-Thread Applications

 CDS (Class Data Sharing)

 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

 OpenJ9 by Eclipse Foundation

 JRockit JVM 28.2.7 by Oracle Corporation

 JVM Bytecode and Instruction Set

►JVM Assembler/Disassembler Tools

 What Is JVM Assembler

 What Is Jasmin

 Compare HelloWorld.j with "javap" Output

 Jasmin Assembly Statements

 Jasmin Example - Empty.j

 Jasmin Example - Calculator.j

►What Is JASM

 JASM Assembly Statements

 JASM Example - Calculator.jasm

 JASM Disassembler: "jasm -d"

 What Is AsmTools

 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"

 What Is Lilac

 Lilac Assembly Statements

 Lilac Macro Example - HelloWorldMacro.jasm

 Lilac Disassembler: "jdasm"

 Archived Tutorials

 References

 Index

 Full Version in PDF/EPUB