Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## mars
Class ProgramStatement

    java.lang.Object
      mars.ProgramStatement

    public class ProgramStatement

extends Object

Represents one assembly/machine statement. This represents the "bare machine" level. Pseudo-instructions have already been processed at this point and each assembly statement generated by them is one of these.

Author:
  Pete Sanderson and Jason Bumgarner

Constructor Summary
`ProgramStatement(int binaryStatement, int textAddress)` Constructor for ProgramStatement used only for writing a binary machine instruction with no source code to refer back to.
`ProgramStatement(MIPSprogram sourceMIPSprogram, String source, TokenList origTokenList, TokenList strippedTokenList, Instruction inst, int textAddress, int sourceLine)` Constructor for ProgramStatement when there are links back to all source and token information.

Method Summary
`void` | `buildBasicStatementFromBasicInstruction(ErrorList errors)` Given specification of BasicInstruction for this operator, build the corresponding assembly statement in basic assembly format (e.g.
`void` | `buildMachineStatementFromBasicStatement(ErrorList errors)` Given the current statement in Basic Assembly format (see above), build the 32-bit binary machine code statement.
`int` | `getAddress()` Produces Text Segment address where the binary machine statement is stored.
`String` | `getBasicAssemblyStatement()` Produces Basic Assembly statement for this MIPS source statement.
`int` | `getBinaryStatement()` Produces 32-bit binary machine statement as int.
`Instruction` | `getInstruction()` Produces Instruction object corresponding to this statement's operator.
`String` | `getMachineStatement()` Produces binary machine statement as 32 character string, all '0' and '1' chars.
`int` | `getOperand(int i)` Produces operand value from given array position (first operand is position 0).
`int[]` | `getOperands()` Produces int array of operand values for this statement.
`TokenList` | `getOriginalTokenList()` Produces token list generated from original source statement.
`String` | `getPrintableBasicAssemblyStatement()` Produces printable Basic Assembly statement for this MIPS source statement.
`String` | `getSource()` Produces MIPS source statement.
`String` | `getSourceFile()` Produces String name of the source file containing this statement.
`int` | `getSourceLine()` Produces line number of MIPS source statement.
`MIPSprogram` | `getSourceMIPSprogram()` Produces MIPSprogram object representing the source file containing this statement.
`TokenList` | `getStrippedTokenList()` Produces token list stripped of all but operator and operand tokens.
`void` | `setBasicAssemblyStatement(String statement)` Assigns given String to be Basic Assembly statement equivalent to this source line.
`void` | `setBinaryStatement(int binaryCode)` Assigns given int to be binary machine code equivalent to this source line.
`void` | `setMachineStatement(String statement)` Assigns given String to be binary machine code (32 characters, all of them 0 or 1) equivalent to this source line.
`void` | `setSource(String src)` associates MIPS source statement.
`String` | `toString()` Crude attempt at building String representation of this complex structure.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ProgramStatement

    public ProgramStatement(MIPSprogram sourceMIPSprogram,
                            String source,
                            TokenList origTokenList,
                            TokenList strippedTokenList,
                            Instruction inst,
                            int textAddress,
                            int sourceLine)

  Constructor for ProgramStatement when there are links back to all source and token information. These can be used by a debugger later on.

  Parameters:
    `sourceMIPSprogram` - The MIPSprogram object that contains this statement
    `source` - The corresponding MIPS source statement.
    `origTokenList` - Complete list of Token objects (includes labels, comments, parentheses, etc)
    `strippedTokenList` - List of Token objects with all but operators and operands removed.
    `inst` - The Instruction object for this statement's operator.
    `textAddress` - The Text Segment address in memory where the binary machine code for this statement is stored.

### ProgramStatement

    public ProgramStatement(int binaryStatement,
                            int textAddress)

  Constructor for ProgramStatement used only for writing a binary machine instruction with no source code to refer back to. Originally supported only NOP instruction (all zeroes), but extended in release 4.4 to support all basic instructions. This was required for the self-modifying code feature.

  Parameters:
    `binaryStatement` - The 32-bit machine code.
    `textAddress` - The Text Segment address in memory where the binary machine code for this statement is stored.

Method Detail

### buildBasicStatementFromBasicInstruction

    public void buildBasicStatementFromBasicInstruction(ErrorList errors)

  Given specification of BasicInstruction for this operator, build the corresponding assembly statement in basic assembly format (e.g. substituting register numbers for register names, replacing labels by values).

  Parameters:
    `errors` - The list of assembly errors encountered so far. May add to it here.

### buildMachineStatementFromBasicStatement

    public void buildMachineStatementFromBasicStatement(ErrorList errors)

  Given the current statement in Basic Assembly format (see above), build the 32-bit binary machine code statement.

  Parameters:
    `errors` - The list of assembly errors encountered so far. May add to it here.

### toString

    public String toString()

  Crude attempt at building String representation of this complex structure.

  Overrides:
    `toString` in class `Object`
  Returns:
    A String representing the ProgramStatement.

### setBasicAssemblyStatement

    public void setBasicAssemblyStatement(String statement)

  Assigns given String to be Basic Assembly statement equivalent to this source line.

  Parameters:
    `statement` - A String containing equivalent Basic Assembly statement.

### setMachineStatement

    public void setMachineStatement(String statement)

  Assigns given String to be binary machine code (32 characters, all of them 0 or 1) equivalent to this source line.

  Parameters:
    `statement` - A String containing equivalent machine code.

### setBinaryStatement

    public void setBinaryStatement(int binaryCode)

  Assigns given int to be binary machine code equivalent to this source line.

  Parameters:
    `binaryCode` - An int containing equivalent binary machine code.

### setSource

    public void setSource(String src)

  associates MIPS source statement. Used by assembler when generating basic statements during macro expansion of extended statement.

  Parameters:
    `src` - a MIPS source statement.

### getSourceMIPSprogram

    public MIPSprogram getSourceMIPSprogram()

  Produces MIPSprogram object representing the source file containing this statement.

  Returns:
    The MIPSprogram object. May be null...

### getSourceFile

    public String getSourceFile()

  Produces String name of the source file containing this statement.

  Returns:
    The file name.

### getSource

    public String getSource()

  Produces MIPS source statement.

  Returns:
    The MIPS source statement.

### getSourceLine

    public int getSourceLine()

  Produces line number of MIPS source statement.

  Returns:
    The MIPS source statement line number.

### getBasicAssemblyStatement

    public String getBasicAssemblyStatement()

  Produces Basic Assembly statement for this MIPS source statement. All numeric values are in decimal.

  Returns:
    The Basic Assembly statement.

### getPrintableBasicAssemblyStatement

    public String getPrintableBasicAssemblyStatement()

  Produces printable Basic Assembly statement for this MIPS source statement. This is generated dynamically and any addresses and values will be rendered in hex or decimal depending on the current setting.

  Returns:
    The Basic Assembly statement.

### getMachineStatement

    public String getMachineStatement()

  Produces binary machine statement as 32 character string, all '0' and '1' chars.

  Returns:
    The String version of 32-bit binary machine code.

### getBinaryStatement

    public int getBinaryStatement()

  Produces 32-bit binary machine statement as int.

  Returns:
    The int version of 32-bit binary machine code.

### getOriginalTokenList

    public TokenList getOriginalTokenList()

  Produces token list generated from original source statement.

  Returns:
    The TokenList of Token objects generated from original source.

### getStrippedTokenList

    public TokenList getStrippedTokenList()

  Produces token list stripped of all but operator and operand tokens.

  Returns:
    The TokenList of Token objects generated by stripping original list of all except operator and operand tokens.

### getInstruction

    public Instruction getInstruction()

  Produces Instruction object corresponding to this statement's operator.

  Returns:
    The Instruction that matches the operator used in this statement.

### getAddress

    public int getAddress()

  Produces Text Segment address where the binary machine statement is stored.

  Returns:
    address in Text Segment of this binary machine statement.

### getOperands

    public int[] getOperands()

  Produces int array of operand values for this statement.

  Returns:
    int array of operand values (if any) required by this statement's operator.

### getOperand

    public int getOperand(int i)

  Produces operand value from given array position (first operand is position 0).

  Parameters:
    `i` - Operand position in array (first operand is position 0).
  Returns:
    Operand value at given operand array position. If < 0 or >= numOperands, it returns -1.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD