Package mars.simulator
Class BackStepper
java.lang.Object
mars.simulator.BackStepper
Used to "step backward" through execution, undoing each instruction.
- Version:
- February 2006
- Author:
- Pete Sanderson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddConditionFlagClear(int flag)Add a new "back step" (the undo action) to the stack.intaddConditionFlagSet(int flag)Add a new "back step" (the undo action) to the stack.intaddCoprocessor0Restore(int register, int value)Add a new "back step" (the undo action) to the stack.intaddCoprocessor1Restore(int register, int value)Add a new "back step" (the undo action) to the stack.intaddDoNothing(int pc)Add a new "back step" (the undo action) to the stack.intaddMemoryRestoreByte(int address, int value)Add a new "back step" (the undo action) to the stack.intaddMemoryRestoreHalf(int address, int value)Add a new "back step" (the undo action) to the stack.intaddMemoryRestoreRawWord(int address, int value)Add a new "back step" (the undo action) to the stack.intaddMemoryRestoreWord(int address, int value)Add a new "back step" (the undo action) to the stack.intaddPCRestore(int value)Add a new "back step" (the undo action) to the stack.intaddRegisterFileRestore(int register, int value)Add a new "back step" (the undo action) to the stack.voidbackStep()Carry out a "back step", which will undo the latest execution step.booleanempty()Check whether there are steps that can be undone.booleanenabled()Determine whether execution "undo" steps are currently being recorded.booleanDetermine whether the next back-step action occurred as the result of an instruction that executed in the "delay slot" of a delayed branch.voidsetEnabled(boolean state)Set enable status.
-
Constructor Details
-
BackStepper
public BackStepper()Create a fresh BackStepper. It is enabled, which means all subsequent instruction executions will have their "undo" action recorded here.
-
-
Method Details
-
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()Check 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
-