Assignment 7

Due Date: 2015-3-8, 11:59pm

Objective

Write a VM-to-Assembler translator that produces behavior that passes the tests. Start with the basic branching commands with
  • BasicLoop.vm
  • FibonacciSeries.vm
then tackle the function calling with
  • SimpleFunction.vm
  • FibbonacciElement (Main.vm and Sys.vm)
  • StaticsTest (Class1.vm, Class2.vm, Sys.vm)

Software

This assignment extends upon the code you wrote last week. You should copy your code from assignment 6 into this week's assignment folder, and add the the extra needed functions to the code writer class.

Also, note that in some versions of last week's Java stubs, C_FUNCTION was not defined in VMCommandType.java. Please add it yourself.

Tips and Resources

  • The only change you need to make to the parser is to handle C_LABEL, C_GOTO, C_IF, C_FUNCTION, C_RETURN, and C_CALL when checking the command type.
  • You only need to call init when you have multiple vm files. You can test for this in your translator.
  • As with the last assignment, write comments into your assembly code.
  • The provided code can take either a vm file or a directory as input. If its a file Foo.vm, then it will be translated to Foo.asm in the same folder. If its a directory, for each subdirectory, the translator will compile all of the vm files in the directory into one asm file in that folder, with the same name as the folder. This functionality is not needed in this assignment, but will be useful next week. Also, its a nice way to translate all of the vm files provided at once.
  • Once again, you do not have to check for errors, including whether a given segment index is valid.