SaM Simulator

SaM Simulator

Current Version: 2.6.2 (Released 09/02/2005)

SaM (Stack Machine) is the simulator used for CS212. It implements a custom ISA that is designed to be easy to use. The simulator and associated tools are written in Java.

Running the Simulator

The easiest way to run the simulator is by downloading the JAR file and running java -jar SaM-<version>.jar. Alternatively, you may also execute the edu.cornell.cs.sam.ui.SamUI class. This class can be run from the JAR file as java -cp SaM-<version>.jar <classname> or by compiling the source code and running java <classname> from the root of the source tree. There is also a text based interface provided in the edu.cornell.cs.sam.ui.SamText class.

SaM 2.6 requires JDK 1.5+. Please make sure your are running the latest version of the JDK if you experience any problems.

Compiling the Simulator

The SaM Simulator is a large project with many files. We are also using a standard package name structure (with all our files under the edu.cornell.cs.sam package). The only reccommended way to compile SaM is to use an IDE. For example, Eclipse is a free and very powerful IDE. You can import the source code and it will handle all the problems of compilation for you.

Using SamTokenizer

The SaM simulator provides a tokenizer that is very helpful in developing a Bali compiler. To use it, make sure you include the SaM JAR file in your classpath when you compile or run your program (javac -classpath SaM-<version>.jar ... for compiling and java -cp SaM-<version>.jar ... when running), include edu.cornell.cs.sam.io.* in your source files, and follow the API.

If you have any questions, please read the SaM I/O Frequently Asked Questions.

Downloading the Simulator

Documentation

If you find any bugs, please e-mail David Levitan.