Package mars.simulator
Class BackStepper
java.lang.Object
mars.simulator.BackStepper
Used to "step backward" through execution, undoing each instruction.
- Author:
- Pete Sanderson, February 2006; Sean Clarke, November 2024
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
backStep()
Carry out a "back step", which will undo the latest execution step.void
boolean
isEmpty()
Test whether there are steps that can be undone.boolean
Determine whether execution "undo" steps are currently being recorded.void
registerChanged
(Register register, int restoreValue) Add a new "back step" (the undo action) to the stack.void
reset()
void
setEnabled
(boolean state) Set enable status.void
statementWritten
(int address, BasicStatement restoreStatement) Add a new "back step" (the undo action) to the stack.void
wordWritten
(int address, int restoreValue) Add a new "back step" (the undo action) to the stack.
-
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
-
reset
public void reset() -
isEnabled
public boolean isEnabled()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.
-
isEmpty
public boolean isEmpty()Test whether there are steps that can be undone.- Returns:
- true if there are no steps to be undone, false otherwise.
-
finishStep
public void finishStep() -
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. -
registerChanged
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.restoreValue
- The "restore" value to be stored there.
-
wordWritten
public void wordWritten(int address, int restoreValue) 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.restoreValue
- The "restore" value to be stored there.
-
statementWritten
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.restoreStatement
- The "restore" value to be stored there.
-