Assignment 2

In this assignment, you will add support for labels to the intermediate language, write some assembly language programs that use labels, and add support for comments and nested blocks to the intermediate language.

In Transformations.scala, complete the implementation of eliminateLabels.

The comment in the handout code says: "If a label is defined multiple times or if a label is used but not defined, call error() with an appropriate error message." The correct function to call in this case is sys.error(). The comment refers to the incorrect URL http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Seq. The correct URL is http://www.scala-lang.org/api/current/scala/collection/immutable/Seq.html.

In A2.scala, complete the implementation of:

  1. maximum
  2. maximumUnsigned

Back in Transformations.scala, complete the implementation of:

  1. eliminateComments
  2. eliminateBlocks
  3. mapCodeTotal

Note: mapCodeTotal will not be tested as part of Assignment 2, but will be used in Assignment 3 and later assignments.

The comment for mapCode refers to the incorrect URL http://www.scala-lang.org/api/current/index.html#scala.PartialFunction. The correct URL is http://www.scala-lang.org/api/current/scala/PartialFunction.html.