0

I'm enrolled in a compilers course, using the "dragon book" as textbook. It gives instructions on how to convert the intermediate code generated by its compiler to an object language, assembly.

My question is: where can I find instructions to convert an intermediate code in the 3-address format to java bytecode, for the same grammar used in the book?

Textbook site: http://dragonbook.stanford.edu/index.html#courses

  • Unless you must invent your own, you could target [Jasmin](http://sourceforge.net/projects/jasmin/). – Elliott Frisch Dec 06 '15 at 20:35
  • It is not necesary to invent one, but I think Jasmin converts Java source code to bytecode. But the language studied on dragon book is not java. At the end of page (http://dragonbook.stanford.edu/), if you download the source code, the readme file describes the grammar used in the language. –  Dec 06 '15 at 20:48
  • Jasmin converts an *assembly language* to bytecode. Not Java source code. – Elliott Frisch Dec 06 '15 at 20:49

2 Answers2

1

If you want to know how to create a binary Java classfile yourself, there's no better resource than the official JVM specification.

If you want to write a classfile in a human readable textual format, there are various assemblers available: Krakatau, Jasmin, and Lilac among others. Note that Jasmin is old and largely unmaintained, though the Sable Research Group maintains a fork of it for use with their own tools.

Antimony
  • 37,781
  • 10
  • 100
  • 107
0

I have implemented a translator that takes the three-address intermediate code, generated by the Dragon Book implementation of the front end of a compiler, and converts it to a Java bytecodes with a syntax similar to Jasmin. Then it uses Krakatau to assemble it into a classfile executable through the JVM.

You can check my implementation at https://github.com/joaofbsm/smallL/tree/master/code/translator.

joaofbsm
  • 625
  • 5
  • 13