neon

package module
v0.0.0-...-6eb16da Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 0

README

Neon

Neon is a fantasy CPU loosely inspired by the video game Shenzhen I/O.

Please see the manual for a detailed description.

Status

  • CLI that can compile and run programs.
  • WASM app that does the same thing on the browser.
  • Graphics system, backed by HTML5 Canvas.
  • Optional: Sound, video, 3D, etc.

Commands

The following commands assume you have cloned this repository and navigated to its root.

See it in action
go run git.gay/lewdum/neon/cmd/neon -r -m examples/loop.neon
Install it locally
go install git.gay/lewdum/neon/cmd/neon

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	// Accumulators:
	A, B uint8

	// Addresses:
	PC uint16 // program counter
	SP uint16 // stack pointer

	// Flags:
	T bool // test
	C bool // carry
	I bool // interrupt disable
	J bool // jump disable

	// Data:
	RAM [0xFFFF + 1]byte

	// Debugger hooks:
	OnStep  func(addr uint16, cd Condition, op Operator)
	OnError func(error) Interrupt

	// Subsystems:
	Rand *rand.Rand
}

func New

func New() *CPU

func (*CPU) Load

func (c *CPU) Load(data []byte)

func (*CPU) Run

func (c *CPU) Run() Interrupt

func (*CPU) Step

func (c *CPU) Step() Interrupt

type Condition

type Condition byte
const (
	Always Condition = iota
	IfTrue
	IfFalse
	Randomly
)

func (Condition) String

func (c Condition) String() string

type Interrupt

type Interrupt uint8
const NoInterrupt Interrupt = 0

type Operator

type Operator byte
const (
	NOP Operator = iota
	LAI
	LAM
	LAB
	LBI
	LBM
	LBA
	SWP
	STA
	STB
	ADI
	ADM
	ADB
	ACI
	ACM
	ACB
	INA
	INB
	SBI
	SBM
	SBB
	SCI
	SCM
	SCB
	DEA
	DEB
	TEI
	TEM
	TEB
	TGI
	TGM
	TGB
	TLI
	TLM
	TLB
	TFC
	TFI
	JMP
	JRF
	JRB
	JSR
	RET
	SET
	SEC
	SEI
	SEJ
	CLT
	CLC
	CLI
	CLJ
	INT
)

func (Operator) String

func (i Operator) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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