Assignment 2 Description
Assignment 2 – Translating Virtual Machine Code
Weighting and Due Dates
• Marks for this assignment contribute 10% of the overall course mark.
• Marks for functionality will be awarded automatically by the web submission system.
• Due dates: Milestone – 11:55pm Tuesday of week 9, Final – 11:55pm Friday of week 9.
• Late penalties: For each part, the maximum mark awarded will be reduced by 25% per day / part day late. If your mark is greater than the maximum, it will be reduced to the maximum.
• Core Body of Knowledge (CBOK) Areas: abstraction, design, hardware and software, data and information, and programming.
Project Description
In this assignment you will complete a variation of projects 7 and 8 in the nand2tetris course. In this assignment the translation program is in two separate programs. The precompiled executable program, bin/parser, will read a Hack Virtual Machine file from standard input and produce an abstract syntax tree on standard output. The executable program, translator, which you will write, will read the abstract syntax tree and output a Hack Assembly Language translation of each Virtual Machine command. The output will be in a form suitable for testing by the precompiled executable program bin/simulator.
SVN Repository
You must create a directory in your svn repository named:
• Makefile – this file is used by make to compile your programs – do not modify this file.
• Makefile-extras – this file is included by Makefile – do not modify this file.
• translator.cpp – C++ source file
• bin – this directory contains precompiled programs and scripts – do not modify this directory.
• lib – this directory contains precompiled components – do not modify this directory.
• includes – this directory contains .h files for precompiled classes – do not modify this directory.
• tests – this directory contains test data, you can add your own tests here
Note: if the lib/lib.a file does not get added to your svn repository you will need to explicitly add it using:
% svn add lib/lib.a
Submission and Marking Scheme
This assignment has two assignments in the web submission system named: Assignment 2 – Milestone Submissions and Assignment 2 – Final Submissions. The assessment is based on “Assessment of Programming Assignments”. A submission to either assignment in the web submission system will automatically result in a submission to the other assignment.
Assignment 2 – Milestone Submissions: due 11:55pm Tuesday of week 9
The marks awarded by the web submission system for the milestone submission contribute up to 20% of your marks for assignment 2. Your milestone submission mark, after the application of late penalties, will be posted to the myuni gradebook when the assignment marking is complete.
Your programs must be written in C++ and will be tested using a small set of Hack Virtual Machine files. You may assume that the first command in each test will be a function command so that you will always know the correct class and function name to use when constructing labels. Although a wide range of tests may be run, marks will only be recorded for those tests that require a complete implementation of the following commands:
• function
• push constant
• push static
• pop pointer
• add
• sub
• neg
• and
• or
• not
Note: the simulator tests each virtual machinecommand implementation separately so the overall failure of a test could still result in a significant number of marks for those individual virtual machine command implementations that behaved correctly.
Your program will be compiled using the Makefile included in the zip file attached below. The only source file that will be used to compile the translator program will be the file translator.cpp file. No other .cpp or .h files should be present in your svn directory.
Assignment 2 – Final Submissions: due 11:55pm Friday of week 9
The marks awarded for the final submission contribute up to 80% of your marks for assignment 2.
Your final submission mark will be the geometric mean of the marks awarded by the web submission system, a mark for your logbook and a mark for your code. It will be limited to 20% more than the marks awarded by the web submission system. See “Assessment – Mark Calculations” for examples of how the marks are combined. Your final submission mark, after the application of late penalties, will be posted to the myuni gradebook when the assignment marking is complete.
Automatic Marking
The automatic marking will compile and test your program in exactly the same way as for the milestone submission. The difference is that marks will be recorded for all of the tests.
Logbook Marking
Important: the logbook must have entries for all work in this assignment, including your milestone submissions. See “Assessment – Logbook Review” for details of how your logbook will be assessed.
Code Review Marking
For each of your programming assignments you are expected to submit well written code. See “Assessment – Code Review” for details of how your code will be assessed.
Assignment 2 – Participation Marks
Any submissions to the Final Submissions assignment made more than one week before but less than two weeks before the due date for the Final Submissions assignment, may be awarded participation marks. The participation marks will be calculated by scaling the best mark awarded by the automatic marking of an eligible submission to be a number between 0 and 10. A maximum of 10 participation marks are available.
Virtual Machine Translator
Background
This assignment requires you to write a complete implementation of the translator program that you may have started in Part 2 of the Virtual Machine Translation workshop. It would be a good idea to revisit workshop 07 before continuing with this assignment. However, you should start again using the startup files that are in the zip files attached below, do not reuse your work from workshop 07. These startup files include a working parser and some new test files. Remember to keep your logbook up to date when working on this assignment and make svn commits when you add new logbook entries.
Note: a limitation of the internal assembler being used requires all VM labels to start with a letter or ‘_’ and be followed by any number of letters, digits or ‘_’s. A VM label may not include ‘.’ or ‘$’.
Startup Files
The startup files in the attached zip file should work on most 64-bit Linux systems and on a Mac. Please see the Startup Files for Workshops and Assignments page for more information.
• assignment-vm-translator.zip