Comparing bytecode assembler with binary formats
Bytecode machines tend to use simpler formats than native code, where binary object files are the norm. Some bytecode machines, such as Python, hide their bytecode format entirely or make it optional. Others, such as Unicon, use a human-readable assembler-like text format for compiled modules. In the case of Java, they seem to have gone out of their way to avoid providing an assembler, to make it more difficult for other languages to generate code for the Java virtual machine (VM).
In the case of Jzero and its machine, space limits motivate us to keep things as simple as possible. The byc
class defines two output methods: print()
for human-friendly text format and printb()
for machine-friendly binary format. You can decide for yourself which one you prefer for any given application.
Printing bytecode in assembler format
The print()
method in the byc
class is similar to the one used in the tac
class. One line of output is...