diff --git a/creature.go b/creature.go index 99e1779..042c726 100644 --- a/creature.go +++ b/creature.go @@ -53,7 +53,7 @@ func (machine *Machine) Reset () { func (machine *Machine) Execute (offset int) { machine.counter = offset - for { + for machine.counter < len(machine.Program) { switch machine.instruction() { case 0x0: // PUSH @@ -244,5 +244,11 @@ func (machine *Machine) Unregister (id int) { delete(machine.functions, id) } +// LoadMemory loads the contents of block into the machine's memory. +func (machine *Machine) LoadMemory (block []int) { + machine.block = make([]int, len(block)) + copy(machine.block, block) +} + // Milk milks the stack machine func (machine *Machine) Milk () {}