assembunny

package
v0.0.0-...-68053d7 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op struct {
	Name string
	X    string
	Y    string
	Z    string
}

type State

type State struct {
	Ops     []Op
	IP      int
	Regs    [4]int
	Error   error
	Debug   bool
	Outputs []int
}

func Parse

func Parse(inputs []string) (*State, error)

Parse an assembunny program.

func (*State) GetRegister

func (s *State) GetRegister(reg string) (int, error)

GetRegister returns the value of the given register, a, b, c, or d.

func (*State) Reset

func (s *State) Reset()

Reset the assembunny machine back to its starting state, but leaving the Ops alone (if `tgl` instructions have changed them, those changes with NOT be undone).

func (*State) SetRegister

func (s *State) SetRegister(reg string, value int) error

SetRegister sets the value of the given register, a, b, c, or d.

func (*State) Step

func (s *State) Step() bool

Step the assembunny computer one instruction forward. Returns true when finished, whether successfully or due to an error.

func (*State) StepUntilOutput

func (s *State) StepUntilOutput() (int, bool)

StepUntilOutput clears the Output, then steps until `Step()` returns `true`, or an output is emitted. If the boolean is true, the machine halted before outputting anything. Otherwise the integer holds the output.

Jump to

Keyboard shortcuts

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