Skip to content

Commit

Permalink
Made minor fixes to comments
Browse files Browse the repository at this point in the history
Except for venus, but I'm not doing that today

Mainly includes removing MIPS references, but also includes updating other out of date comments.

Additionally I added a fair number of @Overrrides and reforactored a method name
that should have been changed before in rars/tools.
  • Loading branch information
TheThirdOne committed Apr 4, 2019
1 parent 8f9e5c5 commit 4b2d4b6
Show file tree
Hide file tree
Showing 63 changed files with 363 additions and 693 deletions.
2 changes: 1 addition & 1 deletion rars/AssemblyException.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ a copy of this software and associated documentation files (the
*/

/**
* Exception wrapping ErrorList, used mainly in Tokenier and Assembler; Represents errors that occurs while assembling a RISCV program.
* Exception wrapping ErrorList, used mainly in Tokenizer and Assembler; Represents errors that occurs while assembling a RISCV program.
*
* @author Benjamin Landers
* @version July 2017
Expand Down
4 changes: 2 additions & 2 deletions rars/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class Globals {
*/
public static final ArrayList<String> fileExtensions = getFileExtensions();
/**
* Maximum length of scrolled message window (MARS Messages and Run I/O)
* Maximum length of scrolled message window (RARS Messages and Run I/O)
*/
public static final int maximumMessageCharacters = getMessageLimit();
/**
Expand Down Expand Up @@ -176,7 +176,7 @@ public static void initialize(boolean gui) {
}
}

// Read byte limit of Run I/O or MARS Messages text to buffer.
// Read byte limit of Run I/O or RARS Messages text to buffer.
private static int getMessageLimit() {
return getIntegerProperty(configPropertiesFile, "MessageLimit", 1000000);
}
Expand Down
8 changes: 3 additions & 5 deletions rars/RISCVprogram.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public Tokenizer getTokenizer() {
/**
* Produces new empty list to hold parsed source code statements.
*
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
* MIPS statement.
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed RISCV statement.
* @see ProgramStatement
**/

Expand All @@ -146,8 +145,7 @@ public ArrayList<ProgramStatement> createParsedList() {
/**
* Produces existing list of parsed source code statements.
*
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed
* MIPS statement.
* @return ArrayList of ProgramStatement. Each ProgramStatement represents a parsed RISCV statement.
* @see ProgramStatement
**/

Expand All @@ -159,7 +157,7 @@ public ArrayList<ProgramStatement> getParsedList() {
* Produces list of machine statements that are assembled from the program.
*
* @return ArrayList of ProgramStatement. Each ProgramStatement represents an assembled
* basic MIPS instruction.
* basic RISCV instruction.
* @see ProgramStatement
**/

Expand Down
13 changes: 5 additions & 8 deletions rars/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ a copy of this software and associated documentation files (the
* instantiating Settings object.
* <p>
* NOTE: If the Preference objects fail due to security exceptions, changes to
* settings will not carry over from one MARS session to the next.
* settings will not carry over from one RARS session to the next.
* <p>
* Actual implementation of the Preference objects is platform-dependent.
* For Windows, they are stored in Registry. To see, run regedit and browse to:
Expand All @@ -61,11 +61,8 @@ a copy of this software and associated documentation files (the
public class Settings extends Observable {
/* Properties file used to hold default settings. */
private static String settingsFile = "Settings";
///////////////////////////// PROPERTY ARRAY INDEXES /////////////////////////////
// Because MARS is programmed to Java 1.4, we cannot use an enumerated type.

// BOOLEAN SETTINGS...

public enum Bool {
/**
* Flag to determine whether or not program being assembled is limited to
Expand Down Expand Up @@ -175,7 +172,7 @@ String getName() {
}
// STRING SETTINGS. Each array position has associated name.
/**
* Current specified exception handler file (a MIPS assembly source file)
* Current specified exception handler file (a RISCV assembly source file)
*/
public static final int EXCEPTION_HANDLER = 0;
/**
Expand Down Expand Up @@ -397,7 +394,7 @@ public Settings(boolean gui) {
/**
* Return whether backstepping is permitted at this time. Backstepping is ability to undo execution
* steps one at a time. Available only in the IDE. This is not a persistent setting and is not under
* MARS user control.
* RARS user control.
*
* @return true if backstepping is permitted, false otherwise.
*/
Expand Down Expand Up @@ -746,7 +743,7 @@ public void setBooleanSetting(Bool setting, boolean value) {

/**
* Temporarily establish boolean setting. This setting will NOT be written to persisent
* store! Currently this is used only when running MARS from the command line
* store! Currently this is used only when running RARS from the command line
*
* @param setting the setting to set the value of
* @param value True to enable the setting, false otherwise.
Expand Down Expand Up @@ -991,7 +988,7 @@ private Color getColorValueByPosition(int position, String[] values) {
//
// NOTE: If there is NO ENTRY for the specified property, Globals.getPropertyEntry() returns
// null. This is no cause for alarm. It will occur during system development or upon the
// first use of a new MARS release in which new settings have been defined.
// first use of a new RARS release in which new settings have been defined.
// In that case, this method will NOT make an assignment to the settings array!
// So consider it a precondition of this method: the settings arrays must already be
// initialized with last-resort default values.
Expand Down
33 changes: 7 additions & 26 deletions rars/assembler/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ a copy of this software and associated documentation files (the
*/

/**
* An Assembler is capable of assembling a MIPS program. It has only one public
* An Assembler is capable of assembling a RISCV program. It has only one public
* method, <tt>assemble()</tt>, which implements a two-pass assembler. It
* translates RISCV source code into binary machine code.
*
Expand Down Expand Up @@ -74,7 +74,7 @@ public ErrorList getErrorList() {
}

/**
* Parse and generate machine code for the given MIPS program. All source
* Parse and generate machine code for the given program. All source
* files must have already been tokenized.
*
* @param tokenizedProgramFiles An ArrayList of RISCVprogram objects, each produced from a
Expand Down Expand Up @@ -430,6 +430,7 @@ private ArrayList<ProgramStatement> parseLine(TokenList tokenList, String source
return ret;
}

// TODO: check what gcc and clang generated assembly looks like currently
// DPS 14-July-2008
// Yet Another Hack: detect unrecognized directive. MARS recognizes the same directives
// as SPIM but other MIPS assemblers recognize additional directives. Compilers such
Expand Down Expand Up @@ -565,8 +566,8 @@ private boolean tokenListBeginsWithLabel(TokenList tokens) {
&& tokens.get(1).getType() == TokenTypes.COLON;
}

// //////////////////////////////////////////////////////////////////////////////////
// This source code line is a directive, not a MIPS instruction. Let's carry it out.
// /////////////////////////////////////////////////////////////////////////////
// This source code line is a directive, not a instruction. Let's carry it out.
private void executeDirective(TokenList tokens) {
Token token = tokens.get(0);
Directives direct = Directives.matchDirective(token.getValue());
Expand Down Expand Up @@ -713,7 +714,7 @@ private void executeDirective(TokenList tokens) {
// If label already in global symtab, do nothing. If not, add it right now.
if (Globals.symbolTable.getAddress(tokens.get(1).getValue()) == SymbolTable.NOT_FOUND) {
Globals.symbolTable.addSymbol(tokens.get(1), this.externAddress,
Symbol.DATA_SYMBOL, errors);
true, errors);
this.externAddress += size;
}
} else if (direct == Directives.GLOBL) {
Expand Down Expand Up @@ -870,27 +871,7 @@ private void storeNumeric(TokenList tokens, Directives directive, ErrorList erro
storeRealNumber(valueToken, directive, errors);
}
}
} // WHAT ABOUT .KDATA SEGMENT?
/*
* /****** NOTE of 11/20/06. Below will always throw exception b/c
* you cannot use Memory.set() with text segment addresses and the
* "not valid address" produced here is misleading. Added data
* segment check prior to this point, so this "else" will never be
* executed. I'm leaving it in just in case MARS in the future adds
* capability of writing to the text segment (e.g. ability to
* de-assemble a binary value into its corresponding MIPS
* instruction)
*
* else { // not in data segment...which we assume to mean in text
* segment. try { for (int i=0; i < repetitions; i++) {
* Globals.memory.set(this.textAddress.get(),
* Binary.stringToInt(valueToken.getValue()), lengthInBytes);
* this.textAddress.increment(lengthInBytes); } } catch
* (AddressErrorException e) { errors.add(new
* ErrorMessage(token.getSourceProgram(), token.getSourceLine(),
* token.getStartPos(), "\""+this.textAddress.get()+
* "\" is not a valid text segment address")); } }
************************************************************************/
}
return;
}

Expand Down
32 changes: 16 additions & 16 deletions rars/assembler/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,51 @@ a copy of this software and associated documentation files (the


/**
* Information about MIPS data types.
* Information about data types.
*
* @author Pete Sanderson
* @version August 2003
**/

public final class DataTypes {
/**
* Number of bytes occupied by MIPS double is 8.
* Number of bytes occupied by double is 8.
**/
public static final int DOUBLE_SIZE = 8;
/**
* Number of bytes occupied by MIPS float is 4.
* Number of bytes occupied by float is 4.
**/
public static final int FLOAT_SIZE = 4;
/**
* Number of bytes occupied by MIPS word is 4.
* Number of bytes occupied by word is 4.
**/
public static final int WORD_SIZE = 4;
/**
* Number of bytes occupied by MIPS halfword is 2.
* Number of bytes occupied by halfword is 2.
**/
public static final int HALF_SIZE = 2;
/**
* Number of bytes occupied by MIPS byte is 1.
* Number of bytes occupied by byte is 1.
**/
public static final int BYTE_SIZE = 1;
/**
* Number of bytes occupied by MIPS character is 1.
* Number of bytes occupied by character is 1.
**/
public static final int CHAR_SIZE = 1;
/**
* Maximum value that can be stored in a MIPS word is 2<sup>31</sup>-1
* Maximum value that can be stored in a word is 2<sup>31</sup>-1
**/
public static final int MAX_WORD_VALUE = Integer.MAX_VALUE;
/**
* Lowest value that can be stored in a MIPS word is -2<sup>31</sup>
* Lowest value that can be stored in aword is -2<sup>31</sup>
**/
public static final int MIN_WORD_VALUE = Integer.MIN_VALUE;
/**
* Maximum value that can be stored in a MIPS halfword is 2<sup>15</sup>-1
* Maximum value that can be stored in a halfword is 2<sup>15</sup>-1
**/
public static final int MAX_HALF_VALUE = 32767; //(int)Math.pow(2,15) - 1;
/**
* Lowest value that can be stored in a MIPS halfword is -2<sup>15</sup>
* Lowest value that can be stored in a halfword is -2<sup>15</sup>
**/
public static final int MIN_HALF_VALUE = -32768; //0 - (int) Math.pow(2,15);
/**
Expand All @@ -94,24 +94,24 @@ public final class DataTypes {
**/
public static final int MIN_UPPER_VALUE = 0xFFF80000;
/**
* Maximum value that can be stored in a MIPS byte is 2<sup>7</sup>-1
* Maximum value that can be stored in a byte is 2<sup>7</sup>-1
**/
public static final int MAX_BYTE_VALUE = Byte.MAX_VALUE;
/**
* Lowest value that can be stored in a MIPS byte is -2<sup>7</sup>
* Lowest value that can be stored in a byte is -2<sup>7</sup>
**/
public static final int MIN_BYTE_VALUE = Byte.MIN_VALUE;
/**
* Maximum positive finite value that can be stored in a MIPS float is same as Java Float
* Maximum positive finite value that can be stored in a float is same as Java Float
**/
public static final double MAX_FLOAT_VALUE = Float.MAX_VALUE;
/**
* Largest magnitude negative value that can be stored in a MIPS float (negative of the max)
* Largest magnitude negative value that can be stored in a float (negative of the max)
**/
public static final double LOW_FLOAT_VALUE = -Float.MAX_VALUE;

/**
* Get length in bytes for numeric MIPS directives.
* Get length in bytes for numeric RISCV directives.
*
* @param direct Directive to be measured.
* @return Returns length in bytes for values of that type. If type is not numeric
Expand Down
16 changes: 8 additions & 8 deletions rars/assembler/Directives.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ a copy of this software and associated documentation files (the
*/

/**
* Class representing MIPS assembler directives. If Java had enumerated types, these
* Class representing RISCV assembler directives. If Java had enumerated types, these
* would probably be implemented that way. Each directive is represented by a unique object.
* The directive name is indicative of the directive it represents. For example, DATA
* represents the MIPS .data directive.
* represents the RISCV .data directive.
*
* @author Pete Sanderson
* @version August 2003
Expand Down Expand Up @@ -128,7 +128,7 @@ public String toString() {
/**
* Get name of this Directives object
*
* @return name of this MIPS directive as a String
* @return name of this directive as a String
**/

public String getName() {
Expand All @@ -138,7 +138,7 @@ public String getName() {
/**
* Get description of this Directives object
*
* @return description of this MIPS directive (for help purposes)
* @return description of this directive (for help purposes)
**/

public String getDescription() {
Expand All @@ -148,7 +148,7 @@ public String getDescription() {
/**
* Produces List of Directive objects
*
* @return MIPS Directive
* @return All directives defined
**/
public static ArrayList<Directives> getDirectiveList() {
return directiveList;
Expand All @@ -158,8 +158,8 @@ public static ArrayList<Directives> getDirectiveList() {
/**
* Lets you know whether given directive is for integer (WORD,HALF,BYTE).
*
* @param direct a MIPS directive
* @return true if given directive is FLOAT or DOUBLE, false otherwise
* @param direct a directive
* @return true if given directive is WORD, HALF, or BYTE, false otherwise
**/
public static boolean isIntegerDirective(Directives direct) {
return direct == Directives.WORD || direct == Directives.HALF || direct == Directives.BYTE;
Expand All @@ -169,7 +169,7 @@ public static boolean isIntegerDirective(Directives direct) {
/**
* Lets you know whether given directive is for floating number (FLOAT,DOUBLE).
*
* @param direct a MIPS directive
* @param direct a directive
* @return true if given directive is FLOAT or DOUBLE, false otherwise.
**/
public static boolean isFloatingDirective(Directives direct) {
Expand Down
21 changes: 4 additions & 17 deletions rars/assembler/OperandFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ a copy of this software and associated documentation files (the
*/

/**
* Provides utility method related to MIPS operand formats.
* Provides utility method related to operand formats.
*
* @author Pete Sanderson
* @version August 2003
*/


public class OperandFormat {
/*
/**
* Syntax test for correct match in both numbers and types of operands.
*
* @param candidateList List of tokens generated from programmer's MIPS statement.
* @param spec The (resumably best matched) MIPS instruction.
* @param inst The (presumably best matched) RISCV instruction.
* @param errors ErrorList into which any error messages generated here will be added.
*
* @return Returns <tt>true</tt> if the programmer's statement matches the MIPS
Expand All @@ -58,7 +58,7 @@ static boolean tokenOperandMatch(TokenList candidateList, Instruction inst, Erro
return numOperandsCheck(candidateList, inst, errors) && operandTypeCheck(candidateList, inst, errors);
}

/*
/**
* If candidate operator token matches more than one instruction mnemonic, then select
* first such Instruction that has an exact operand match. If none match,
* return the first Instruction and let client deal with operand mismatches.
Expand Down Expand Up @@ -147,19 +147,6 @@ private static boolean operandTypeCheck(TokenList cand, Instruction spec, ErrorL
}
}

/* nice little debugging code to see which operand format
the operands for this source code instruction matched.
System.out.print("Candidate: ");
for (int i=1; i<spec.size(); i++) {
System.out.print(cand.get(i).getValue()+" ");
}
System.out.print("Matched Spec: ");
for (int i=1; i<spec.size(); i++) {
System.out.print(spec.get(i).getValue()+" ");
}
System.out.println();
**/

return true;
}

Expand Down
Loading

0 comments on commit 4b2d4b6

Please sign in to comment.