machine

package
v0.0.0-...-38c8f7e Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHalt = errors.New("machine: halt")

Functions

This section is empty.

Types

type Instruction

type Instruction struct {
	Opcode Opcode
	Arg    int
}

func CloneProgram

func CloneProgram(program []Instruction) []Instruction

func ParseProgram

func ParseProgram(program []string) ([]Instruction, error)

type Machine

type Machine struct {
	PC  int
	Acc int
	// contains filtered or unexported fields
}

func New

func New(program []Instruction) *Machine

func (*Machine) Step

func (m *Machine) Step() error

type Opcode

type Opcode int
const (
	OpAcc Opcode = iota
	OpJmp
	OpNop
)

Jump to

Keyboard shortcuts

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