4/26/2019 Assignment 2 Description: Computer Systems (2000_7081 Combined) https://myuni.adelaide.edu.au/courses/44935/pages/assignment-2-description 1/7 Assignment 2 Descrip�on Assignment 2 - Wri�ng...

C++ programming plus logbook for the development process


4/26/2019 Assignment 2 Description: Computer Systems (2000_7081 Combined) https://myuni.adelaide.edu.au/courses/44935/pages/assignment-2-description 1/7 Assignment 2 Descrip�on Assignment 2 - Wri�ng an Assembler Weigh�ng 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 Descrip�on 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: //cs/assignment2. This directory must only contain the following files and directories - the web submission system (https://cs.adelaide.edu.au/services/websubmission) 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 https://cs.adelaide.edu.au/services/websubmission 4/26/2019 Assignment 2 Description: Computer Systems (2000_7081 Combined) https://myuni.adelaide.edu.au/courses/44935/pages/assignment-2-description 2/7 This assignment has two assignments in the web submission system (https://cs.adelaide.edu.au/services/websubmission) named: Assignment 2 - Milestone Submissions and Assignment 2 - Final Submissions. The assessment is based on "Assessment of Programming Assignments (https://myuni.adelaide.edu.au/courses/44935/pages/assessment-of- programming-assignments) ". Assignment 2 - Milestone Submissions: due 11:55pm Tuesday of week 9 The marks awarded by the web submission system (https://cs.adelaide.edu.au/services/websubmission) 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 (https://cs.adelaide.edu.au/services/websubmission/) , 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 (https://cs.adelaide.edu.au/services/websubmission) . See "Assessment - Mark Calculations (https://myuni.adelaide.edu.au/courses/44935/pages/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. Automa�c 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 (https://myuni.adelaide.edu.au/courses/44935/pages/assessment-logbook-review) " for details of how your logbook will be assessed. https://cs.adelaide.edu.au/services/websubmission https://myuni.adelaide.edu.au/courses/44935/pages/assessment-of-programming-assignments https://cs.adelaide.edu.au/services/websubmission https://cs.adelaide.edu.au/services/websubmission/ https://cs.adelaide.edu.au/services/websubmission https://myuni.adelaide.edu.au/courses/44935/pages/assessment-mark-calculations https://myuni.adelaide.edu.au/courses/44935/pages/assessment-logbook-review 4/26/2019 Assignment 2 Description: Computer Systems (2000_7081 Combined) https://myuni.adelaide.edu.au/courses/44935/pages/assignment-2-description 3/7 Code Review Marking For each of your programming assignments you are expected to submit well written code. See "Assessment - Code Review (https://myuni.adelaide.edu.au/courses/44935/pages/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/parser and bin/translator. Objec�ve The Hack assembler is a relatively simple program however, so that you can gain experience with the tools used in other workshops and assignments, you will build your assembler from three parts. This will involve using a precompiled tokeniser for the Hack assembly language to implement a parser that recognises labels, A-instructions and C-instructions using tokens returned by the tokeniser. The parser will construct a tree representation of the program that the translator will walk over in order to assemble the final machine code. If you wish to create additional source files that can be used by your programs the .cpp and .h files must have names that start with my. All my*.cpp files will be compiled as part of both you parser and translator programs. Compiling and Running Your Programs You programs can be compiled with one of the following three commands. To compile both: % make To compile just parser: % make parser To compile just translator: https://myuni.adelaide.edu.au/courses/44935/pages/assessment-code-review 4/26/2019 Assignment 2 Description: Computer Systems (2000_7081 Combined) https://myuni.adelaide.edu.au/courses/44935/pages/assignment-2-description 4/7 % make translator To compile and test your programs at the same time you can use the following command: % make test g++ --std=c++11 -I. -Iincludes -c -o parser.o parser.cpp g++ --std=c++11 -I. -Iincludes -o parser parser.o lib/lib.a Testing student parser against Pxml files. | Test Input | parser | Expected Test Output | Test Result Checking "cat tests/Add.milestone | ./parser | diff - tests/Add.milestone.Pxml " - test passe d ... g++ --std=c++11 -I. -Iincludes -c -o translator.o translator.cpp g++ --std=c++11 -I. -Iincludes -o translator translator.o lib/lib.a Testing student translator against Pxml-hack files. | Test Input | bin/parser | translator | Expected Test Output | Test Result Checking "cat tests/Add.milestone | ./bin/parser | ./translator | diff - tests/Add.milestone.Pxml-hack " - test passed ... Testing student parser and translator against Pxml-hack files. | Test Input | parser | translator | Expected Test Output | Test Result Checking "cat tests/Add.milestone | ./parser | ./translator | diff - tests/Add.milestone.Pxml-hack " - test passed ... The test scripts do not show the program outputs, just passed or failed, but they do show you the commands being used to run each test. You can copy-paste these commands if you want to run a particular test yourself and see all of the output. If you wish to add new tests, create appropriately named files in the tests directory and then use the command: % make test-add Note: If you want to see what your parser or translator programs should be producing you can use the expected output files in the tests directory as a reference. Note: Do not modify the Makefile or the sub-directories includes, bin and lib. They will be replaced during testing by the web submission system. The Tokeniser You must use the precompiled tokeniser functions provided by the library in the zip file attached below. The tokens recognised and the tokeniser functions are described in the file includes/tokeniser.h. The tokeniser objects returned convert the spelling of all tokens to uppercase except for label / variable names which are case sensitive. All error handling is silent, if the tokeniser encounters a character that cannot be part of a token or a character that is not whitespace, it
May 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here