1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package main import ( // "os" // "fmt" ) type Rom []byte func (r *Rom) Fetch(pc *uint64, n uint64) []byte { if (*pc + n > uint64(len(*r))) { return nil } x := make([]byte, n) copy(x, (*r)[*pc:*pc + n]) *pc += n return x }