[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'
+6 -7
View File
@@ -1,4 +1,3 @@
/* /*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
@@ -29,14 +28,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/** /**
* Portal to Mars * Portal to Mars
* *
* @author Pete Sanderson * @author Pete Sanderson
* @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: .
+250 -204
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
@@ -38,212 +42,254 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/** /**
* Collection of globally-available data structures. * Collection of globally-available data structures.
* *
* @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 boolean runSpeedPanelExists = false; public static final String ASCII_NON_PRINT = getAsciiNonPrint();
/**
private static String getCopyrightYears() { * Array of strings to display for ASCII codes in ASCII display of data segment. ASCII code 0-255 is array index.
return "2003-2014"; */
} public static final String[] ASCII_TABLE = getAsciiStrings();
private static String getCopyrightHolders() { private static final String syscallPropertiesFile = "Syscall";
return "Pete Sanderson and Kenneth Vollmar"; /* Flag that indicates whether or not instructionSet has been initialized. */
} private static boolean initialized = false;
public static void setGui(VenusUI g) { private static String getCopyrightYears() {
gui = g; return "2003-2014";
} }
public static VenusUI getGui() {
return gui; private static String getCopyrightHolders() {
} return "Pete Sanderson and Kenneth Vollmar";
}
public static Settings getSettings() {
return settings; public static VenusUI getGui() {
} return gui;
}
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. * 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();
symbolTable = new SymbolTable("global"); symbolTable = new SymbolTable("global");
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");
StringTokenizer st = new StringTokenizer(tools, delimiter); if (tools != null) {
while (st.hasMoreTokens()) { StringTokenizer st = new StringTokenizer(tools, delimiter);
toolsList.add(st.nextToken()); while (st.hasMoreTokens()) {
} 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, * Read and return property file value (if any) for requested property.
* which is assumed to be ".properties") *
* @param propertyName String containing desired property name * @param propertiesFile name of properties file (do NOT include filename extension,
* @return String containing associated value; null if property not found * which is assumed to be ".properties")
*/ * @param propertyName String containing desired property name
public static String getPropertyEntry(String propertiesFile, String propertyName) { * @return String containing associated value; null if property not found
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.
* @return ArrayList of SyscallNumberOverride objects /**
*/ * Read any syscall number assignment overrides from config file.
public ArrayList getSyscallOverrides() { *
ArrayList overrides = new ArrayList(); * @return ArrayList of SyscallNumberOverride objects
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile); */
Enumeration keys = properties.keys(); public ArrayList getSyscallOverrides() {
while (keys.hasMoreElements()) { ArrayList overrides = new ArrayList();
Properties properties = PropertiesFile.loadPropertiesFromFile(syscallPropertiesFile);
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
@@ -44,12 +46,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
public SyscallPrintFloat() { public SyscallPrintFloat() {
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)));
} }
} }
+357 -356
View File
@@ -1,356 +1,357 @@
package mars.tools; package mars.tools;
import java.awt.*;
import java.awt.event.*; import mars.Globals;
import java.util.*; import mars.mips.hardware.AddressErrorException;
import mars.mips.hardware.Coprocessor0;
import javax.swing.*; import mars.mips.hardware.Memory;
import javax.swing.Timer; import mars.mips.hardware.MemoryAccessNotice;
import mars.Globals; import javax.swing.*;
import mars.mips.hardware.AddressErrorException; import java.awt.*;
import mars.mips.hardware.Coprocessor0; import java.awt.event.ActionEvent;
import mars.mips.hardware.Memory; import java.awt.event.ActionListener;
import mars.mips.hardware.MemoryAccessNotice; import java.awt.event.MouseEvent;
import mars.simulator.Exceptions; import java.awt.event.MouseListener;
@SuppressWarnings("serial") import java.util.Observable;
/* Add these two lines in exceptions.java file @SuppressWarnings("serial")
* public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim /* Add these two lines in exceptions.java file
* public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim * public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
*/ * public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim
*/
/*
* Didier Teifreto LIFC Université de franche-Comté www.lifc.univ-fcomte.fr/~teifreto /*
* didier.teifreto@univ-fcomte.fr * Didier Teifreto LIFC Université de franche-Comté www.lifc.univ-fcomte.fr/~teifreto
*/ * didier.teifreto@univ-fcomte.fr
public class DigitalLabSim extends AbstractMarsToolAndApplication { */
private static String heading = "Digital Lab Sim"; public class DigitalLabSim extends AbstractMarsToolAndApplication {
private static String version = " Version 1.0 (Didier Teifreto)"; private static String heading = "Digital Lab Sim";
private static final int IN_ADRESS_DISPLAY_1=Memory.memoryMapBaseAddress+0x10; private static String version = " Version 1.0 (Didier Teifreto)";
private static final int IN_ADRESS_DISPLAY_2=Memory.memoryMapBaseAddress+0x11; private static final int IN_ADRESS_DISPLAY_1=Memory.memoryMapBaseAddress+0x10;
private static final int IN_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x12; private static final int IN_ADRESS_DISPLAY_2=Memory.memoryMapBaseAddress+0x11;
private static final int IN_ADRESS_COUNTER=Memory.memoryMapBaseAddress+0x13; private static final int IN_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x12;
private static final int OUT_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x14; private static final int IN_ADRESS_COUNTER=Memory.memoryMapBaseAddress+0x13;
private static final int OUT_ADRESS_HEXA_KEYBOARD=Memory.memoryMapBaseAddress+0x14;
public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim public static final int EXTERNAL_INTERRUPT_TIMER = 0x00000100; //Add for digital Lab Sim
public static final int EXTERNAL_INTERRUPT_HEXA_KEYBOARD = 0x00000200;// Add for digital Lab Sim
// GUI Interface.
private static JPanel panelTools; // GUI Interface.
// Seven Segment display private static JPanel panelTools;
private SevenSegmentPanel sevenSegPanel; // Seven Segment display
// Keyboard private SevenSegmentPanel sevenSegPanel;
private static int KeyBoardValueButtonClick=-1; // -1 no button click // Keyboard
private HexaKeyboard hexaKeyPanel; private static int KeyBoardValueButtonClick=-1; // -1 no button click
private static boolean KeyboardInterruptOnOff=false; private HexaKeyboard hexaKeyPanel;
// Counter private static boolean KeyboardInterruptOnOff=false;
private static int CounterValueMax=30; // Counter
private static int CounterValue=CounterValueMax; private static int CounterValueMax=30;
private static boolean CounterInterruptOnOff=false; private static int CounterValue=CounterValueMax;
private static OneSecondCounter SecondCounter; private static boolean CounterInterruptOnOff=false;
private static OneSecondCounter SecondCounter;
public DigitalLabSim(String title, String heading) {
super(title,heading); public DigitalLabSim(String title, String heading) {
} super(title,heading);
public DigitalLabSim() { }
super (heading+", "+version, heading); public DigitalLabSim() {
} super (heading+", "+version, heading);
public static void main(String[] args) { }
new DigitalLabSim(heading+", "+version,heading).go(); public static void main(String[] args) {
} new DigitalLabSim(heading+", "+version,heading).go();
public String getName() { }
return "Digital Lab Sim"; public String getName() {
} return "Digital Lab Sim";
protected void addAsObserver(){ }
addAsObserver(IN_ADRESS_DISPLAY_1, IN_ADRESS_DISPLAY_1); protected void addAsObserver(){
addAsObserver(Memory.textBaseAddress, Memory.textLimitAddress); addAsObserver(IN_ADRESS_DISPLAY_1, IN_ADRESS_DISPLAY_1);
} addAsObserver(Memory.textBaseAddress, Memory.textLimitAddress);
public void update(Observable ressource, Object accessNotice){ }
MemoryAccessNotice notice = (MemoryAccessNotice) accessNotice; public void update(Observable ressource, Object accessNotice){
int address=notice.getAddress(); MemoryAccessNotice notice = (MemoryAccessNotice) accessNotice;
char value=(char)notice.getValue(); int address=notice.getAddress();
if(address == IN_ADRESS_DISPLAY_1) char value=(char)notice.getValue();
updateSevenSegment(1, value); if(address == IN_ADRESS_DISPLAY_1)
else updateSevenSegment(1, value);
if (address == IN_ADRESS_DISPLAY_2) else
updateSevenSegment(0, value); if (address == IN_ADRESS_DISPLAY_2)
else updateSevenSegment(0, value);
if (address == IN_ADRESS_HEXA_KEYBOARD) else
updateHexaKeyboard(value); if (address == IN_ADRESS_HEXA_KEYBOARD)
else updateHexaKeyboard(value);
if (address == IN_ADRESS_COUNTER) else
updateOneSecondCounter(value); if (address == IN_ADRESS_COUNTER)
if (CounterInterruptOnOff) updateOneSecondCounter(value);
if (CounterValue >0){ if (CounterInterruptOnOff)
CounterValue--; if (CounterValue >0){
} CounterValue--;
else{ }
CounterValue=CounterValueMax; else{
if((Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){ CounterValue=CounterValueMax;
mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_TIMER; if((Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){
} mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_TIMER;
} }
} }
protected void reset(){ }
sevenSegPanel.resetSevenSegment(); protected void reset(){
hexaKeyPanel.resetHexaKeyboard(); sevenSegPanel.resetSevenSegment();
SecondCounter.resetOneSecondCounter(); hexaKeyPanel.resetHexaKeyboard();
} SecondCounter.resetOneSecondCounter();
protected JComponent buildMainDisplayArea() { }
panelTools=new JPanel(new GridLayout(1,2)); protected JComponent buildMainDisplayArea() {
sevenSegPanel=new SevenSegmentPanel(); panelTools=new JPanel(new GridLayout(1,2));
panelTools.add(sevenSegPanel); sevenSegPanel=new SevenSegmentPanel();
hexaKeyPanel = new HexaKeyboard(); panelTools.add(sevenSegPanel);
panelTools.add(hexaKeyPanel); hexaKeyPanel = new HexaKeyboard();
SecondCounter= new OneSecondCounter(); panelTools.add(hexaKeyPanel);
return panelTools; SecondCounter= new OneSecondCounter();
} return panelTools;
private synchronized void updateMMIOControlAndData(int dataAddr, int dataValue) { }
if (!this.isBeingUsedAsAMarsTool || (this.isBeingUsedAsAMarsTool && connectButton.isConnected())) { private synchronized void updateMMIOControlAndData(int dataAddr, int dataValue) {
synchronized (Globals.memoryAndRegistersLock) { if (!this.isBeingUsedAsAMarsTool || (this.isBeingUsedAsAMarsTool && connectButton.isConnected())) {
try { synchronized (Globals.memoryAndRegistersLock) {
Globals.memory.setByte(dataAddr, dataValue); try {
} Globals.memory.setByte(dataAddr, dataValue);
catch (AddressErrorException aee) { }
System.out.println("Tool author specified incorrect MMIO address!"+aee); catch (AddressErrorException aee) {
System.exit(0); System.out.println("Tool author specified incorrect MMIO address!"+aee);
} System.exit(0);
} }
if (Globals.getGui() != null && Globals.getGui().getMainPane().getExecutePane().getTextSegmentWindow().getCodeHighlighting() ) { }
Globals.getGui().getMainPane().getExecutePane().getDataSegmentWindow().updateValues(); if (Globals.getGui() != null && Globals.getGui().getMainPane().getExecutePane().getTextSegmentWindow().getCodeHighlighting() ) {
} Globals.getGui().getMainPane().getExecutePane().getDataSegmentWindow().updateValues();
} }
} }
protected JComponent getHelpComponent() { }
final String helpContent = protected JComponent getHelpComponent() {
" This tool is composed of 3 parts : two seven-segment displays, an hexadecimal keyboard and counter \n"+ final String helpContent =
"Seven segment display\n"+ " This tool is composed of 3 parts : two seven-segment displays, an hexadecimal keyboard and counter \n"+
" Byte value at address 0xFFFF0010 : command right seven segment display \n "+ "Seven segment display\n"+
" Byte value at address 0xFFFF0011 : command left seven segment display \n "+ " Byte value at address 0xFFFF0010 : command right seven segment display \n "+
" Each bit of these two bytes are connected to segments (bit 0 for a segment, 1 for b segment and 7 for point \n \n"+ " Byte value at address 0xFFFF0011 : command left seven segment display \n "+
"Hexadecimal keyboard\n"+ " Each bit of these two bytes are connected to segments (bit 0 for a segment, 1 for b segment and 7 for point \n \n"+
" Byte value at address 0xFFFF0012 : command row number of hexadecimal keyboard (bit 0 to 3) and enable keyboard interrupt (bit 7) \n" + "Hexadecimal keyboard\n"+
" Byte value at address 0xFFFF0014 : receive row and column of the key pressed, 0 if not key pressed \n"+ " Byte value at address 0xFFFF0012 : command row number of hexadecimal keyboard (bit 0 to 3) and enable keyboard interrupt (bit 7) \n" +
" The mips program have to scan, one by one, each row (send 1,2,4,8...)"+ " Byte value at address 0xFFFF0014 : receive row and column of the key pressed, 0 if not key pressed \n"+
" and then observe if a key is pressed (that mean byte value at adresse 0xFFFF0014 is different from zero). "+ " The mips program have to scan, one by one, each row (send 1,2,4,8...)"+
" This byte value is composed of row number (4 left bits) and column number (4 right bits)"+ " and then observe if a key is pressed (that mean byte value at adresse 0xFFFF0014 is different from zero). "+
" Here you'll find the code for each key : 0x11,0x21,0x41,0x81,0x12,0x22,0x42,0x82,0x14,0x24,0x44,0x84,0x18,0x28,0x48,0x88. \n"+ " This byte value is composed of row number (4 left bits) and column number (4 right bits)"+
" For exemple key number 2 return 0x41, that mean the key is on column 3 and row 1. \n"+ " Here you'll find the code for each key : 0x11,0x21,0x41,0x81,0x12,0x22,0x42,0x82,0x14,0x24,0x44,0x84,0x18,0x28,0x48,0x88. \n"+
" If keyboard interruption is enable, an exception is started, with cause register bit number 11 set.\n \n"+ " For exemple key number 2 return 0x41, that mean the key is on column 3 and row 1. \n"+
"Counter\n"+ " If keyboard interruption is enable, an exception is started, with cause register bit number 11 set.\n \n"+
" Byte value at address 0xFFFF0013 : If one bit of this byte is set, the counter interruption is enable.\n"+ "Counter\n"+
" If counter interruption is enable, every 30 instructions, an exception is started with cause register bit number 10.\n" + " Byte value at address 0xFFFF0013 : If one bit of this byte is set, the counter interruption is enable.\n"+
" (contributed by Didier Teifreto, dteifreto@lifc.univ-fcomte.fr)" " If counter interruption is enable, every 30 instructions, an exception is started with cause register bit number 10.\n" +
; " (contributed by Didier Teifreto, dteifreto@lifc.univ-fcomte.fr)"
JButton help = new JButton("Help"); ;
help.addActionListener( JButton help = new JButton("Help");
new ActionListener() { help.addActionListener(
public void actionPerformed(ActionEvent e) { new ActionListener() {
JTextArea ja = new JTextArea(helpContent); public void actionPerformed(ActionEvent e) {
ja.setRows(20); JTextArea ja = new JTextArea(helpContent);
ja.setColumns(60); ja.setRows(20);
ja.setLineWrap(true); ja.setColumns(60);
ja.setWrapStyleWord(true); ja.setLineWrap(true);
JOptionPane.showMessageDialog(theWindow, new JScrollPane(ja), ja.setWrapStyleWord(true);
"Simulating the Hexa Keyboard and Seven segment display", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(theWindow, new JScrollPane(ja),
} "Simulating the Hexa Keyboard and Seven segment display", JOptionPane.INFORMATION_MESSAGE);
}); }
return help; });
}/* ....................Seven Segment display start here................................... */ return help;
/* ...........................Seven segment display start here ..............................*/ }/* ....................Seven Segment display start here................................... */
public void updateSevenSegment(int number,char value) { /* ...........................Seven segment display start here ..............................*/
sevenSegPanel.display[number].modifyDisplay(value); public void updateSevenSegment(int number,char value) {
} sevenSegPanel.display[number].modifyDisplay(value);
public class SevenSegmentDisplay extends JComponent { }
public char aff; public class SevenSegmentDisplay extends JComponent {
public SevenSegmentDisplay(char aff){ public char aff;
this.aff=aff; public SevenSegmentDisplay(char aff){
this.setPreferredSize(new Dimension(60,80)); this.aff=aff;
} this.setPreferredSize(new Dimension(60,80));
public void modifyDisplay(char val){ }
aff=val; public void modifyDisplay(char val){
this.repaint(); aff=val;
} this.repaint();
public void SwitchSegment(Graphics g,char segment){ }
switch(segment){ public void SwitchSegment(Graphics g,char segment){
case 'a': //a segment switch(segment){
int[]pxa1={12,9,12}; case 'a': //a segment
int[]pxa2={36,39,36}; int[]pxa1={12,9,12};
int[]pya={5,8,11}; int[]pxa2={36,39,36};
g.fillPolygon(pxa1,pya, 3); int[]pya={5,8,11};
g.fillPolygon(pxa2,pya, 3); g.fillPolygon(pxa1,pya, 3);
g.fillRect(12,5,24,6); g.fillPolygon(pxa2,pya, 3);
break; g.fillRect(12,5,24,6);
case 'b': //b segment break;
int[]pxb={37,40,43}; case 'b': //b segment
int[]pyb1={12,9,12}; int[]pxb={37,40,43};
int[]pyb2={36,39,36}; int[]pyb1={12,9,12};
g.fillPolygon(pxb,pyb1, 3); int[]pyb2={36,39,36};
g.fillPolygon(pxb,pyb2, 3); g.fillPolygon(pxb,pyb1, 3);
g.fillRect(37,12,6,24); g.fillPolygon(pxb,pyb2, 3);
break; g.fillRect(37,12,6,24);
case 'c': // c segment break;
int[]pxc={37,40,43}; case 'c': // c segment
int[]pyc1={44,41,44}; int[]pxc={37,40,43};
int[]pyc2={68,71,68}; int[]pyc1={44,41,44};
g.fillPolygon(pxc,pyc1, 3); int[]pyc2={68,71,68};
g.fillPolygon(pxc,pyc2, 3); g.fillPolygon(pxc,pyc1, 3);
g.fillRect(37,44,6,24); g.fillPolygon(pxc,pyc2, 3);
break; g.fillRect(37,44,6,24);
case 'd': // d segment break;
int[]pxd1={12,9,12}; case 'd': // d segment
int[]pxd2={36,39,36}; int[]pxd1={12,9,12};
int[]pyd={69,72,75}; int[]pxd2={36,39,36};
g.fillPolygon(pxd1,pyd, 3); int[]pyd={69,72,75};
g.fillPolygon(pxd2,pyd, 3); g.fillPolygon(pxd1,pyd, 3);
g.fillRect(12,69,24,6); g.fillPolygon(pxd2,pyd, 3);
break; g.fillRect(12,69,24,6);
case 'e': // e segment break;
int[]pxe={5,8,11}; case 'e': // e segment
int[]pye1={44,41,44}; int[]pxe={5,8,11};
int[]pye2={68,71,68}; int[]pye1={44,41,44};
g.fillPolygon(pxe,pye1, 3); int[]pye2={68,71,68};
g.fillPolygon(pxe,pye2, 3); g.fillPolygon(pxe,pye1, 3);
g.fillRect(5,44,6,24); g.fillPolygon(pxe,pye2, 3);
break; g.fillRect(5,44,6,24);
case 'f': // f segment break;
int[]pxf={5,8,11}; case 'f': // f segment
int[]pyf1={12,9,12}; int[]pxf={5,8,11};
int[]pyf2={36,39,36}; int[]pyf1={12,9,12};
g.fillPolygon(pxf,pyf1, 3); int[]pyf2={36,39,36};
g.fillPolygon(pxf,pyf2, 3); g.fillPolygon(pxf,pyf1, 3);
g.fillRect(5,12,6,24); g.fillPolygon(pxf,pyf2, 3);
break; g.fillRect(5,12,6,24);
case 'g': // g segment break;
int[]pxg1={12,9,12}; case 'g': // g segment
int[]pxg2={36,39,36}; int[]pxg1={12,9,12};
int[]pyg={37,40,43}; int[]pxg2={36,39,36};
g.fillPolygon(pxg1,pyg, 3); int[]pyg={37,40,43};
g.fillPolygon(pxg2,pyg, 3); g.fillPolygon(pxg1,pyg, 3);
g.fillRect(12,37,24,6); g.fillPolygon(pxg2,pyg, 3);
break; g.fillRect(12,37,24,6);
case 'h': // decimal point break;
g.fillOval(49,68,8,8); case 'h': // decimal point
break; g.fillOval(49,68,8,8);
} break;
} }
public void paint(Graphics g) { }
char c='a'; public void paint(Graphics g) {
while(c<='h'){ char c='a';
if ((aff & 0x1) == 1) while(c<='h'){
g.setColor(Color.RED); if ((aff & 0x1) == 1)
else g.setColor(Color.RED);
g.setColor(Color.LIGHT_GRAY); else
SwitchSegment(g,c); g.setColor(Color.LIGHT_GRAY);
aff = (char)(aff >>>1); SwitchSegment(g,c);
c++; aff = (char)(aff >>>1);
} c++;
} }
} }
public class SevenSegmentPanel extends JPanel { }
public SevenSegmentDisplay[] display; public class SevenSegmentPanel extends JPanel {
public SevenSegmentPanel(){ public SevenSegmentDisplay[] display;
int i; public SevenSegmentPanel(){
FlowLayout fl= new FlowLayout(); int i;
this.setLayout(fl); FlowLayout fl= new FlowLayout();
display= new SevenSegmentDisplay[2]; this.setLayout(fl);
for (i=0;i<2;i++){ display= new SevenSegmentDisplay[2];
display[i]= new SevenSegmentDisplay((char)(0)); for (i=0;i<2;i++){
this.add(display[i]); display[i]= new SevenSegmentDisplay((char)(0));
} this.add(display[i]);
} }
public void modifyDisplay(int num,char val){ }
display[num].modifyDisplay(val); public void modifyDisplay(int num,char val){
display[num].repaint(); display[num].modifyDisplay(val);
} display[num].repaint();
public void resetSevenSegment() { }
int i; public void resetSevenSegment() {
for (i=0;i<2;i++) int i;
modifyDisplay(i, (char)0); for (i=0;i<2;i++)
} modifyDisplay(i, (char)0);
} }
/* ...........................Seven segment display end here ..............................*/ }
/* ....................Hexa Keyboard start here................................... */ /* ...........................Seven segment display end here ..............................*/
public void updateHexaKeyboard(char row) { /* ....................Hexa Keyboard start here................................... */
int key = KeyBoardValueButtonClick; public void updateHexaKeyboard(char row) {
if ((key !=-1)&& ((1 << (key / 4))==(row & 0xF))){ int key = KeyBoardValueButtonClick;
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD, if ((key !=-1)&& ((1 << (key / 4))==(row & 0xF))){
(char)(1 << (key / 4)) | (1 << (4+(key%4)))); updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD,
} (char)(1 << (key / 4)) | (1 << (4+(key%4))));
else{ }
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD, 0); else{
} updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD, 0);
if ((row & 0xF0) != 0) }
KeyboardInterruptOnOff = true; if ((row & 0xF0) != 0)
else KeyboardInterruptOnOff = true;
KeyboardInterruptOnOff = false; else
} KeyboardInterruptOnOff = false;
public class HexaKeyboard extends JPanel{ }
public JButton[] button; public class HexaKeyboard extends JPanel{
public HexaKeyboard(){ public JButton[] button;
int i; public HexaKeyboard(){
GridLayout layout = new GridLayout(4,4); int i;
this.setLayout(layout); GridLayout layout = new GridLayout(4,4);
button = new JButton[16]; this.setLayout(layout);
for (i=0;i<16;i++){ button = new JButton[16];
button[i]= new JButton(Integer.toHexString(i)); for (i=0;i<16;i++){
button[i].setBackground(Color.WHITE); button[i]= new JButton(Integer.toHexString(i));
button[i].setMargin(new Insets(10,10,10,10)); button[i].setBackground(Color.WHITE);
button[i].addMouseListener(new EcouteurClick(i)); button[i].setMargin(new Insets(10,10,10,10));
this.add(button[i]); button[i].addMouseListener(new EcouteurClick(i));
} this.add(button[i]);
} }
public void resetHexaKeyboard(){ }
int i; public void resetHexaKeyboard(){
KeyBoardValueButtonClick=-1; int i;
for(i=0;i<16;i++){ KeyBoardValueButtonClick=-1;
button[i].setBackground(Color.WHITE); for(i=0;i<16;i++){
} button[i].setBackground(Color.WHITE);
} }
public class EcouteurClick implements MouseListener{ }
private int buttonValue; public class EcouteurClick implements MouseListener{
public EcouteurClick(int val){ private int buttonValue;
buttonValue=val; public EcouteurClick(int val){
} buttonValue=val;
public void mouseEntered(MouseEvent arg0) { } }
public void mouseExited(MouseEvent arg0) {} public void mouseEntered(MouseEvent arg0) { }
public void mousePressed(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {}
public void mouseReleased(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {}
public void mouseClicked(MouseEvent arg0) { public void mouseReleased(MouseEvent arg0) {}
int i; public void mouseClicked(MouseEvent arg0) {
if(KeyBoardValueButtonClick!=-1){//Button already pressed -> now realease int i;
KeyBoardValueButtonClick = -1; if(KeyBoardValueButtonClick!=-1){//Button already pressed -> now realease
updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD,0); KeyBoardValueButtonClick = -1;
for(i=0;i<16;i++) updateMMIOControlAndData(OUT_ADRESS_HEXA_KEYBOARD,0);
button[i].setBackground(Color.WHITE); for(i=0;i<16;i++)
} button[i].setBackground(Color.WHITE);
else{ // new button pressed }
KeyBoardValueButtonClick = buttonValue; else{ // new button pressed
button[KeyBoardValueButtonClick].setBackground(Color.GREEN); KeyBoardValueButtonClick = buttonValue;
if( KeyboardInterruptOnOff && (Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){ button[KeyBoardValueButtonClick].setBackground(Color.GREEN);
mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_HEXA_KEYBOARD; if( KeyboardInterruptOnOff && (Coprocessor0.getValue(Coprocessor0.STATUS) & 2)==0){
} mars.simulator.Simulator.externalInterruptingDevice = /*Exceptions.*/EXTERNAL_INTERRUPT_HEXA_KEYBOARD;
} }
} }
} }
} }
/* ....................Hexa Keyboard end here................................... */ }
/* ....................Timer start here................................... */ /* ....................Hexa Keyboard end here................................... */
public void updateOneSecondCounter(char value) { /* ....................Timer start here................................... */
if (value !=0){ public void updateOneSecondCounter(char value) {
CounterInterruptOnOff=true; if (value !=0){
CounterValue=CounterValueMax; CounterInterruptOnOff=true;
} CounterValue=CounterValueMax;
else{ }
CounterInterruptOnOff=false; else{
} CounterInterruptOnOff=false;
} }
public class OneSecondCounter{ }
public OneSecondCounter(){ public class OneSecondCounter{
CounterInterruptOnOff=false; public OneSecondCounter(){
} CounterInterruptOnOff=false;
public void resetOneSecondCounter(){ }
CounterInterruptOnOff=false; public void resetOneSecondCounter(){
CounterValue=CounterValueMax; CounterInterruptOnOff=false;
} CounterValue=CounterValueMax;
} }
} }
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
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