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 target their virtual machine (VM).
In the case of Jzero and its machine, we have strong incentives to keep things as simple as possible. The byc
class defines two output methods: print()
for text format and printb()
for binary format. You can decide for yourself which one you prefer.
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 produced for each element in the list. The Unicon implementation of the print...