CS140 HW06 - Assembler
Objective
- Connect Assembly and Machine Language to computer architecture
- Write a program to translate from Assembly to Machine Language
- Learn and practice C programming fundamentals
|
Background
Assignment
This week's assignment is Nand2Tetris Assignment #6,
with the following restrictions and additions.
Pair Programming
For this assignment, pair programming is encouraged, subject to:
- Each pair shall work on a single program and turn in only one submission.
- Work on the assignment must be completed together in person, using a single computer.
- The pairs must take turns at the keyboard, with roughly equal share of the roles.
- Minor bug fixes, designs, done independently should be documented on paper and then implemented together by the pair.
It
not allowed to split up the work of the project, work on the code without the partner present, or to share information between teams.
C Language Required
This program must be implemented in the C programming language, and the program must execute on the csgateway linux machine.
- You must supply a make file so that your program can be compiled by executing "make" within your code directory.
- The name of your executable must be assembler in all lowercase.
- The assembler must take exactly two command line arguments: input filename and output filename.
- The folowing command should assemble an input file named test.asm and output it to test.hack:
./assembler test.asm test.hack
- Your program must free any memory that it allocates. You can check your program with the
valgrind
Testing and Evaluation
Your solution will be tested for correctness, and your code will be evaluated for proper programming style.
- Correctness will evaluated by comparing the output of your assembler against the output from the nand2tetris supplied assembler.
You can use the
diff
command on linux to compare files.
valgrind
will be used to check your program for memory leaks.
- Your code must be properly documented, with comments describing each function and inline comments describing how the code works.
- The functionality of your code must be properly separated into modules and functions (as suggested in the nand2tetris description).
- Each file of your code must include a header describing the module, the authors (your names), the date, and the assignment. You
must note in the header any resources outside of class that you accessed to assist with the assignment.
C Programming Language Collaboration
You are encouraged to assist eachother with aspects of the C programming language. You may help anybody in the class with topics of: C syntax, C language features, string manipulation, compiling code, makefiles, understanding error messages.
Map Data Structure
I've written some C code for a simple map data structure. You can use this for your symbol table and command lookups.
The code is available:
here.
Submit
Submission will be on Gradescope. Please clean your submission and submit a zip file containing your code and Makefile at the TOP LEVEL (not inside a folder).
Your program
must compile and run on the ssh.cs.clarku.edu machine according to the specification above. We should be able to unzip your file, run make, and execute the resulting program as specified above.
Checkpoint
Checkpoint output of your program that outputs C_COMMAND, A_COMMAND, L_COMMAND as specified in class. Place your source code files and Makefile into the top level of the zip file and upload to Gradescope.
Academic Conduct Reminder
While pair programming is allowed, collaboration between pairs is not allowed. Each submission must represent the intellectual efforts of the person or persons submitting the assignment. You may access resources about the C programming language, but you may not review code related to this assignment from any sources. Please review the policy on the syllabus and ask questions if you are unsure.