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

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.