CS 453 Programming Assignment #3 — MeggyJava for Pictures
Due Thursday March 8 (by 11:59pm)
Introduction
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, negation (unary minus), and byte casts as
parameters to the Meggy.setPixel() function calls.
You will
- use your lexer from PA2,
- build the parser with JavaCUP,
- perform syntax-directed evaluation of constant integer and byte expressions,
- perform syntax directed code generation to AVR assembly code for Meggy.setPixel() statements,
- add to the regression testing framework.
- add a test to ensure that the name of the main class matches the program's filename.
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 PA1 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. See
the Meggy Sim instructions for usage notes.
Assembly (.s) programs have a prolog and epilog. Files for these are provided
in avrH.rtl.s and avrF.rtl.s.
The set of instructions you will need include those 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
Execute MJSIM.jar for a list of available instructions.
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
Download and untar PA3Empty.tar. Study the file
structure. The java_cup subdirectory is needed for the way
we are building the MJPA3.jar file in the Makefile.
The Makefile will build your parser and create a .jar file.
Submitting the Assignment
-
Make sure you test your implementation thoroughly.
-
Only turnin one assignment per group.
- Create a MJPA3_groupname.tar file that contains all source code, your .cup and .lex files,
a README file, a subversion.txt file, and your regression testing system. We should be able to run Make to produce a jar file for your PA3 MeggyJava compiler.
-
Your obligatory README file should include your groupname, usernames, email addresses,
and any information you want the TA to have before grading your assignment (
e.g., this part is not working due to..., any assumptions you had to make due to ambiguity
in the specification, etc).
-
The subversion.txt file should include output from the following:
svn log
svn info
-
Submit assignment using checkin utility.
~cs453/bin/checkin PA3 MJPA3_groupname.tar
-
Sanity Check (procedure TA will use to grade your assignment):
tar -xf MJPA3_groupname.tar
cd PA3
java -jar MJPA3_groupname.jar TestCase.java
java -jar MJSIM.jar TestCase.java.s > t1
javac TestCase.java
java TestCase > t2
diff t1 t2
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.