Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Assignment 2 - Writing an Assembler
Weighting and Due Dates
Marks for this assignment contribute 5% 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 project 6 in the
nand2tetris course. A detailed description of Nand2Tetris Project 6
tailored to this course is shown below. In this assignment the
assembler will be written as two separate programs. The executable
program, parser, will read a Hack Assembly Language program from
standard input and produce an abstract syntax tree on standard
output. The executable program, translator, will read the abstract
syntax tree and assemble a machine code representation of the
original Hack Assembly Language program. The assembled code will be
formatted as sixteen zeros or ones per line and it will be written to
standard output.
SVN Repository
You must create a directory in your svn repository named:
<year>/<semester>/cs/assignment2. This directory must only contain
the following files and directories - the web submission system will
check this:
? Makefile - this file is used by make to compile your
programs - do not modify this file.
? parser.cpp - C++ source file
? translator.cpp - C++ source file
? my*.cpp C++ source files with names that start with my
? my*.h C++ include files with names that start with my
? 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".
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 Hack
Assembly Language programs that that may or may not be syntactically
correct. Although a wide range of tests may be run, including a
number of secret tests, marks will only be recorded for those tests
that are syntactically correct and do not use symbols. Your programs
will be compiled using the Makefile included in the zip file
attached below. The parser program will be compiled using the file
parser.cpp and the translator program will be compiled using the
file translator.cpp file. In both cases any .cpp files with names
starting with my will be also included together with the precompiled
library functions.
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 both of your programs in
exactly the same way as for the milestone submission. The difference
is that marks will be recorded for all of the tests including
the secret tests. Note: if your programs fail any of these
secret tests you will not receive any feedback about these
secret tests, even if you ask!
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.
Nand2Tetris Project 6: The Assembler
Background
Low-level machine programs are rarely written by humans. Typically,
they are generated by compilers. Yet humans can inspect the
translated code and learn important lessons about how to write their
high-level programs better, in a way that avoids low-level pitfalls
and exploits the underlying hardware better. One of the key players
in this translation process is the assembler -- a program designed to
translate code written in a symbolic machine language into code
written in binary machine language.
This project marks an exciting landmark in our Nand to Tetris
odyssey: it deals with building the first rung up the software
hierarchy, which will eventually end up in the construction of a
compiler for a Java/C++ like high-level language. The relevant
reading for this project is Chapter 6. Some of the useful tools
available include, the Hack Assembler, the CPU Emulator and working
versions of the two programs, bin/working-parser and bin/workingtranslator.
Objective