Class AbstractSyscall

java.lang.Object
mars.mips.instructions.syscalls.AbstractSyscall
All Implemented Interfaces:
Syscall
Direct Known Subclasses:
SyscallClose, SyscallConfirmDialog, SyscallExit, SyscallExit2, SyscallInputDialogDouble, SyscallInputDialogFloat, SyscallInputDialogInt, SyscallInputDialogString, SyscallMessageDialog, SyscallMessageDialogDouble, SyscallMessageDialogFloat, SyscallMessageDialogInt, SyscallMessageDialogString, SyscallMidiOut, SyscallMidiOutSync, SyscallOpen, SyscallPrintChar, SyscallPrintDouble, SyscallPrintFloat, SyscallPrintInt, SyscallPrintIntBinary, SyscallPrintIntHex, SyscallPrintIntUnsigned, SyscallPrintIOMessage, SyscallPrintString, SyscallRandDouble, SyscallRandFloat, SyscallRandInt, SyscallRandIntRange, SyscallRandSeed, SyscallRead, SyscallReadChar, SyscallReadDouble, SyscallReadFloat, SyscallReadInt, SyscallReadString, SyscallSbrk, SyscallSeek, SyscallSleep, SyscallTime, SyscallWrite

public abstract class AbstractSyscall extends Object implements Syscall
Abstract class that a MIPS syscall system service may extend. A qualifying service must be a class in the mars.mips.instructions.syscalls package that implements the Syscall interface, must be compiled into a .class file, and its .class file must be in the same folder as Syscall.class. Mars will detect a qualifying syscall upon startup, create an instance using its no-argument constructor and add it to its syscall list. When its service is invoked at runtime ("syscall" instruction with its service number stored in register $v0), its simulate(BasicStatement) method will be invoked.
  • Constructor Details

    • AbstractSyscall

      public AbstractSyscall(int number, String name)
      Constructor is provided so subclass may initialize instance variables.
      Parameters:
      number - default assigned service number
      name - service name which may be used for reference independent of number
  • Method Details

    • getName

      public String getName()
      Return the name you have chosen for this syscall. This can be used by a MARS user to refer to the service when choosing to override its default service number in the configuration file.
      Specified by:
      getName in interface Syscall
      Returns:
      service name as a string
    • setNumber

      public void setNumber(int number)
      Set the service number. This is provided to allow MARS implementer or user to override the default service number.
      Specified by:
      setNumber in interface Syscall
      Parameters:
      number - specified service number to override the default.
    • getNumber

      public int getNumber()
      Return the assigned service number. This is the number the MIPS programmer must store into $v0 before issuing the SYSCALL instruction.
      Specified by:
      getNumber in interface Syscall
      Returns:
      assigned service number
    • simulate

      public abstract void simulate(BasicStatement statement) throws SimulatorException, InterruptedException
      Performs syscall function. It will be invoked when the service is invoked at simulation time. Service is identified by value stored in $v0.
      Specified by:
      simulate in interface Syscall
      Parameters:
      statement - BasicStatement object for this syscall instruction.
      Throws:
      SimulatorException
      InterruptedException