Test and poke operation fixed
This commit is contained in:
parent
dba858307d
commit
e45d153b80
|
@ -97,7 +97,9 @@ func (machine *Machine) Execute(offset int) (err error) {
|
||||||
|
|
||||||
case POKE:
|
case POKE:
|
||||||
// store a word at an address
|
// store a word at an address
|
||||||
machine.Poke(machine.Pop(), machine.Pop())
|
address := machine.Pop()
|
||||||
|
word := machine.Pop()
|
||||||
|
machine.Poke(address, word)
|
||||||
|
|
||||||
case ADD:
|
case ADD:
|
||||||
// adds the last two words on the stack
|
// adds the last two words on the stack
|
||||||
|
@ -258,6 +260,7 @@ func (machine *Machine) Poke(address int, word int) {
|
||||||
copy(reallocatedBlock, machine.block)
|
copy(reallocatedBlock, machine.block)
|
||||||
machine.block = reallocatedBlock
|
machine.block = reallocatedBlock
|
||||||
}
|
}
|
||||||
|
machine.block[address] = word
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register registers a function at the specified ID. If there is already a
|
// Register registers a function at the specified ID. If there is already a
|
||||||
|
|
|
@ -164,7 +164,7 @@ func TestPeekPoke(test *testing.T) {
|
||||||
PEEK,
|
PEEK,
|
||||||
}, []int {
|
}, []int {
|
||||||
632,
|
632,
|
||||||
29,
|
13,
|
||||||
}, test)
|
}, test)
|
||||||
|
|
||||||
secondResult := machine.Pop()
|
secondResult := machine.Pop()
|
||||||
|
|
Loading…
Reference in New Issue