Add a Reset method to the machine

This commit is contained in:
Sasha Koshka 2022-08-28 17:35:30 -04:00
parent ebf58c9427
commit d48181b832
1 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,13 @@ func (err Error) Error () (description string) {
return
}
// Reset resets the stack of the machine. This should be called before Execute,
// since Execute does not reset the stack.
func (machine *Machine) Reset () {
machine.stack = nil
machine.pointer = 0
}
// Execute starts execution at the address specified by offset. The machine will
// run until a HALT instruction is encountered, or the end of program memory is
// reached.