Today you build the 64 KB address space the CPU sees as its entire world, from cartridge and RAM to hardware registers. Every future instruction that reads or writes memory ultimately calls the two methods you build here.
Build a 64 KB address space that can be read from and written to at any address.
The CPU sees the whole machine - cartridge, work RAM, video RAM, and hardware
registers - as one flat address space of 65,536 bytes, from 0x0000 to
0xFFFF. Today it is just a plain array; later lessons will give special regions
special behavior, but every one of them still answers a read or a write
at some address.
Address 0xC000 is the start of work RAM, the CPU’s general scratch memory,
which is why it is a safe place to prove the round trip. Keep the interface tiny
// 0x0000..0xFFFF - one byte per addresstype Memory struct{ data [0x10000]uint8 }func (m *Memory) Read(addr uint16) uint8 { return m.data[addr] }func (m *Memory) Write(addr uint16, v uint8) { m.data[addr] = v }
The Game Boy memory map - a 16-bit address space from 0x0000 to 0xFFFF.