Test and poke operation fixed

This commit is contained in:
Sasha Koshka 2022-08-29 00:43:13 -04:00
parent dba858307d
commit e45d153b80
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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()