[O] Refactor
This commit is contained in:
@@ -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
|
||||
@@ -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
@@ -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 {
|
||||
// Apply the application plugin to add support for building a CLI application in Java.
|
||||
id 'application'
|
||||
@@ -34,5 +25,5 @@ testing {
|
||||
|
||||
application {
|
||||
// Define the main class for the application.
|
||||
mainClass = 'mars.assembler.App'
|
||||
mainClass = 'Mars'
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,11 +1 @@
|
||||
/*
|
||||
* 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'
|
||||
rootProject.name = 'MARS'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
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
|
||||
**/
|
||||
|
||||
public class Mars {
|
||||
public static void main(String[] args) {
|
||||
new mars.MarsLaunch(args);
|
||||
}
|
||||
}
|
||||
public class Mars {
|
||||
public static void main(String[] args) {
|
||||
new mars.MarsLaunch(args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Main-Class: Mars
|
||||
Class-Path: .
|
||||
+222
-176
@@ -1,12 +1,16 @@
|
||||
package mars;
|
||||
import mars.mips.instructions.syscalls.*;
|
||||
import mars.mips.instructions.*;
|
||||
import mars.mips.hardware.*;
|
||||
import mars.assembler.*;
|
||||
import mars.venus.*;
|
||||
import mars.util.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
package mars;
|
||||
|
||||
import mars.assembler.SymbolTable;
|
||||
import mars.mips.hardware.Memory;
|
||||
import mars.mips.instructions.InstructionSet;
|
||||
import mars.mips.instructions.syscalls.SyscallNumberOverride;
|
||||
import mars.util.PropertiesFile;
|
||||
import mars.venus.VenusUI;
|
||||
|
||||
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
|
||||
@@ -42,84 +46,123 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* @author Pete Sanderson
|
||||
* @version August 2003
|
||||
*/
|
||||
public class Globals
|
||||
{
|
||||
// List these first because they are referenced by methods called at initialization.
|
||||
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 */
|
||||
public class Globals {
|
||||
/**
|
||||
* Path to folder that contains images
|
||||
*/
|
||||
// The leading "/" in filepath prevents package name from being pre-pended.
|
||||
public static final String imagesPath = "/images/";
|
||||
/** Path to folder that contains help text */
|
||||
public static final String helpPath = "/help/";
|
||||
/* Flag that indicates whether or not instructionSet has been initialized. */
|
||||
private static boolean initialized = false;
|
||||
public static final String imagesPath = "/images/";
|
||||
/**
|
||||
* Path to folder that contains help text
|
||||
*/
|
||||
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. */
|
||||
static VenusUI gui = null;
|
||||
/** The current MARS version number. Can't wait for "initialize()" call to get it. */
|
||||
public static final String version = "4.5";
|
||||
/** List of accepted file extensions for MIPS assembly source files. */
|
||||
public static final ArrayList fileExtensions = getFileExtensions();
|
||||
/** Maximum length of scrolled message window (MARS Messages and Run I/O) */
|
||||
public static final int maximumMessageCharacters = getMessageLimit();
|
||||
/** Maximum number of assembler errors produced by one assemble operation */
|
||||
public static final int maximumErrorMessages = getErrorLimit();
|
||||
/** Maximum number of back-step operations to buffer */
|
||||
public static final int maximumBacksteps = getBackstepLimit();
|
||||
/** MARS copyright years */
|
||||
public static final String copyrightYears = getCopyrightYears();
|
||||
/** MARS copyright holders */
|
||||
public static final String copyrightHolders = getCopyrightHolders();
|
||||
/** 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();
|
||||
/** MARS exit code -- useful with SYSCALL 17 when running from command line (not GUI) */
|
||||
public static int exitCode = 0;
|
||||
static VenusUI gui = null;
|
||||
// List these first because they are referenced by methods called at initialization.
|
||||
private static final String configPropertiesFile = "Config";
|
||||
/**
|
||||
* List of accepted file extensions for MIPS assembly source files.
|
||||
*/
|
||||
public static final ArrayList fileExtensions = getFileExtensions();
|
||||
/**
|
||||
* Maximum length of scrolled message window (MARS Messages and Run I/O)
|
||||
*/
|
||||
public static final int maximumMessageCharacters = getMessageLimit();
|
||||
/**
|
||||
* Maximum number of assembler errors produced by one assemble operation
|
||||
*/
|
||||
public static final int maximumErrorMessages = getErrorLimit();
|
||||
/**
|
||||
* Maximum number of back-step operations to buffer
|
||||
*/
|
||||
public static final int maximumBacksteps = getBackstepLimit();
|
||||
/**
|
||||
* 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() {
|
||||
return "2003-2014";
|
||||
}
|
||||
private static String getCopyrightHolders() {
|
||||
return "Pete Sanderson and Kenneth Vollmar";
|
||||
}
|
||||
private static String getCopyrightHolders() {
|
||||
return "Pete Sanderson and Kenneth Vollmar";
|
||||
}
|
||||
|
||||
public static void setGui(VenusUI g) {
|
||||
gui = g;
|
||||
}
|
||||
public static VenusUI getGui() {
|
||||
return gui;
|
||||
}
|
||||
public static VenusUI getGui() {
|
||||
return gui;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
public static void setGui(VenusUI g) {
|
||||
gui = g;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called once upon system initialization to create the global data structures.
|
||||
**/
|
||||
|
||||
public static void initialize(boolean gui) {
|
||||
if (!initialized) {
|
||||
public static void initialize(boolean gui) {
|
||||
if (!initialized) {
|
||||
memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory
|
||||
instructionSet = new InstructionSet();
|
||||
instructionSet.populate();
|
||||
@@ -127,123 +170,126 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
settings = new Settings(gui);
|
||||
initialized = true;
|
||||
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.
|
||||
private static int getMessageLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "MessageLimit", 1000000);
|
||||
}
|
||||
// Read byte limit of Run I/O or MARS Messages text to buffer.
|
||||
private static int getMessageLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "MessageLimit", 1000000);
|
||||
}
|
||||
|
||||
// Read limit on number of error messages produced by one assemble operation.
|
||||
private static int getErrorLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "ErrorLimit", 200);
|
||||
}
|
||||
// Read limit on number of error messages produced by one assemble operation.
|
||||
private static int getErrorLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "ErrorLimit", 200);
|
||||
}
|
||||
|
||||
// Read backstep limit (number of operations to buffer) from properties file.
|
||||
private static int getBackstepLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "BackstepLimit", 1000);
|
||||
}
|
||||
// Read backstep limit (number of operations to buffer) from properties file.
|
||||
private static int getBackstepLimit() {
|
||||
return getIntegerProperty(configPropertiesFile, "BackstepLimit", 1000);
|
||||
}
|
||||
|
||||
// Read ASCII default display character for non-printing characters, from properties file.
|
||||
public static String getAsciiNonPrint() {
|
||||
String anp = getPropertyEntry(configPropertiesFile, "AsciiNonPrint");
|
||||
return (anp == null) ? "." : ( (anp.equals("space")) ? " " : anp );
|
||||
}
|
||||
// Read ASCII default display character for non-printing characters, from properties file.
|
||||
public static String getAsciiNonPrint() {
|
||||
String anp = getPropertyEntry(configPropertiesFile, "AsciiNonPrint");
|
||||
return (anp == null) ? "." : ((anp.equals("space")) ? " " : anp);
|
||||
}
|
||||
|
||||
// Read ASCII strings for codes 0-255, from properties file. If string
|
||||
// value is "null", substitute value of ASCII_NON_PRINT. If string is
|
||||
// "space", substitute string containing one space character.
|
||||
public static String[] getAsciiStrings() {
|
||||
String let = getPropertyEntry(configPropertiesFile,"AsciiTable");
|
||||
String placeHolder = getAsciiNonPrint();
|
||||
String[] lets = let.split(" +");
|
||||
int maxLength = 0;
|
||||
for (int i = 0; i < lets.length; i++) {
|
||||
if (lets[i].equals("null")) lets[i] = placeHolder;
|
||||
if (lets[i].equals("space")) lets[i] = " ";
|
||||
if (lets[i].length() > maxLength) maxLength = lets[i].length();
|
||||
}
|
||||
String padding = " ";
|
||||
maxLength++;
|
||||
for (int i = 0; i < lets.length; i++) {
|
||||
lets[i] = padding.substring(0,maxLength-lets[i].length()) + lets[i];
|
||||
}
|
||||
return lets;
|
||||
}
|
||||
// Read ASCII strings for codes 0-255, from properties file. If string
|
||||
// value is "null", substitute value of ASCII_NON_PRINT. If string is
|
||||
// "space", substitute string containing one space character.
|
||||
public static String[] getAsciiStrings() {
|
||||
String let = getPropertyEntry(configPropertiesFile, "AsciiTable");
|
||||
String placeHolder = getAsciiNonPrint();
|
||||
String[] lets = let.split(" +");
|
||||
int maxLength = 0;
|
||||
for (int i = 0; i < lets.length; i++) {
|
||||
if (lets[i].equals("null")) lets[i] = placeHolder;
|
||||
if (lets[i].equals("space")) lets[i] = " ";
|
||||
if (lets[i].length() > maxLength) maxLength = lets[i].length();
|
||||
}
|
||||
String padding = " ";
|
||||
maxLength++;
|
||||
for (int i = 0; i < lets.length; i++) {
|
||||
lets[i] = padding.substring(0, maxLength - lets[i].length()) + lets[i];
|
||||
}
|
||||
return lets;
|
||||
}
|
||||
|
||||
// Read and return integer property value for given file and property name.
|
||||
// Default value is returned if property file or name not found.
|
||||
private static int getIntegerProperty(String propertiesFile, String propertyName, int defaultValue) {
|
||||
int limit = defaultValue; // just in case no entry is found
|
||||
Properties properties = PropertiesFile.loadPropertiesFromFile(propertiesFile);
|
||||
try {
|
||||
// Read and return integer property value for given file and property name.
|
||||
// Default value is returned if property file or name not found.
|
||||
private static int getIntegerProperty(String propertiesFile, String propertyName, int defaultValue) {
|
||||
int limit = defaultValue; // just in case no entry is found
|
||||
Properties properties = PropertiesFile.loadPropertiesFromFile(propertiesFile);
|
||||
try {
|
||||
limit = Integer.parseInt(properties.getProperty(propertyName, Integer.toString(defaultValue)));
|
||||
}
|
||||
catch (NumberFormatException nfe) { } // do nothing, I already have a default
|
||||
return limit;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
} // do nothing, I already have a default
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
||||
// Read assembly language file extensions from properties file. Resulting
|
||||
// string is tokenized into array list (assume StringTokenizer default delimiters).
|
||||
private static ArrayList getFileExtensions() {
|
||||
ArrayList extensionsList = new ArrayList();
|
||||
String extensions = getPropertyEntry(configPropertiesFile,"Extensions");
|
||||
if (extensions != null) {
|
||||
// Read assembly language file extensions from properties file. Resulting
|
||||
// string is tokenized into array list (assume StringTokenizer default delimiters).
|
||||
private static ArrayList getFileExtensions() {
|
||||
ArrayList extensionsList = new ArrayList();
|
||||
String extensions = getPropertyEntry(configPropertiesFile, "Extensions");
|
||||
if (extensions != null) {
|
||||
StringTokenizer st = new StringTokenizer(extensions);
|
||||
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.
|
||||
* Currently this is done by adding the tool's path name to the list
|
||||
* 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.
|
||||
*/
|
||||
public static ArrayList getExternalTools() {
|
||||
ArrayList toolsList = new ArrayList();
|
||||
String delimiter = ";";
|
||||
String tools = getPropertyEntry(configPropertiesFile,"ExternalTools");
|
||||
if (tools != null) {
|
||||
/**
|
||||
* Get list of MarsTools that reside outside the MARS distribution.
|
||||
* Currently this is done by adding the tool's path name to the list
|
||||
* 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.
|
||||
*/
|
||||
public static ArrayList getExternalTools() {
|
||||
ArrayList toolsList = new ArrayList();
|
||||
String delimiter = ";";
|
||||
String tools = getPropertyEntry(configPropertiesFile, "ExternalTools");
|
||||
if (tools != null) {
|
||||
StringTokenizer st = new StringTokenizer(tools, delimiter);
|
||||
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.
|
||||
* @param propertiesFile name of properties file (do NOT include filename extension,
|
||||
* which is assumed to be ".properties")
|
||||
* @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);
|
||||
}
|
||||
/**
|
||||
* 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 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read any syscall number assignment overrides from config file.
|
||||
* @return ArrayList of SyscallNumberOverride objects
|
||||
*/
|
||||
public ArrayList getSyscallOverrides() {
|
||||
ArrayList overrides = new ArrayList();
|
||||
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile);
|
||||
Enumeration keys = properties.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
/**
|
||||
* Read any syscall number assignment overrides from config file.
|
||||
*
|
||||
* @return ArrayList of SyscallNumberOverride objects
|
||||
*/
|
||||
public ArrayList getSyscallOverrides() {
|
||||
ArrayList overrides = new ArrayList();
|
||||
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile);
|
||||
Enumeration keys = properties.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String key = (String) keys.nextElement();
|
||||
overrides.add(new SyscallNumberOverride(key,properties.getProperty(key)));
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
overrides.add(new SyscallNumberOverride(key, properties.getProperty(key)));
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1283
-1212
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,13 @@
|
||||
package mars.mips.hardware;
|
||||
import mars.*;
|
||||
import mars.util.*;
|
||||
import mars.simulator.*;
|
||||
import mars.mips.instructions.*;
|
||||
import java.util.*;
|
||||
package mars.mips.hardware;
|
||||
|
||||
import mars.Globals;
|
||||
import mars.ProgramStatement;
|
||||
import mars.Settings;
|
||||
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
|
||||
@@ -768,11 +772,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
value = fetchWordOrNullFromTable(stackBlockTable, relative);
|
||||
}
|
||||
else if (inTextSegment(address) || inKernelTextSegment(address)) {
|
||||
try {
|
||||
value = (getStatementNoNotify(address) == null) ? null : new Integer(getStatementNoNotify(address).getBinaryStatement());
|
||||
}
|
||||
catch (AddressErrorException aee) {
|
||||
value = null; }
|
||||
try {
|
||||
value = (getStatementNoNotify(address) == null) ? null : getStatementNoNotify(address).getBinaryStatement();
|
||||
} catch (AddressErrorException aee) {
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
else if (inKernelDataSegment(address)) {
|
||||
// in kernel data segment
|
||||
@@ -1382,7 +1386,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
else {
|
||||
value = blockTable[block][offset];
|
||||
}
|
||||
return new Integer(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
package mars.mips.instructions;
|
||||
import mars.simulator.*;
|
||||
import mars.mips.hardware.*;
|
||||
import mars.mips.instructions.syscalls.*;
|
||||
import mars.*;
|
||||
import mars.util.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
package mars.mips.instructions;
|
||||
|
||||
import mars.Globals;
|
||||
import mars.ProcessingException;
|
||||
import mars.ProgramStatement;
|
||||
import mars.mips.hardware.AddressErrorException;
|
||||
import mars.mips.hardware.Coprocessor0;
|
||||
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
|
||||
@@ -1672,7 +1686,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
round = Integer.MAX_VALUE;
|
||||
}
|
||||
else {
|
||||
Float floatObj = new Float(floatValue);
|
||||
Float floatObj = floatValue;
|
||||
// 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
|
||||
// are exactly equal.
|
||||
@@ -1920,7 +1934,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
round = Integer.MAX_VALUE;
|
||||
}
|
||||
else {
|
||||
Double doubleObj = new Double(doubleValue);
|
||||
Double doubleObj = doubleValue;
|
||||
// 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
|
||||
// are exactly equal.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package mars.mips.instructions.syscalls;
|
||||
import mars.util.*;
|
||||
import mars.mips.hardware.*;
|
||||
import mars.*;
|
||||
package mars.mips.instructions.syscalls;
|
||||
|
||||
import mars.ProcessingException;
|
||||
import mars.ProgramStatement;
|
||||
import mars.mips.hardware.Coprocessor1;
|
||||
import mars.util.SystemIO;
|
||||
|
||||
/*
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs syscall function to display float whose bits are stored in $f12
|
||||
*/
|
||||
public void simulate(ProgramStatement statement) throws ProcessingException {
|
||||
SystemIO.printString(new Float(Float.intBitsToFloat(
|
||||
Coprocessor1.getValue(12))).toString());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Performs syscall function to display float whose bits are stored in $f12
|
||||
*/
|
||||
public void simulate(ProgramStatement statement) throws ProcessingException {
|
||||
SystemIO.printString(Float.toString(Float.intBitsToFloat(
|
||||
Coprocessor1.getValue(12))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package mars.mips.instructions.syscalls;
|
||||
import mars.util.*;
|
||||
import mars.mips.hardware.*;
|
||||
import mars.*;
|
||||
package mars.mips.instructions.syscalls;
|
||||
|
||||
import mars.ProcessingException;
|
||||
import mars.ProgramStatement;
|
||||
import mars.mips.hardware.RegisterFile;
|
||||
import mars.util.SystemIO;
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
public void simulate(ProgramStatement statement) throws ProcessingException {
|
||||
SystemIO.printString(
|
||||
new Integer(RegisterFile.getValue(4)).toString());
|
||||
}
|
||||
SystemIO.printString(
|
||||
Integer.toString(RegisterFile.getValue(4)));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
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.mips.hardware.AddressErrorException;
|
||||
import mars.mips.hardware.Coprocessor0;
|
||||
import mars.mips.hardware.Memory;
|
||||
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")
|
||||
/* Add these two lines in exceptions.java file
|
||||
* 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
|
||||
*/
|
||||
public class DigitalLabSim extends AbstractMarsToolAndApplication {
|
||||
|
||||
@@ -1,62 +1,5 @@
|
||||
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.ProgramStatement;
|
||||
import mars.mips.hardware.AccessNotice;
|
||||
@@ -69,6 +12,25 @@ import mars.venus.RunAssembleAction;
|
||||
import mars.venus.RunBackstepAction;
|
||||
import mars.venus.RunStepAction;
|
||||
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{
|
||||
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.
|
||||
*/
|
||||
protected JComponent getHelpComponent() {
|
||||
final String helpContent =
|
||||
"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"+
|
||||
"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"+
|
||||
"\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"+
|
||||
"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" +
|
||||
"\n"+
|
||||
"To see the datapath of register bank and control units click inside the functional unit.\n\n" +
|
||||
"Version 2.0\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"
|
||||
;
|
||||
JButton help = new JButton("Help");
|
||||
help.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JOptionPane.showMessageDialog(theWindow, helpContent);
|
||||
}
|
||||
});
|
||||
return help;
|
||||
}
|
||||
final String helpContent =
|
||||
"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" +
|
||||
"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" +
|
||||
"\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" +
|
||||
"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" +
|
||||
"\n" +
|
||||
"To see the datapath of register bank and control units click inside the functional unit.\n\n" +
|
||||
"Version 2.0\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";
|
||||
JButton help = new JButton("Help");
|
||||
help.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JOptionPane.showMessageDialog(theWindow, helpContent);
|
||||
}
|
||||
});
|
||||
return help;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package mars.venus;
|
||||
import mars.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.undo.UndoableEdit;
|
||||
import mars.simulator.Simulator;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.Position.Bias;
|
||||
package mars.venus;
|
||||
|
||||
import mars.ErrorList;
|
||||
import mars.Globals;
|
||||
import mars.simulator.Simulator;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.NavigationFilter;
|
||||
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
|
||||
@@ -375,19 +382,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
return asker.response();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
class Asker implements Runnable {
|
||||
ArrayBlockingQueue<String> resultQueue = new ArrayBlockingQueue<String>(1);
|
||||
int initialPos;
|
||||
int maxLen;
|
||||
Asker(int maxLen) {
|
||||
this.maxLen = maxLen;
|
||||
// initialPos will be set in run()
|
||||
}
|
||||
final DocumentListener listener =
|
||||
new DocumentListener() {
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
class Asker implements Runnable {
|
||||
ArrayBlockingQueue<String> resultQueue = new ArrayBlockingQueue<String>(1);
|
||||
int initialPos;
|
||||
int maxLen;
|
||||
final DocumentListener listener =
|
||||
new DocumentListener() {
|
||||
public void insertUpdate(final DocumentEvent e) {
|
||||
EventQueue.invokeLater(
|
||||
new Runnable() {
|
||||
@@ -430,6 +433,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
}
|
||||
public void changedUpdate(DocumentEvent e) { }
|
||||
};
|
||||
|
||||
Asker(int maxLen) {
|
||||
this.maxLen = maxLen;
|
||||
// initialPos will be set in run()
|
||||
}
|
||||
final NavigationFilter navigationFilter =
|
||||
new NavigationFilter() {
|
||||
public void moveDot(FilterBypass fb, int dot, Bias bias) {
|
||||
|
||||
+884
-1055
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
Reference in New Issue
Block a user