Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would also recommend ASM, but have a look at <a href="http://jasmin.sourceforge.net/" rel="noreferrer">Jasmin</a>, I used it (or: had to use it) for an university-project, and it works quite well, I wrote a lexer/parse/analyzer/optimizer/generator combination for a programing-language using java and jasmin, so generating JVM Code. I uploaded the code <a href="http://www.dbruhn.de/compilerpraktikum" rel="noreferrer">here</a>, the interesting part should be the <a href="http://www.dbruhn.de/compilerpraktikum/src/edu/kit/compilerpraktikum/" rel="noreferrer">source-code itself</a>. In the folder "bytecode/InsanelyFastByteCodeCreator.java" you find a pice of code which transforms an AST Tree into the input format of jasmin assembler. Is quite straight forward.</p> <p>The source-language (which was tranformed to the AST by Lexer+Parser+Analyzer) is a subset of Java called MiniJava. It lacks some "complicated" features like Inheritance, Constructors, static methods, private fields/methods. None of those features are difficult to implement, but there was another task to write an X86 backend (so to generate machine-assembler), and those things tend to get difficult if you got no JVM which handles some things.</p> <p><em>In case you wonder about the strange Class name: The task of the university project was to transform the AST into a a <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Static_single_assignment_form" rel="noreferrer">SSA</a> Graph (so a graph representing the input code), then optimize the graph and then turn the graph into java byte code. That was about 3/4 of the work of the project and the InsanlyFastByteCodeCreator was just a short-cut to test everything.</em></p> <p>Have a look at the "Java Virtual Machine" book from Jon Meyer and Troy Downing. This book heavily references the Jasmin-Assembler, it's quite helpful for understanding the JVM internals.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload