diff --git a/creature.go b/creature.go index af82112..18bd92e 100644 --- a/creature.go +++ b/creature.go @@ -97,7 +97,9 @@ func (machine *Machine) Execute(offset int) (err error) { case POKE: // store a word at an address - machine.Poke(machine.Pop(), machine.Pop()) + address := machine.Pop() + word := machine.Pop() + machine.Poke(address, word) case ADD: // adds the last two words on the stack @@ -258,6 +260,7 @@ func (machine *Machine) Poke(address int, word int) { copy(reallocatedBlock, machine.block) machine.block = reallocatedBlock } + machine.block[address] = word } // Register registers a function at the specified ID. If there is already a diff --git a/creature_test.go b/creature_test.go index 5c3acb9..7ba7243 100644 --- a/creature_test.go +++ b/creature_test.go @@ -164,7 +164,7 @@ func TestPeekPoke(test *testing.T) { PEEK, }, []int { 632, - 29, + 13, }, test) secondResult := machine.Pop()