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 (
|
const (
|
||||||
PUSH = 0x0
|
PUSH = 0x0
|
||||||
POP = 0x1
|
POP = 0x1
|
||||||
LOAD = 0x2
|
PEEK = 0x2
|
||||||
STOR = 0x3
|
POKE = 0x3
|
||||||
ADD = 0x4
|
ADD = 0x4
|
||||||
SUB = 0x5
|
SUB = 0x5
|
||||||
MUL = 0x6
|
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
|
// pop the top word off of the stack, and discard it
|
||||||
machine.Pop()
|
machine.Pop()
|
||||||
|
|
||||||
case LOAD:
|
case PEEK:
|
||||||
// push the word at an address onto the stack
|
// push the word at an address onto the stack
|
||||||
machine.Push(machine.Peek(machine.Pop()))
|
machine.Push(machine.Peek(machine.Pop()))
|
||||||
|
|
||||||
case STOR:
|
case POKE:
|
||||||
// store a word at an address
|
// store a word at an address
|
||||||
machine.Poke(machine.Pop(), machine.Pop())
|
machine.Poke(machine.Pop(), machine.Pop())
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ func runMachineTest(program []int, test *testing.T) (machine *Machine) {
|
|||||||
|
|
||||||
func TestPush(test *testing.T) {
|
func TestPush(test *testing.T) {
|
||||||
machine := runMachineTest ([]int {
|
machine := runMachineTest ([]int {
|
||||||
|
PUSH, 3,
|
||||||
|
POP,
|
||||||
PUSH, 654,
|
PUSH, 654,
|
||||||
}, test)
|
}, test)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user