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:
|
||||
// store a word at an address
|
||||
machine.Poke(machine.Pop(), machine.Pop())
|
||||
address := machine.Pop()
|
||||
word := machine.Pop()
|
||||
machine.Poke(address, word)
|
||||
|
||||
case ADD:
|
||||
// adds the last two words on the stack
|
||||
@ -258,6 +260,7 @@ func (machine *Machine) Poke(address int, word int) {
|
||||
copy(reallocatedBlock, machine.block)
|
||||
machine.block = reallocatedBlock
|
||||
}
|
||||
machine.block[address] = word
|
||||
}
|
||||
|
||||
// Register registers a function at the specified ID. If there is already a
|
||||
|
@ -164,7 +164,7 @@ func TestPeekPoke(test *testing.T) {
|
||||
PEEK,
|
||||
}, []int {
|
||||
632,
|
||||
29,
|
||||
13,
|
||||
}, test)
|
||||
|
||||
secondResult := machine.Pop()
|
||||
|
Loading…
Reference in New Issue
Block a user