Documentation
¶
Index ¶
- Constants
- func AccessViolationError(addr uint32) error
- type Decoder
- func (m *Decoder) Byte(addr int) (b byte, err error)
- func (m *Decoder) Long(addr int) (n uint32, err error)
- func (m *Decoder) Read(addr int, p []byte) (n int, err error)
- func (m *Decoder) Reset() (err error)
- func (m *Decoder) Slong(addr int) (n int32, err error)
- func (m *Decoder) Sword(addr int) (n int16, err error)
- func (m *Decoder) Word(addr int) (n uint16, err error)
- func (m *Decoder) Write(addr int, p []byte) (n int, err error)
- type Mapper
- type Memory
Examples ¶
Constants ¶
const ( MinAddress uint32 = 0 MaxAddress uint32 = 0xFFFFFF )
Variables ¶
This section is empty.
Functions ¶
func AccessViolationError ¶
AccessViolationError returns an error indicating a memory address access violation for the given address.
Types ¶
type Decoder ¶
type Decoder struct { M Memory // contains filtered or unexported fields }
A Decoder provides native type decoding for a Memory interface.
func NewDecoder ¶
NewDecoder returns a new Decoder for the given Memory interface.
func (*Decoder) Long ¶
Long reads a single 32-bit unsigned long from the underlying Memory interface.
func (*Decoder) Slong ¶
Slong reads a single 32-bit signed long from the underlying Memory interface.
func (*Decoder) Sword ¶
Sword reads a single 16-bit signed word from the underlying Memory interface.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
A Mapper allows a Motorola 68000 processor to communicate with external devices using a memory address, mapped into its addressable range.
Example ¶
// create a memory mapper m := NewMapper() // map a ROM device to 0x00 dev1 := NewROM([]byte("This is device one.............\n")) m.Map(dev1, 0, 0x1F) // map a ROM device to 0x20 dev2 := NewROM([]byte("This is device two.............\n")) m.Map(dev2, 0x20, 0x3F) // map a ROM device to 0x40 dev3 := NewROM([]byte("This is device three...........\n")) m.Map(dev3, 0x40, 0x5F) // read 96 bytes from the memory mapper b := make([]byte, 0x60) m.Read(0, b) fmt.Print(string(b))
Output: This is device one............. This is device two............. This is device three...........
type Memory ¶
type Memory interface { Read(addr int, p []byte) (n int, err error) Write(addr int, p []byte) (n int, err error) Reset() (err error) }
Memory is an interface for any IO device that is addressable via memory mapping. This interface will be satisfied by random access memory, a virtual memory manager, peripheral devices, etc.
func AttachBus ¶
AttachBus protects all accesses to the given Memory device with a 68000 A23-A0 Address Bus emulator. The bus ensures all 32-bit addresses are reduced to a 24-bit address by masking the 8 most significant bits.
func Mirror ¶
Mirror returns a new Mirror for the given Memory interface. If n is the size of the mirrored device, then r is the size of the range across which it is mirrored.
func NewNop ¶
func NewNop() Memory
NewNop returns a No-Operation memory device that neither stores nor retrieves data. It serves only for debug or placeholder purposes.
func NewRAM ¶
NewRAM returns Random Access Memory initialized to the given size. This memory can used to load programs and data for a 68000 processor. Memory access is protected by an AddressBus.
func NewROM ¶
NewROM returns Read-Only Memory initialized with the given byte data. This memory can be used to load programs and data for a 68000 processor. Memory access is protected by an AddressBus.
func NewTracer ¶
NewTracer wraps a memory device to log all reads and write to the given io.Writer.
Example ¶
m := NewTracer("ram", os.Stdout, NewRAM(64)) m.Write(0x10, []byte("Hello world!\n")) m.Read(0x10, make([]byte, 13))
Output: 00000010 [ram] wrote 13 bytes: 48656c6c6f20776f726c64210a 00000010 [ram] read 13 bytes: 48656c6c6f20776f726c64210a