CS140 HW04 - Assembly Language

Objective

  • Understand and practice Assembly Language programming
  • Connect Assembly and Machine Language to computer architecture

Background

This assignment is based on material from Nand2Tetris Chapter 4.
See resources here: http://www.nand2tetris.org/course

See add100.asm example for style and commenting.

See the course Piazza for additional hints and tips.

Required Tasks

    Collaborative Assignment



    The first part of HW04 is a collaborative assignment. Write a HACK assembly language program using the tools from Nand2Tetris Assignment 4 according to the following specification.

    String Length
    This assignment will calculate the length of a string and store the result in a memory location. A string is specified by a starting memory location, and each increasing consecutive memory address until a "0" value is reached.
    • Place your string starting at memory address 100.
    • The resulting total length of the string should be at memory address 16 when the program completes (note that memory address 16 is the location of the first variable you use).
    • Be sure that your program works for strings of length 0, 1, as well as longer strings (e.g. 20 characters).
    • This part of the assignment is OPEN collaboration. You can work with any other students as long as you are physically present in the same space. You may not simply share or submit someone else's code. You must acknowledge the names of any students you work with.
    • Name your program strlen.asm
    Use the following files to test your program:

    Individual Assignment


    Complete the two programs for Nand2Tetris Assignment #4. This part of the assignment must be completed individually.

Submit



Please zip up and submit your entire 04 directory. Be sure to include your strlen.asm program.

The zip file must have the following structure:

/04/strlen.asm
/04/mult/mult.asm
/04/fill/Fill.asm
Note the capital F in the filename for Fill.asm as it is the case-sensitive name provided by the nand2tetris project. Other files in the zip file are ok and will be ignored. Also note that the Mult.tst file has been modified on the autograder to look for mult.hack with a lowercase m. The autograder will first assemble your .asm file into a .hack file and then run the .tst script.

Grading Rubric



Your submission will be evaluated as:
15% strlen test autograder
5% strlen header, style, comments

35% mult test autograder
5% mult header, style, comments

35% fill test autograder
5% fill header, style, comments
Each file you submit must have an appropriate header that identifies the author, the date, class/semester, project name, and a short description of what it does. For the strlen assignment where collaboration is encouraged, you must indicate in the header the names of other students you worked with.

Each file must also have good style and commenting. Use indentation to indicate blocks of code as demonstrated in the example files. Use comments to explain high level functionality.