Modify addressable to become a pointer because Go's range does not
provide a pointer to the element but a copy of the element (urgh).
Go's range operator really can be considered broken. In this case it
copies the addressable all the time which significantly slows things
down. To boot, it isn't writing in the memory you think it is (it ends
up in the copy of memory).
Before the change:
$ go test -v -test.run Klaus
=== RUN TestKlausDormann6502
Running Klaus Dormann' 6502 functional tests. This may take some time...
Klaus Dormann's 6502 functional tests passed.
--- PASS: TestKlausDormann6502 (13.51s)
PASS
ok github.com/ariejan/i6502 13.522s
After the change:
$ go test -v -test.run Klaus
=== RUN TestKlausDormann6502
Running Klaus Dormann' 6502 functional tests. This may take some time...
Klaus Dormann's 6502 functional tests passed.
--- PASS: TestKlausDormann6502 (4.87s)
PASS
ok github.com/ariejan/i6502 4.877s
Because io.Reader and io.Writer already claim the functions Read and
Write it was necessary to rename the Memory interface methods Read and
Write to ReadByte and WriteByte.