Important Note:Depending on your machine and OS, you may need to make modifications, such as pathnames, to these instructions. Learning how to customize to your environment is a good skill for your future. Share any modifications with the class on piazza, and we will update these instructions or add to them.
Follow these steps:
java -jar MJ_PA2.jar PA2bluedot.java java -jar MJ_PA5.jar PA5movedot.java
tar -xf testlib.tarAfter doing this you should have a directory called meggy/.
javac PA2bluedot.java
java PA2bluedotYou should get back a message:
Setting pixel (1,2) to BLUE
In order to have MeggyJava programs run on the Meggy Jr. device they must be compiled into AVR assembly; this is the goal of your future programming assignments. We provide a few sample .s files and you will be creating additional ones as test cases for PA1.
You have two ways to translate a MeggyJava program to AVR assembly: (1) use the reference compiler (MJ.jar) which is for your convenience in testing your own work and for grading, or (2) use your own compiler that you will be creating this semester. This document describes how to use the reference compiler. To get started on the MeggyJr device without using the MeggyJava compilers, you can run existing C++ programs on the MeggyJr.To use the reference compiler to compile a MeggyJava program down to AVR assembly, Download the reference compiler MJ.jar and place where you will be executing MeggyJava programs with the reference compiler. The reference compiler compiles MeggyJava code to AVR assembly, which is what your compilers will be doing as well. It can be helpful to use the reference compiler on your test cases to see what code it generates.
To try out the reference compiler, first download the example input PA5Cylon.java. Then do the following:
java -jar MJ.jar PA5Cylon.javaThis will generate a PA5Cylon.java.s file, which you can then compile and upload to the Meggy Jr using the above provided Makefile, or run on the MJSIM simulator.
In PA2 and onward you will be compiling .java source-files and outputting .s assembly language files. To assemble and run your .s files you will use a Makefile that can translate .s files to .hex, then transfer .hex files onto the Meggy Jr. device itself.
AVR assembly for MeggyJava programs can be executed in one of three ways: (1) through the commandline line mode of the MeggyJava simulator, (2) through the GUI of the MeggyJava simulator, and (3) on the device itself. To run PA2bluedot and PA5movedot through the simulator:
java -jar MJSIM.jar --batch --file PA2bluedot.java.sYou should get back the same message you did when running PA2bluedot.java through java.
Setting pixel (1,2) to BLUEThis technique of comparing the output with java to the output of the simulator is one way of testing the code generator for your MeggyJava compiler.
java -jar MJSIM.jar
In PA2 and onward, you will be compiling .java source-files and outputting .s assembly language files. To assemble and run your .s files, you will use a Makefile that can translate .s files to .hex, then transfer .hex files onto the Meggy Jr. device itself.