CSCI 322 - Computing Systems Organization
Spring 2020
Project 11 Guide
To complete Project 11, it is best to finish the compiler in stages. At each
stage, only implement the code generation for the productions sufficient for
completing the given test case.
Some of these test cases are included in the nand2tetris distribution. Others I created myself;
their titles include hyperlinks to the ZIP files containing their source code in Jack.
To compile Three, you need to generate code for the following symbols:
- class
- subroutineDec (ignore parameterList)
- subroutineBody (functions only)
- statements
- doStatement
- returnStatement (may ignore return value)
- subroutineCall (functions only)
- expressionList
- expression
- term (specifically integerConstant)
Seven
To compile Seven, you need to generate code for the following additional symbols:
- term (parenthesized expressions)
- op (specifically + and *)
To compile AlphaWhere, you need to generate code for the following
additional symbols:
- varDec
- letStatement (ignore arrays)
- ifStatement
- term (specifically true, false, and varName for locals)
- op (specifically - and <)
Note : You will need to create a symbol table data structure to keep track of your
local variables.
To compile AlphaShow, you need to generate code for the following
additional symbols:
- varDec (specifically, more than one variable of the same type on a line)
- whileStatement
- term (specifically the ~ unary operator)
- op (specifically >)
To compile Factorial, you need to generate code for the following
additional symbols:
- subroutineDec (with paramaterList)
- returnStatement (with return expression)
- term (specifically, varName for arguments and stringConstant)
- op (specifically =)
ConvertToBin
NOTE: The provided ConvertToBin is difficult to use. I recommend my
modified version (Main.jack). My version
uses keyboard input and prints to the screen, rather than relying
on RAM hacking. Note that it prints its binary result with the least significant bit on
the left (reversed in comparison to how you would typically write a binary number).
To compile ConvertToBin, you need to generate code for the following
additional symbols:
- varDec (specifically multiple var declarations of different data types)
- letStatement (specifically modification of parameter values)
- subroutineDec (with paramaterList that has multiple parameters)
- op (specifically &)
Average
To compile Average, you need to generate code for the following additional
symbols:
- letStatement (with arrays)
- term (specifically varName with array lookup)
- op (specifically division)