Renamed load and store to peek and poke
This commit is contained in:
parent
0f1285bbb9
commit
302a4e5806
@ -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())
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user