From 302a4e5806cc4643af2703904617a7ee5a1d0498 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 28 Aug 2022 20:20:04 -0400 Subject: [PATCH] Renamed load and store to peek and poke --- creature.go | 8 ++++---- creature_test.go | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/creature.go b/creature.go index 1a338e3..af82112 100644 --- a/creature.go +++ b/creature.go @@ -24,8 +24,8 @@ type MachineFunction func(machine *Machine) (stop bool) const ( PUSH = 0x0 POP = 0x1 - LOAD = 0x2 - STOR = 0x3 + PEEK = 0x2 + POKE = 0x3 ADD = 0x4 SUB = 0x5 MUL = 0x6 @@ -91,11 +91,11 @@ func (machine *Machine) Execute(offset int) (err error) { // pop the top word off of the stack, and discard it machine.Pop() - case LOAD: + case PEEK: // push the word at an address onto the stack machine.Push(machine.Peek(machine.Pop())) - case STOR: + case POKE: // store a word at an address machine.Poke(machine.Pop(), machine.Pop()) diff --git a/creature_test.go b/creature_test.go index 6db50e9..ad1db3f 100644 --- a/creature_test.go +++ b/creature_test.go @@ -16,6 +16,8 @@ func runMachineTest(program []int, test *testing.T) (machine *Machine) { func TestPush(test *testing.T) { machine := runMachineTest ([]int { + PUSH, 3, + POP, PUSH, 654, }, test)