Java Reference
In-Depth Information
AppendixE
MIPSandtheSPIMSimulator
E.1 Introduction
In addition to compiling j-- source programs to JVM byte code, the j-- compiler can also
produce native code for the MIPS architecture. The compiler does not actually produce
binary code that can be run on such a machine, but it produces human-readable assembly
code that can be executed by a program that simulates a MIPS machine. The advantage of
using a simulator is that one can easily debug the translated program, and does not need
access to an actual MIPS machine in order to run the program. The simulator that we will
use is called SPIM (MIPS spelled backward). Chapter 7 describes the MIPS architecture
and the SPIM simulator in some detail. In this appendix we describe how one can obtain
and run SPIM, compile j-- programs to SPIM code, and extend the JVM to SPIM translator
to convert more JVM instructions to SPIM code. The MIPS (and so, SPIM) instruction set
is described very nicely in [Larus, 2009].
E.2 Obtaining and Running SPIM
SPIM implements both a command-line and a graphical user interface (GUI). The GUI for
SPIM, called QtSpim, is developed using the Qt UI Framework 1 . Qt being cross-platform,
QtSpim will run on Windows, Linux, and Mac OS X.
One can download the compiled version of SPIM for Windows, Mac OS X,
or Debian-based (including Ubuntu) Linux from http://sourceforge.net/projects
/spimsimulator/files/ , or build SPIM from source files obtained from http://
spimsimulator.svn.sourceforge.net/viewvc/spimsimulator/ . The README file in the
source distribution documents the installation steps.
E.3 Compilingj--Programs to SPIM Code
The j-- compiler supports the following command-line syntax:
Usage:j--<options><sourcefile>
wherepossibleoptionsinclude:
-tOnlytokenizeinputandprinttokenstoSTDOUT
1 A cross-platform application and UI framework with APIs for C ++ programming and Qt Quick for
rapid UI creation.
341
 
Search WWH ::




Custom Search