host

package module
v0.0.0-...-398f498 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package host allows you to create a "host" that emulates a computer system with a 6502 CPU, 64K of memory, a built-in assembler, a built-in debugger, and other useful tools.

Within the host it is possible to assemble and load machine code into memory, debug and step through machine code, measure the number of CPU cycles elapsed, set address and data breakpoints, dump the contents of memory, disassemble the contents of memory, manipulate CPU registers and memory, and evaluate arbitrary expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	// contains filtered or unexported fields
}

A Host represents a fully emulated 6502 system, 64K of memory, a built-in assembler, a built-in debugger, and other useful tools.

func New

func New() *Host

New creates a new 6502 host environment.

func (*Host) AssembleFile

func (h *Host) AssembleFile(filename string) error

AssembleFile assembles a file on disk and stores the result in a compiled 'bin' file. A source map file is also produced.

func (*Host) Break

func (h *Host) Break()

Break interrupts a running CPU.

func (*Host) Cleanup

func (h *Host) Cleanup()

Cleanup cleans up all resources initialized by the call to New().

func (*Host) EnableProcessedMode

func (h *Host) EnableProcessedMode(r io.Reader, w io.Writer) *IoState

EnableProcessedMode disables raw mode and enters the processed I/O mode, where input is read from the reader r and output is written to the writer w. The original I/O state is returned so that it may be restored afterwards.

func (*Host) EnableRawMode

func (h *Host) EnableRawMode() *IoState

EnableRawMode enables the raw interactive console mode. The original I/O state is returned so that it may be restored afterwards.

func (*Host) OnBreakpoint

func (h *Host) OnBreakpoint(cpu *cpu.CPU, b *cpu.Breakpoint)

OnBreakpoint is called when the debugger encounters a code breakpoint.

func (*Host) OnBrk

func (h *Host) OnBrk(cpu *cpu.CPU)

OnBrk is called when the CPU is about to execute a BRK instruction.

func (*Host) OnDataBreakpoint

func (h *Host) OnDataBreakpoint(cpu *cpu.CPU, b *cpu.DataBreakpoint)

OnDataBreakpoint is called when the debugger encounters a data breakpoint.

func (*Host) RestoreIoState

func (h *Host) RestoreIoState(state *IoState)

RestoreIoState restores a previously saved I/O state.

func (*Host) RunCommands

func (h *Host) RunCommands(interactive bool)

RunCommands accepts host commands from a reader and outputs the results to a writer. If the commands are interactive, a prompt is displayed while the host waits for the the next command to be entered.

func (*Host) Write

func (h *Host) Write(p []byte) (n int, err error)

Write writes the contents of p into the output device currently assigned to the host. It returns the number of bytes written.

type IoState

type IoState struct {
	// contains filtered or unexported fields
}

IoState represents the state of the host's I/O subsystem. It is returned by calls to EnableRawMode and EnableProcessedMode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL