[O] Refactor

This commit is contained in:
Azalea
2022-11-09 23:41:40 -05:00
parent 380de99170
commit 13c408bbdd
417 changed files with 5494 additions and 5561 deletions
-1
View File
@@ -1 +0,0 @@
jar cmf mainclass.txt Mars.jar PseudoOps.txt Config.properties Syscall.properties Settings.properties MARSlicense.txt mainclass.txt MipsXRayOpcode.xml registerDatapath.xml controlDatapath.xml ALUcontrolDatapath.xml CreateMarsJar.bat CreateMarsJar.sh Mars.java Mars.class docs help images mars
-2
View File
@@ -1,2 +0,0 @@
# If you can't generate due of permissions, do a "chmod +x CreateMarsJar.sh".
jar cmf mainclass.txt Mars.jar PseudoOps.txt Config.properties Syscall.properties Settings.properties MARSlicense.txt mainclass.txt MipsXRayOpcode.xml registerDatapath.xml controlDatapath.xml ALUcontrolDatapath.xml CreateMarsJar.bat CreateMarsJar.sh Mars.java Mars.class docs help images mars
+1 -10
View File
@@ -1,12 +1,3 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.5.1/userguide/building_java_projects.html
* This project uses @Incubating APIs which are subject to change.
*/
plugins { plugins {
// Apply the application plugin to add support for building a CLI application in Java. // Apply the application plugin to add support for building a CLI application in Java.
id 'application' id 'application'
@@ -34,5 +25,5 @@ testing {
application { application {
// Define the main class for the application. // Define the main class for the application.
mainClass = 'mars.assembler.App' mainClass = 'Mars'
} }
+17
View File
@@ -0,0 +1,17 @@
import os
from pathlib import Path
from subprocess import check_output
if __name__ == '__main__':
java = Path('src/main/java')
files = [Path(root) / f for root, dir, files in os.walk(java) for f in files]
for f in files:
ftype = check_output(f'file {f}', shell=True).decode()
if '8859' not in ftype:
continue
print(f'Converting {f} to UTF-8...')
f.write_text(f.read_text('ISO-8859-1'), 'utf8')
# print(files)
+1 -11
View File
@@ -1,11 +1 @@
/* rootProject.name = 'MARS'
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.5.1/userguide/multi_project_builds.html
* This project uses @Incubating APIs which are subject to change.
*/
rootProject.name = 'MARS-Assembler'
+5 -6
View File
@@ -1,4 +1,3 @@
/* /*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
@@ -34,9 +33,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* @version March 2006 * @version March 2006
**/ **/
public class Mars { public class Mars {
public static void main(String[] args) { public static void main(String[] args) {
new mars.MarsLaunch(args); new mars.MarsLaunch(args);
} }
} }
-2
View File
@@ -1,2 +0,0 @@
Main-Class: Mars
Class-Path: .
+222 -176
View File
@@ -1,12 +1,16 @@
package mars; package mars;
import mars.mips.instructions.syscalls.*;
import mars.mips.instructions.*; import mars.assembler.SymbolTable;
import mars.mips.hardware.*; import mars.mips.hardware.Memory;
import mars.assembler.*; import mars.mips.instructions.InstructionSet;
import mars.venus.*; import mars.mips.instructions.syscalls.SyscallNumberOverride;
import mars.util.*; import mars.util.PropertiesFile;
import java.io.*; import mars.venus.VenusUI;
import java.util.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
/* /*
Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2008, Pete Sanderson and Kenneth Vollmar
@@ -42,84 +46,123 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* @author Pete Sanderson * @author Pete Sanderson
* @version August 2003 * @version August 2003
*/ */
public class Globals public class Globals {
{ /**
// List these first because they are referenced by methods called at initialization. * Path to folder that contains images
private static String configPropertiesFile = "Config"; */
private static String syscallPropertiesFile = "Syscall";
/** The set of implemented MIPS instructions. **/
public static InstructionSet instructionSet;
/** the program currently being worked with. Used by GUI only, not command line. **/
public static MIPSprogram program;
/** Symbol table for file currently being assembled. **/
public static SymbolTable symbolTable;
/** Simulated MIPS memory component. **/
public static Memory memory;
/** Lock variable used at head of synchronized block to guard MIPS memory and registers **/
public static Object memoryAndRegistersLock = new Object();
/** Flag to determine whether or not to produce internal debugging information. **/
public static boolean debug = false;
/** Object that contains various settings that can be accessed modified internally. **/
static Settings settings;
/** String to GUI's RunI/O text area when echoing user input from pop-up dialog. */
public static String userInputAlert = "**** user input : ";
/** Path to folder that contains images */
// The leading "/" in filepath prevents package name from being pre-pended. // The leading "/" in filepath prevents package name from being pre-pended.
public static final String imagesPath = "/images/"; public static final String imagesPath = "/images/";
/** Path to folder that contains help text */ /**
public static final String helpPath = "/help/"; * Path to folder that contains help text
/* Flag that indicates whether or not instructionSet has been initialized. */ */
private static boolean initialized = false; public static final String helpPath = "/help/";
/**
* The current MARS version number. Can't wait for "initialize()" call to get it.
*/
public static final String version = "4.5";
/**
* MARS copyright years
*/
public static final String copyrightYears = getCopyrightYears();
/**
* MARS copyright holders
*/
public static final String copyrightHolders = getCopyrightHolders();
/**
* The set of implemented MIPS instructions.
**/
public static InstructionSet instructionSet;
/**
* the program currently being worked with. Used by GUI only, not command line.
**/
public static MIPSprogram program;
/**
* Symbol table for file currently being assembled.
**/
public static SymbolTable symbolTable;
/**
* Simulated MIPS memory component.
**/
public static Memory memory;
/**
* Lock variable used at head of synchronized block to guard MIPS memory and registers
**/
public static Object memoryAndRegistersLock = new Object();
/**
* Flag to determine whether or not to produce internal debugging information.
**/
public static boolean debug = false;
/**
* String to GUI's RunI/O text area when echoing user input from pop-up dialog.
*/
public static String userInputAlert = "**** user input : ";
/**
* MARS exit code -- useful with SYSCALL 17 when running from command line (not GUI)
*/
public static int exitCode = 0;
public static boolean runSpeedPanelExists = false;
/**
* Object that contains various settings that can be accessed modified internally.
**/
static Settings settings;
/* The GUI being used (if any) with this simulator. */ /* The GUI being used (if any) with this simulator. */
static VenusUI gui = null; static VenusUI gui = null;
/** The current MARS version number. Can't wait for "initialize()" call to get it. */ // List these first because they are referenced by methods called at initialization.
public static final String version = "4.5"; private static final String configPropertiesFile = "Config";
/** List of accepted file extensions for MIPS assembly source files. */ /**
public static final ArrayList fileExtensions = getFileExtensions(); * List of accepted file extensions for MIPS assembly source files.
/** Maximum length of scrolled message window (MARS Messages and Run I/O) */ */
public static final int maximumMessageCharacters = getMessageLimit(); public static final ArrayList fileExtensions = getFileExtensions();
/** Maximum number of assembler errors produced by one assemble operation */ /**
public static final int maximumErrorMessages = getErrorLimit(); * Maximum length of scrolled message window (MARS Messages and Run I/O)
/** Maximum number of back-step operations to buffer */ */
public static final int maximumBacksteps = getBackstepLimit(); public static final int maximumMessageCharacters = getMessageLimit();
/** MARS copyright years */ /**
public static final String copyrightYears = getCopyrightYears(); * Maximum number of assembler errors produced by one assemble operation
/** MARS copyright holders */ */
public static final String copyrightHolders = getCopyrightHolders(); public static final int maximumErrorMessages = getErrorLimit();
/** Placeholder for non-printable ASCII codes */ /**
public static final String ASCII_NON_PRINT = getAsciiNonPrint(); * Maximum number of back-step operations to buffer
/** Array of strings to display for ASCII codes in ASCII display of data segment. ASCII code 0-255 is array index. */ */
public static final String[] ASCII_TABLE = getAsciiStrings(); public static final int maximumBacksteps = getBackstepLimit();
/** MARS exit code -- useful with SYSCALL 17 when running from command line (not GUI) */ /**
public static int exitCode = 0; * Placeholder for non-printable ASCII codes
*/
public static final String ASCII_NON_PRINT = getAsciiNonPrint();
/**
* Array of strings to display for ASCII codes in ASCII display of data segment. ASCII code 0-255 is array index.
*/
public static final String[] ASCII_TABLE = getAsciiStrings();
private static final String syscallPropertiesFile = "Syscall";
/* Flag that indicates whether or not instructionSet has been initialized. */
private static boolean initialized = false;
public static boolean runSpeedPanelExists = false; private static String getCopyrightYears() {
return "2003-2014";
}
private static String getCopyrightYears() { private static String getCopyrightHolders() {
return "2003-2014"; return "Pete Sanderson and Kenneth Vollmar";
} }
private static String getCopyrightHolders() {
return "Pete Sanderson and Kenneth Vollmar";
}
public static void setGui(VenusUI g) { public static VenusUI getGui() {
gui = g; return gui;
} }
public static VenusUI getGui() {
return gui;
}
public static Settings getSettings() { public static void setGui(VenusUI g) {
return settings; gui = g;
} }
public static Settings getSettings() {
return settings;
}
/** /**
* Method called once upon system initialization to create the global data structures. * Method called once upon system initialization to create the global data structures.
**/ **/
public static void initialize(boolean gui) { public static void initialize(boolean gui) {
if (!initialized) { if (!initialized) {
memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory
instructionSet = new InstructionSet(); instructionSet = new InstructionSet();
instructionSet.populate(); instructionSet.populate();
@@ -127,123 +170,126 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
settings = new Settings(gui); settings = new Settings(gui);
initialized = true; initialized = true;
debug = false; debug = false;
memory.clear(); // will establish memory configuration from setting memory.clear(); // will establish memory configuration from setting
} }
} }
// Read byte limit of Run I/O or MARS Messages text to buffer. // Read byte limit of Run I/O or MARS Messages text to buffer.
private static int getMessageLimit() { private static int getMessageLimit() {
return getIntegerProperty(configPropertiesFile, "MessageLimit", 1000000); return getIntegerProperty(configPropertiesFile, "MessageLimit", 1000000);
} }
// Read limit on number of error messages produced by one assemble operation. // Read limit on number of error messages produced by one assemble operation.
private static int getErrorLimit() { private static int getErrorLimit() {
return getIntegerProperty(configPropertiesFile, "ErrorLimit", 200); return getIntegerProperty(configPropertiesFile, "ErrorLimit", 200);
} }
// Read backstep limit (number of operations to buffer) from properties file. // Read backstep limit (number of operations to buffer) from properties file.
private static int getBackstepLimit() { private static int getBackstepLimit() {
return getIntegerProperty(configPropertiesFile, "BackstepLimit", 1000); return getIntegerProperty(configPropertiesFile, "BackstepLimit", 1000);
} }
// Read ASCII default display character for non-printing characters, from properties file. // Read ASCII default display character for non-printing characters, from properties file.
public static String getAsciiNonPrint() { public static String getAsciiNonPrint() {
String anp = getPropertyEntry(configPropertiesFile, "AsciiNonPrint"); String anp = getPropertyEntry(configPropertiesFile, "AsciiNonPrint");
return (anp == null) ? "." : ( (anp.equals("space")) ? " " : anp ); return (anp == null) ? "." : ((anp.equals("space")) ? " " : anp);
} }
// Read ASCII strings for codes 0-255, from properties file. If string // Read ASCII strings for codes 0-255, from properties file. If string
// value is "null", substitute value of ASCII_NON_PRINT. If string is // value is "null", substitute value of ASCII_NON_PRINT. If string is
// "space", substitute string containing one space character. // "space", substitute string containing one space character.
public static String[] getAsciiStrings() { public static String[] getAsciiStrings() {
String let = getPropertyEntry(configPropertiesFile,"AsciiTable"); String let = getPropertyEntry(configPropertiesFile, "AsciiTable");
String placeHolder = getAsciiNonPrint(); String placeHolder = getAsciiNonPrint();
String[] lets = let.split(" +"); String[] lets = let.split(" +");
int maxLength = 0; int maxLength = 0;
for (int i = 0; i < lets.length; i++) { for (int i = 0; i < lets.length; i++) {
if (lets[i].equals("null")) lets[i] = placeHolder; if (lets[i].equals("null")) lets[i] = placeHolder;
if (lets[i].equals("space")) lets[i] = " "; if (lets[i].equals("space")) lets[i] = " ";
if (lets[i].length() > maxLength) maxLength = lets[i].length(); if (lets[i].length() > maxLength) maxLength = lets[i].length();
} }
String padding = " "; String padding = " ";
maxLength++; maxLength++;
for (int i = 0; i < lets.length; i++) { for (int i = 0; i < lets.length; i++) {
lets[i] = padding.substring(0,maxLength-lets[i].length()) + lets[i]; lets[i] = padding.substring(0, maxLength - lets[i].length()) + lets[i];
} }
return lets; return lets;
} }
// Read and return integer property value for given file and property name. // Read and return integer property value for given file and property name.
// Default value is returned if property file or name not found. // Default value is returned if property file or name not found.
private static int getIntegerProperty(String propertiesFile, String propertyName, int defaultValue) { private static int getIntegerProperty(String propertiesFile, String propertyName, int defaultValue) {
int limit = defaultValue; // just in case no entry is found int limit = defaultValue; // just in case no entry is found
Properties properties = PropertiesFile.loadPropertiesFromFile(propertiesFile); Properties properties = PropertiesFile.loadPropertiesFromFile(propertiesFile);
try { try {
limit = Integer.parseInt(properties.getProperty(propertyName, Integer.toString(defaultValue))); limit = Integer.parseInt(properties.getProperty(propertyName, Integer.toString(defaultValue)));
} } catch (NumberFormatException nfe) {
catch (NumberFormatException nfe) { } // do nothing, I already have a default } // do nothing, I already have a default
return limit; return limit;
} }
// Read assembly language file extensions from properties file. Resulting // Read assembly language file extensions from properties file. Resulting
// string is tokenized into array list (assume StringTokenizer default delimiters). // string is tokenized into array list (assume StringTokenizer default delimiters).
private static ArrayList getFileExtensions() { private static ArrayList getFileExtensions() {
ArrayList extensionsList = new ArrayList(); ArrayList extensionsList = new ArrayList();
String extensions = getPropertyEntry(configPropertiesFile,"Extensions"); String extensions = getPropertyEntry(configPropertiesFile, "Extensions");
if (extensions != null) { if (extensions != null) {
StringTokenizer st = new StringTokenizer(extensions); StringTokenizer st = new StringTokenizer(extensions);
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
extensionsList.add(st.nextToken()); extensionsList.add(st.nextToken());
} }
} }
return extensionsList; return extensionsList;
} }
/** /**
* Get list of MarsTools that reside outside the MARS distribution. * Get list of MarsTools that reside outside the MARS distribution.
* Currently this is done by adding the tool's path name to the list * Currently this is done by adding the tool's path name to the list
* of values for the external_tools property. Use ";" as delimiter! * of values for the external_tools property. Use ";" as delimiter!
* @return ArrayList. Each item is file path to .class file *
* of a class that implements MarsTool. If none, returns empty list. * @return ArrayList. Each item is file path to .class file
*/ * of a class that implements MarsTool. If none, returns empty list.
public static ArrayList getExternalTools() { */
ArrayList toolsList = new ArrayList(); public static ArrayList getExternalTools() {
String delimiter = ";"; ArrayList toolsList = new ArrayList();
String tools = getPropertyEntry(configPropertiesFile,"ExternalTools"); String delimiter = ";";
if (tools != null) { String tools = getPropertyEntry(configPropertiesFile, "ExternalTools");
if (tools != null) {
StringTokenizer st = new StringTokenizer(tools, delimiter); StringTokenizer st = new StringTokenizer(tools, delimiter);
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
toolsList.add(st.nextToken()); toolsList.add(st.nextToken());
} }
} }
return toolsList; return toolsList;
} }
/** /**
* Read and return property file value (if any) for requested property. * Read and return property file value (if any) for requested property.
* @param propertiesFile name of properties file (do NOT include filename extension, *
* which is assumed to be ".properties") * @param propertiesFile name of properties file (do NOT include filename extension,
* @param propertyName String containing desired property name * which is assumed to be ".properties")
* @return String containing associated value; null if property not found * @param propertyName String containing desired property name
*/ * @return String containing associated value; null if property not found
public static String getPropertyEntry(String propertiesFile, String propertyName) { */
return PropertiesFile.loadPropertiesFromFile(propertiesFile).getProperty(propertyName); public static String getPropertyEntry(String propertiesFile, String propertyName) {
} return PropertiesFile.loadPropertiesFromFile(propertiesFile).getProperty(propertyName);
}
/** /**
* Read any syscall number assignment overrides from config file. * Read any syscall number assignment overrides from config file.
* @return ArrayList of SyscallNumberOverride objects *
*/ * @return ArrayList of SyscallNumberOverride objects
public ArrayList getSyscallOverrides() { */
ArrayList overrides = new ArrayList(); public ArrayList getSyscallOverrides() {
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile); ArrayList overrides = new ArrayList();
Enumeration keys = properties.keys(); Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile);
while (keys.hasMoreElements()) { Enumeration keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement(); String key = (String) keys.nextElement();
overrides.add(new SyscallNumberOverride(key,properties.getProperty(key))); overrides.add(new SyscallNumberOverride(key, properties.getProperty(key)));
} }
return overrides; return overrides;
} }
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+16 -12
View File
@@ -1,9 +1,13 @@
package mars.mips.hardware; package mars.mips.hardware;
import mars.*;
import mars.util.*; import mars.Globals;
import mars.simulator.*; import mars.ProgramStatement;
import mars.mips.instructions.*; import mars.Settings;
import java.util.*; import mars.mips.instructions.Instruction;
import mars.simulator.Exceptions;
import mars.util.Binary;
import java.util.*;
/* /*
Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2009, Pete Sanderson and Kenneth Vollmar
@@ -768,11 +772,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
value = fetchWordOrNullFromTable(stackBlockTable, relative); value = fetchWordOrNullFromTable(stackBlockTable, relative);
} }
else if (inTextSegment(address) || inKernelTextSegment(address)) { else if (inTextSegment(address) || inKernelTextSegment(address)) {
try { try {
value = (getStatementNoNotify(address) == null) ? null : new Integer(getStatementNoNotify(address).getBinaryStatement()); value = (getStatementNoNotify(address) == null) ? null : getStatementNoNotify(address).getBinaryStatement();
} } catch (AddressErrorException aee) {
catch (AddressErrorException aee) { value = null;
value = null; } }
} }
else if (inKernelDataSegment(address)) { else if (inKernelDataSegment(address)) {
// in kernel data segment // in kernel data segment
@@ -1382,7 +1386,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
else { else {
value = blockTable[block][offset]; value = blockTable[block][offset];
} }
return new Integer(value); return value;
} }
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
@@ -1,11 +1,25 @@
package mars.mips.instructions; package mars.mips.instructions;
import mars.simulator.*;
import mars.mips.hardware.*; import mars.Globals;
import mars.mips.instructions.syscalls.*; import mars.ProcessingException;
import mars.*; import mars.ProgramStatement;
import mars.util.*; import mars.mips.hardware.AddressErrorException;
import java.util.*; import mars.mips.hardware.Coprocessor0;
import java.io.*; import mars.mips.hardware.Coprocessor1;
import mars.mips.hardware.RegisterFile;
import mars.mips.instructions.syscalls.Syscall;
import mars.simulator.DelayedBranch;
import mars.simulator.Exceptions;
import mars.util.Binary;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
/* /*
Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar
@@ -1672,7 +1686,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
round = Integer.MAX_VALUE; round = Integer.MAX_VALUE;
} }
else { else {
Float floatObj = new Float(floatValue); Float floatObj = floatValue;
// If we are EXACTLY in the middle, then round to even! To determine this, // If we are EXACTLY in the middle, then round to even! To determine this,
// find next higher integer and next lower integer, then see if distances // find next higher integer and next lower integer, then see if distances
// are exactly equal. // are exactly equal.
@@ -1920,7 +1934,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
round = Integer.MAX_VALUE; round = Integer.MAX_VALUE;
} }
else { else {
Double doubleObj = new Double(doubleValue); Double doubleObj = doubleValue;
// If we are EXACTLY in the middle, then round to even! To determine this, // If we are EXACTLY in the middle, then round to even! To determine this,
// find next higher integer and next lower integer, then see if distances // find next higher integer and next lower integer, then see if distances
// are exactly equal. // are exactly equal.
@@ -1,7 +1,9 @@
package mars.mips.instructions.syscalls; package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*; import mars.ProcessingException;
import mars.*; import mars.ProgramStatement;
import mars.mips.hardware.Coprocessor1;
import mars.util.SystemIO;
/* /*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
@@ -45,11 +47,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
super(2, "PrintFloat"); super(2, "PrintFloat");
} }
/** /**
* Performs syscall function to display float whose bits are stored in $f12 * Performs syscall function to display float whose bits are stored in $f12
*/ */
public void simulate(ProgramStatement statement) throws ProcessingException { public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString(new Float(Float.intBitsToFloat( SystemIO.printString(Float.toString(Float.intBitsToFloat(
Coprocessor1.getValue(12))).toString()); Coprocessor1.getValue(12))));
} }
} }
@@ -1,7 +1,9 @@
package mars.mips.instructions.syscalls; package mars.mips.instructions.syscalls;
import mars.util.*;
import mars.mips.hardware.*; import mars.ProcessingException;
import mars.*; import mars.ProgramStatement;
import mars.mips.hardware.RegisterFile;
import mars.util.SystemIO;
/* /*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
@@ -50,7 +52,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Performs syscall function to print on the console the integer stored in $a0. * Performs syscall function to print on the console the integer stored in $a0.
*/ */
public void simulate(ProgramStatement statement) throws ProcessingException { public void simulate(ProgramStatement statement) throws ProcessingException {
SystemIO.printString( SystemIO.printString(
new Integer(RegisterFile.getValue(4)).toString()); Integer.toString(RegisterFile.getValue(4)));
} }
} }
+9 -8
View File
@@ -1,17 +1,18 @@
package mars.tools; package mars.tools;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;
import mars.Globals; import mars.Globals;
import mars.mips.hardware.AddressErrorException; import mars.mips.hardware.AddressErrorException;
import mars.mips.hardware.Coprocessor0; import mars.mips.hardware.Coprocessor0;
import mars.mips.hardware.Memory; import mars.mips.hardware.Memory;
import mars.mips.hardware.MemoryAccessNotice; import mars.mips.hardware.MemoryAccessNotice;
import mars.simulator.Exceptions;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;
@SuppressWarnings("serial") @SuppressWarnings("serial")
/* Add these two lines in exceptions.java file /* Add these two lines in exceptions.java file
* public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim * public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
@@ -19,7 +20,7 @@ import mars.simulator.Exceptions;
*/ */
/* /*
* Didier Teifreto LIFC Université de franche-Comté www.lifc.univ-fcomte.fr/~teifreto * Didier Teifreto LIFC Université de franche-Comté www.lifc.univ-fcomte.fr/~teifreto
* didier.teifreto@univ-fcomte.fr * didier.teifreto@univ-fcomte.fr
*/ */
public class DigitalLabSim extends AbstractMarsToolAndApplication { public class DigitalLabSim extends AbstractMarsToolAndApplication {
+43 -82
View File
@@ -1,62 +1,5 @@
package mars.tools; package mars.tools;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIManager;
//import java.util.Timer;
import javax.swing.event.InternalFrameEvent;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import mars.Globals; import mars.Globals;
import mars.ProgramStatement; import mars.ProgramStatement;
import mars.mips.hardware.AccessNotice; import mars.mips.hardware.AccessNotice;
@@ -69,6 +12,25 @@ import mars.venus.RunAssembleAction;
import mars.venus.RunBackstepAction; import mars.venus.RunBackstepAction;
import mars.venus.RunStepAction; import mars.venus.RunStepAction;
import mars.venus.VenusUI; import mars.venus.VenusUI;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Vector;
public class MipsXray extends AbstractMarsToolAndApplication{ public class MipsXray extends AbstractMarsToolAndApplication{
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@@ -117,31 +79,30 @@ public class MipsXray extends AbstractMarsToolAndApplication{
* Overrides default method, to provide a Help button for this tool/app. * Overrides default method, to provide a Help button for this tool/app.
*/ */
protected JComponent getHelpComponent() { protected JComponent getHelpComponent() {
final String helpContent = final String helpContent =
"This plugin is used to visualizate the behavior of mips processor using the default datapath. \n"+ "This plugin is used to visualizate the behavior of mips processor using the default datapath. \n" +
"It reads the source code instruction and generates an animation representing the inputs and \n"+ "It reads the source code instruction and generates an animation representing the inputs and \n" +
"outputs of functional blocks and the interconnection between them. The basic signals \n"+ "outputs of functional blocks and the interconnection between them. The basic signals \n" +
"represented are, control signals, opcode bits and data of functional blocks.\n"+ "represented are, control signals, opcode bits and data of functional blocks.\n" +
"\n"+ "\n" +
"Besides the datapath representation, information for each instruction is displayed below\n"+ "Besides the datapath representation, information for each instruction is displayed below\n" +
"the datapath. That display includes opcode value, with the correspondent colors used to\n"+ "the datapath. That display includes opcode value, with the correspondent colors used to\n" +
"represent the signals in datapath, mnemonic of the instruction processed at the moment, registers\n"+ "represent the signals in datapath, mnemonic of the instruction processed at the moment, registers\n" +
"used in the instruction and a label that indicates the color code used to represent control signals\n" + "used in the instruction and a label that indicates the color code used to represent control signals\n" +
"\n"+ "\n" +
"To see the datapath of register bank and control units click inside the functional unit.\n\n" + "To see the datapath of register bank and control units click inside the functional unit.\n\n" +
"Version 2.0\n" + "Version 2.0\n" +
"Developed by Márcio Roberto, Guilherme Sales, Fabrício Vivas, Flávio Cardeal and Fábio Lúcio\n" + "Developed by Márcio Roberto, Guilherme Sales, Fabrício Vivas, Flávio Cardeal and Fábio Lúcio\n" +
"Contact Marcio Roberto at marcio.rdaraujo@gmail.com with questions or comments.\n" "Contact Marcio Roberto at marcio.rdaraujo@gmail.com with questions or comments.\n";
; JButton help = new JButton("Help");
JButton help = new JButton("Help"); help.addActionListener(
help.addActionListener( new ActionListener() {
new ActionListener() { public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(theWindow, helpContent);
JOptionPane.showMessageDialog(theWindow, helpContent); }
} });
}); return help;
return help; }
}
/** /**
* Implementation of the inherited abstract method to build the main * Implementation of the inherited abstract method to build the main
* display area of the GUI. It will be placed in the CENTER area of a * display area of the GUI. It will be placed in the CENTER area of a
+33 -25
View File
@@ -1,15 +1,22 @@
package mars.venus; package mars.venus;
import mars.*;
import javax.swing.*; import mars.ErrorList;
import javax.swing.text.*; import mars.Globals;
import java.awt.*; import mars.simulator.Simulator;
import java.awt.event.*;
import java.util.concurrent.ArrayBlockingQueue; import javax.swing.*;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent;
import javax.swing.undo.UndoableEdit; import javax.swing.event.DocumentListener;
import mars.simulator.Simulator; import javax.swing.text.BadLocationException;
import javax.swing.event.DocumentEvent; import javax.swing.text.NavigationFilter;
import javax.swing.text.Position.Bias; import javax.swing.text.Position.Bias;
import javax.swing.undo.UndoableEdit;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.concurrent.ArrayBlockingQueue;
/* /*
Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
@@ -375,19 +382,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return asker.response(); return asker.response();
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Thread class for obtaining user input in the Run I/O window (MessagesPane) // Thread class for obtaining user input in the Run I/O window (MessagesPane)
// Written by Ricardo Fernández Pascual [rfernandez@ditec.um.es] December 2009. // Written by Ricardo Fernández Pascual [rfernandez@ditec.um.es] December 2009.
class Asker implements Runnable { class Asker implements Runnable {
ArrayBlockingQueue<String> resultQueue = new ArrayBlockingQueue<String>(1); ArrayBlockingQueue<String> resultQueue = new ArrayBlockingQueue<String>(1);
int initialPos; int initialPos;
int maxLen; int maxLen;
Asker(int maxLen) { final DocumentListener listener =
this.maxLen = maxLen; new DocumentListener() {
// initialPos will be set in run()
}
final DocumentListener listener =
new DocumentListener() {
public void insertUpdate(final DocumentEvent e) { public void insertUpdate(final DocumentEvent e) {
EventQueue.invokeLater( EventQueue.invokeLater(
new Runnable() { new Runnable() {
@@ -430,6 +433,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
} }
public void changedUpdate(DocumentEvent e) { } public void changedUpdate(DocumentEvent e) { }
}; };
Asker(int maxLen) {
this.maxLen = maxLen;
// initialPos will be set in run()
}
final NavigationFilter navigationFilter = final NavigationFilter navigationFilter =
new NavigationFilter() { new NavigationFilter() {
public void moveDot(FilterBypass fb, int dot, Bias bias) { public void moveDot(FilterBypass fb, int dot, Bias bias) {
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More