CS 453 Programming Assignment #3 — MeggyJava for Pictures

Due Wednesday March 2nd (by 11:59pm)


This assignment is to be done with your CS 453 programming partner. In this assignment you will be writing a program that parses the PA3 subset of the MeggyJava language that enables any number of pixels to be set with Meggy.setPixel() and can include constant expressions using addition, subtract, multiplication, and byte casts as parameters to the Meggy.setPixel() function calls. You will

The Assignment

You should create a jar file, MJPA3.jar, that can be executed as follows:
   java -jar MJPA3_groupname.jar InputFile.java

The input files can be any PA3 MeggyJava program. The PA3Picture.java example you wrote for PA2 is a possible test case for MJPA3_groupname.jar. The output file named InputFile.java.s should be an AVR assembly program that using the provided build process will run on the MeggyJr device. Additionally, the InputFile.java.s file must be such that we can run it through the AVR simulator MJSIM.jar. See the Meggy Sim instructions for usage notes. The set of instructions you will need include those already provided in the avrH.rtl.s and avrF.rtl.s files and the following:

        # Examples of each statement type are provided.
        # Register numbers, constant values, and labels can change.
        ldi    r24,lo8(1)
        ldi    r24,73
        push   r24
        pop    r24
        call   functionName
For more details about the instructions see the 08-MeggyJrSimple-n-AVR.txt notes.

Notice that avrF.rtl.s already has an infinite loop at the end of main so that the program will always remain running on the Meggy Jr device even if there is no while loop in the MeggyJava program.

For this assignment, no error handling is necessary. In other words, you can assume the input is correct.

Getting Started

Create the following directory structure and organize the provided files: java-cup-11a.jar, java-cup-11a-runtime.jar, Makefile, avrF.rtl.s, and avrH.rtl.s as shown. The java_cup subdirectory is needed for the way we are building the MJPA3.jar file in the Makefile. You can create a java_cup subdirectory by doing a "jar xf java-cup-11a-runtime.jar" command. For the mj.lex and mj.cup files, start with the 15min.lex and 15min.cup examples and then attend recitation to hear about some modifications that are necessary if you want to create the lexer from a driver other than the parser. The MJPA3Driver.java will be provided in recitation.


The Makefile will create a .jar file provided you use the suggested directory structure. You can use any directory structure and any build process as long as your MJPA3_groupname.jar file works as required.

Remember that we suggest you start from example .lex and .cup files that already work. We also recommend that you start out with a small driver that builds into a jar file and does something right away. Incrementally add functionality and test along the way.

Submitting the Assignment

Late Policy

Late assignments will be accepted up to 48 hours past the due date for a 10% deduction. The assignment will not be accepted past this period. Late means anything after 11:59pm on the day the assignment is due, including 12 midnight.

mstrout@cs.colostate.edu .... March 2, 2011