|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmars.util.SystemIO
public class SystemIO
Provides standard i/o services needed to simulate the MIPS syscall routines. These methods will detect whether the simulator is being run from the command line or through the GUI, then do I/O to System.in and System.out in the former situation, and interact with the GUI in the latter.
Field Summary | |
---|---|
static String |
fileErrorString
String used for description of file error |
static int |
SYSCALL_BUFSIZE
Buffer size for syscalls for file I/O |
static int |
SYSCALL_MAXFILES
Maximum number of files that can be open |
Constructor Summary | |
---|---|
SystemIO()
|
Method Summary | |
---|---|
static void |
closeFile(int fd)
Close the file with specified file descriptor |
static String |
getFileErrorMessage()
Retrieve file operation or error message |
static int |
openFile(String filename,
int flags)
Open a file for either reading or writing. |
static void |
printString(String string)
Implements syscall having 4 in $v0, to print a string. |
static int |
readChar(int serviceNumber)
Implements syscall having 12 in $v0, to read a char value. |
static double |
readDouble(int serviceNumber)
Implements syscall to read a double value. |
static float |
readFloat(int serviceNumber)
Implements syscall to read a float value. |
static int |
readFromFile(int fd,
byte[] myBuffer,
int lengthRequested)
Read bytes from file. |
static int |
readInteger(int serviceNumber)
Implements syscall to read an integer value. |
static String |
readString(int serviceNumber,
int maxLength)
Implements syscall to read a string. |
static void |
resetFiles()
Reset all files -- clears out the file descriptor table. |
static int |
writeToFile(int fd,
byte[] myBuffer,
int lengthRequested)
Write bytes to file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SYSCALL_BUFSIZE
public static final int SYSCALL_MAXFILES
public static String fileErrorString
Constructor Detail |
---|
public SystemIO()
Method Detail |
---|
public static int readInteger(int serviceNumber)
serviceNumber
- the number assigned to Read Int syscall (default 5)
public static float readFloat(int serviceNumber)
serviceNumber
- the number assigned to Read Float syscall (default 6)
public static double readDouble(int serviceNumber)
serviceNumber
- the number assigned to Read Double syscall (default 7)
public static void printString(String string)
public static String readString(int serviceNumber, int maxLength)
serviceNumber
- the number assigned to Read String syscall (default 8)maxLength
- the maximum string length
public static int readChar(int serviceNumber)
serviceNumber
- the number assigned to Read Char syscall (default 12)
public static int writeToFile(int fd, byte[] myBuffer, int lengthRequested)
fd
- file descriptormyBuffer
- byte array containing characters to writelengthRequested
- number of bytes to write
public static int readFromFile(int fd, byte[] myBuffer, int lengthRequested)
fd
- file descriptormyBuffer
- byte array to contain bytes readlengthRequested
- number of bytes to read
public static int openFile(String filename, int flags)
filename
- string containing filenameflag
- 0 for read, 1 for write
public static void closeFile(int fd)
fd
- the file descriptor of an open filepublic static void resetFiles()
public static String getFileErrorMessage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |