## mars.simulator
Class BackStepper

    java.lang.Object
      mars.simulator.BackStepper

    public class BackStepper

extends Object

Used to "step backward" through execution, undoing each instruction.

Author:
  Pete Sanderson

Constructor Summary
`BackStepper()` Create a fresh BackStepper.

Method Summary
`int` `addConditionFlagClear(int flag)` Add a new "back step" (the undo action) to the stack.
`int` `addConditionFlagSet(int flag)` Add a new "back step" (the undo action) to the stack.
`int` `addCoprocessor0Restore(int register, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addCoprocessor1Restore(int register, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addDoNothing(int pc)` Add a new "back step" (the undo action) to the stack.
`int` `addMemoryRestoreByte(int address, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addMemoryRestoreHalf(int address, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addMemoryRestoreRawWord(int address, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addMemoryRestoreWord(int address, int value)` Add a new "back step" (the undo action) to the stack.
`int` `addPCRestore(int value)` Add a new "back step" (the undo action) to the stack.
`int` `addRegisterFileRestore(int register, int value)` Add a new "back step" (the undo action) to the stack.
`void` `backStep()` Carry out a "back step", which will undo the latest execution step.
`boolean` `empty()` Test whether there are steps that can be undone.
`boolean` `enabled()` Determine whether execution "undo" steps are currently being recorded.
`boolean` `inDelaySlot()` Determine whether the next back-step action occurred as the result of an instruction that executed in the "delay slot" of a delayed branch.
`void` `setEnabled(boolean state)` Set enable status.

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

Constructor Detail

### BackStepper

    public BackStepper()

  Create a fresh BackStepper. It is enabled, which means all subsequent instruction executions will have their "undo" action recorded here.

Method Detail

### enabled

    public boolean enabled()

  Determine whether execution "undo" steps are currently being recorded.

  Returns:
    true if undo steps being recorded, false if not.

### setEnabled

    public void setEnabled(boolean state)

  Set enable status.

  Parameters:
    `state` - If true, will begin (or continue) recoding "undo" steps. If false, will stop.

### empty

    public boolean empty()

  Test whether there are steps that can be undone.

  Returns:
    true if there are no steps to be undone, false otherwise.

### inDelaySlot

    public boolean inDelaySlot()

  Determine whether the next back-step action occurred as the result of an instruction that executed in the "delay slot" of a delayed branch.

  Returns:
    true if next backstep is instruction that executed in delay slot, false otherwise.

### backStep

    public void backStep()

  Carry out a "back step", which will undo the latest execution step. Does nothing if backstepping not enabled or if there are no steps to undo.

### addMemoryRestoreRawWord

    public int addMemoryRestoreRawWord(int address,
                                       int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a raw memory word value (setRawWord).

  Parameters:
    `address` - The affected memory address.
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addMemoryRestoreWord

    public int addMemoryRestoreWord(int address,
                                    int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a memory word value.

  Parameters:
    `address` - The affected memory address.
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addMemoryRestoreHalf

    public int addMemoryRestoreHalf(int address,
                                    int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a memory half-word value.

  Parameters:
    `address` - The affected memory address.
    `value` - The "restore" value to be stored there, in low order half.
  Returns:
    the argument value

### addMemoryRestoreByte

    public int addMemoryRestoreByte(int address,
                                    int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a memory byte value.

  Parameters:
    `address` - The affected memory address.
    `value` - The "restore" value to be stored there, in low order byte.
  Returns:
    the argument value

### addRegisterFileRestore

    public int addRegisterFileRestore(int register,
                                      int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a register file register value.

  Parameters:
    `register` - The affected register number.
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addPCRestore

    public int addPCRestore(int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore the program counter.

  Parameters:
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addCoprocessor0Restore

    public int addCoprocessor0Restore(int register,
                                      int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a coprocessor 0 register value.

  Parameters:
    `register` - The affected register number.
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addCoprocessor1Restore

    public int addCoprocessor1Restore(int register,
                                      int value)

  Add a new "back step" (the undo action) to the stack. The action here is to restore a coprocessor 1 register value.

  Parameters:
    `register` - The affected register number.
    `value` - The "restore" value to be stored there.
  Returns:
    the argument value

### addConditionFlagSet

    public int addConditionFlagSet(int flag)

  Add a new "back step" (the undo action) to the stack. The action here is to set the given coprocessor 1 condition flag (to 1).

  Parameters:
    `flag` - The condition flag number.
  Returns:
    the argument value

### addConditionFlagClear

    public int addConditionFlagClear(int flag)

  Add a new "back step" (the undo action) to the stack. The action here is to clear the given coprocessor 1 condition flag (to 0).

  Parameters:
    `flag` - The condition flag number.
  Returns:
    the argument value

### addDoNothing

    public int addDoNothing(int pc)

  Add a new "back step" (the undo action) to the stack. The action here is to do nothing! This is just a place holder so when user is backstepping through the program no instructions will be skipped. Cosmetic. If the top of the stack has the same PC counter, the do-nothing action will not be added.

  Returns:
    0