Package jminusminus

Class SPIM

java.lang.Object
jminusminus.SPIM

public class SPIM extends Object
This is a Java wrapper class for the SPIM runtime file SPIM.s. Any j-- program that's compiled for the SPIM target must import this class for console IO operations. Note that the functions have no implementations here which means that if the programs using this class are compiled using j--, they will compile fine but won't function as desired when run against the JVM. Such programs must be compiled using the j-- compiler for the SPIM target and must be run against the SPIM simulator.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Exits SPIM.
    static void
    exit2(int code)
    Exits SPIM with the given code.
    static void
    printChar(char value)
    Prints a char to the console.
    static void
    printDouble(double value)
    Prints a double to the console.
    static void
    printFloat(float value)
    Prints a float to the console.
    static void
    printInt(int value)
    Prints an integer to the console.
    static void
    Prints a string to the console.
    static char
    Reads and returns a char from the console.
    static double
    Reads and returns a double from the console.
    static float
    Reads and returns a float from the console.
    static int
    Reads and returns an integer from the console.
    static String
    readString(int length)
    Reads and returns a string from the console.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SPIM

      public SPIM()
  • Method Details

    • printInt

      public static void printInt(int value)
      Prints an integer to the console.
      Parameters:
      value - the integer.
    • printFloat

      public static void printFloat(float value)
      Prints a float to the console.
      Parameters:
      value - the float.
    • printDouble

      public static void printDouble(double value)
      Prints a double to the console.
      Parameters:
      value - the double.
    • printString

      public static void printString(String value)
      Prints a string to the console.
      Parameters:
      value - the string.
    • printChar

      public static void printChar(char value)
      Prints a char to the console.
      Parameters:
      value - the char.
    • readInt

      public static int readInt()
      Reads and returns an integer from the console.
      Returns:
      an integer from the console.
    • readFloat

      public static float readFloat()
      Reads and returns a float from the console.
      Returns:
      a float from the console.
    • readDouble

      public static double readDouble()
      Reads and returns a double from the console.
      Returns:
      a double from the console.
    • readString

      public static String readString(int length)
      Reads and returns a string from the console.
      Returns:
      a string from the console.
    • readChar

      public static char readChar()
      Reads and returns a char from the console.
      Returns:
      a char from the console.
    • exit

      public static void exit()
      Exits SPIM.
    • exit2

      public static void exit2(int code)
      Exits SPIM with the given code.
      Parameters:
      code - the exit code.