Package mars.mips.instructions.syscalls
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,SyscallPrintString,SyscallRandDouble,SyscallRandFloat,SyscallRandInt,SyscallRandIntRange,SyscallRandSeed,SyscallRead,SyscallReadChar,SyscallReadDouble,SyscallReadFloat,SyscallReadInt,SyscallReadString,SyscallSbrk,SyscallSleep,SyscallTime,SyscallWrite
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() method will be invoked.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSyscall(int number, String name)Constructor is provided so subclass may initialize instance variables. -
Method Summary
-
Constructor Details
-
AbstractSyscall
Constructor is provided so subclass may initialize instance variables.- Parameters:
number- default assigned service numbername- service name which may be used for reference independent of number
-
-
Method Details
-
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. -
setNumber
public void setNumber(int num)Set the service number. This is provided to allow MARS implementer or user to override the default service number. -
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. -
simulate
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:
simulatein interfaceSyscall- Parameters:
statement- ProgramStatement object for this syscall instruction.- Throws:
ProcessingException
-