instruction

package
v0.0.0-...-0235693 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instruction

type Instruction struct {
	Op    Operation
	Value int
}

func Parse

func Parse(s string) (Instruction, error)

func ParseMany

func ParseMany(r io.Reader) ([]Instruction, error)

func (Instruction) IsValid

func (i Instruction) IsValid() bool

func (Instruction) String

func (i Instruction) String() string

type Machine

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

func NewMachine

func NewMachine(is []Instruction) *Machine

func (*Machine) Acc

func (m *Machine) Acc() int

func (*Machine) Exec

func (m *Machine) Exec() (int, error)

func (*Machine) ExecNext

func (m *Machine) ExecNext() error

func (*Machine) ExecOneLoop

func (m *Machine) ExecOneLoop() (int, error)

func (*Machine) Reset

func (m *Machine) Reset()

type Operation

type Operation string
const (
	Acc Operation = "acc"
	Jmp Operation = "jmp"
	Nop Operation = "nop"
)

Jump to

Keyboard shortcuts

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