iris16

package
v0.0.0-...-1646a41 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2016 License: BSD-2-Clause Imports: 8 Imported by: 2

Documentation

Overview

machine description of iris1

move related operations

Index

Constants

View Source
const (
	// arithmetic operations
	ArithmeticOpAdd = iota
	ArithmeticOpSub
	ArithmeticOpMul
	ArithmeticOpDiv
	ArithmeticOpRem
	ArithmeticOpShiftLeft
	ArithmeticOpShiftRight
	ArithmeticOpBinaryAnd
	ArithmeticOpBinaryOr
	ArithmeticOpBinaryNot
	ArithmeticOpBinaryXor
	ArithmeticOpIncrement
	ArithmeticOpDecrement
	ArithmeticOpDouble
	ArithmeticOpHalve
	ArithmeticOpAddImmediate
	ArithmeticOpSubImmediate
	ArithmeticOpMulImmediate
	ArithmeticOpDivImmediate
	ArithmeticOpRemImmediate
	ArithmeticOpShiftLeftImmediate
	ArithmeticOpShiftRightImmediate
	// always last
	ArithmeticOpCount
)
View Source
const (
	// Compare operations
	CompareOpEq = iota
	CompareOpEqAnd
	CompareOpEqOr
	CompareOpEqXor
	CompareOpNeq
	CompareOpNeqAnd
	CompareOpNeqOr
	CompareOpNeqXor
	CompareOpLessThan
	CompareOpLessThanAnd
	CompareOpLessThanOr
	CompareOpLessThanXor
	CompareOpGreaterThan
	CompareOpGreaterThanAnd
	CompareOpGreaterThanOr
	CompareOpGreaterThanXor
	CompareOpLessThanOrEqualTo
	CompareOpLessThanOrEqualToAnd
	CompareOpLessThanOrEqualToOr
	CompareOpLessThanOrEqualToXor
	CompareOpGreaterThanOrEqualTo
	CompareOpGreaterThanOrEqualToAnd
	CompareOpGreaterThanOrEqualToOr
	CompareOpGreaterThanOrEqualToXor

	CompareOpCount
)
View Source
const (
	CombineNone = iota
	CombineAnd
	CombineOr
	CombineXor
	CombineError
)
View Source
const (
	CompareBodyEq = iota
	CompareBodyNeq
	CompareBodyLt
	CompareBodyGt
	CompareBodyLe
	CompareBodyGe
	CompareBodyError
)
View Source
const (
	RegisterCount            = 256
	MemorySize               = 65536
	MajorOperationGroupCount = 8
	SystemCallCount          = 256
)
View Source
const (
	// reserved registers
	FalseRegister = iota
	TrueRegister
	InstructionPointer
	StackPointer
	PredicateRegister
	CallPointer
	UserRegisterBegin
)
View Source
const (
	// Error codes
	ErrorNone = iota
	ErrorPanic
	ErrorGetRegisterOutOfRange
	ErrorPutRegisterOutOfRange
	ErrorInvalidInstructionGroupProvided
	ErrorInvalidArithmeticOperation
	ErrorInvalidMoveOperation
	ErrorInvalidJumpOperation
	ErrorInvalidCompareOperation
	ErrorInvalidMiscOperation
	ErrorInvalidSystemCommand
	ErrorWriteToFalseRegister
	ErrorWriteToTrueRegister
	ErrorEncodeByteOutOfRange
	ErrorGroupValueOutOfRange
	ErrorOpValueOutOfRange
)
View Source
const (
	// Instruction groups
	InstructionGroupArithmetic = iota
	InstructionGroupMove
	InstructionGroupJump
	InstructionGroupCompare
	InstructionGroupMisc
)
View Source
const (
	// Misc operations
	MiscOpSystemCall = iota
	NumberOfMiscOperations
)
View Source
const (
	// Move Operations
	MoveOpMove = iota
	MoveOpSwap
	MoveOpSet
	MoveOpLoad
	MoveOpStore
	MoveOpPush
	MoveOpPop
	MoveOpPeek
	MoveOpLoadCode
	MoveOpStoreCode
	// always last
	MoveOpCount
)
View Source
const (
	// System commands
	SystemCallTerminate = iota
	SystemCallPanic
	SystemCallPutc
	NumberOfSystemCalls
)
View Source
const (
	DivideByZeroMessage = "Divide by zero error!"
)

Variables

This section is empty.

Functions

func InvalidRegister

func InvalidRegister(value string) error

func NewError

func NewError(code, value uint) error

func RegistrationName

func RegistrationName() string

Types

type ArithmeticOp

type ArithmeticOp struct {
	ImmediateForm bool
	Fn            func(Word, Word) (Word, error)
}

func (*ArithmeticOp) Invoke

func (this *ArithmeticOp) Invoke(first, second Word) (Word, error)

type Core

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

func New

func New() (*Core, error)

func (*Core) AdvanceProgramCounter

func (this *Core) AdvanceProgramCounter() error

func (*Core) Call

func (this *Core) Call(addr Word) error

func (*Core) CallMemory

func (this *Core) CallMemory(address Word) Word

func (*Core) CodeMemory

func (this *Core) CodeMemory(address Word) Instruction

func (*Core) CurrentInstruction

func (this *Core) CurrentInstruction() Instruction

func (*Core) DataMemory

func (this *Core) DataMemory(address Word) Word

func (*Core) Dispatch

func (this *Core) Dispatch(inst Instruction) error

func (*Core) Dump

func (this *Core) Dump(output chan<- byte) error

func (*Core) ExecuteCurrentInstruction

func (this *Core) ExecuteCurrentInstruction() error

func (*Core) GetDebugStatus

func (this *Core) GetDebugStatus() bool

func (*Core) HaltExecution

func (this *Core) HaltExecution()

func (*Core) InstallExecutionUnit

func (this *Core) InstallExecutionUnit(group byte, fn ExecutionUnit) error

func (*Core) InstallProgram

func (this *Core) InstallProgram(input <-chan byte) error

func (*Core) InstallSystemCall

func (this *Core) InstallSystemCall(offset byte, fn SystemCall) error

func (*Core) InstructionAddress

func (this *Core) InstructionAddress() Word

func (*Core) Invoke

func (this *Core) Invoke(inst *DecodedInstruction) error

func (*Core) IoMemory

func (this *Core) IoMemory(address Word) (Word, error)

func (*Core) MicrocodeMemory

func (this *Core) MicrocodeMemory(address Word) Word

func (*Core) NextInstructionAddress

func (this *Core) NextInstructionAddress() Word

func (*Core) Peek

func (this *Core) Peek() Word

func (*Core) Pop

func (this *Core) Pop() Word

func (*Core) PredicateValue

func (this *Core) PredicateValue(index byte) bool

func (*Core) Push

func (this *Core) Push(value Word)

func (*Core) Register

func (this *Core) Register(index byte) Word

func (*Core) RegisterIoDevice

func (this *Core) RegisterIoDevice(dev IoDevice) error

func (*Core) ResumeExecution

func (this *Core) ResumeExecution()

func (*Core) Return

func (this *Core) Return() Word

func (*Core) Run

func (this *Core) Run() error

func (*Core) SetCallMemory

func (this *Core) SetCallMemory(address, value Word) error

func (*Core) SetCodeMemory

func (this *Core) SetCodeMemory(address Word, value Instruction) error

func (*Core) SetDataMemory

func (this *Core) SetDataMemory(address, value Word) error

func (*Core) SetDebug

func (this *Core) SetDebug(_ bool)

func (*Core) SetIoMemory

func (this *Core) SetIoMemory(address, value Word) error

func (*Core) SetMicrocodeMemory

func (this *Core) SetMicrocodeMemory(address, value Word) error

func (*Core) SetRegister

func (this *Core) SetRegister(index byte, value Word) error

func (*Core) SetStackMemory

func (this *Core) SetStackMemory(address, value Word) error

func (*Core) ShouldExecute

func (this *Core) ShouldExecute() bool

func (*Core) Shutdown

func (this *Core) Shutdown() error

func (*Core) StackMemory

func (this *Core) StackMemory(address Word) Word

func (*Core) Startup

func (this *Core) Startup() error

func (*Core) SystemCall

func (this *Core) SystemCall(inst *DecodedInstruction) error

func (*Core) TerminateExecution

func (this *Core) TerminateExecution() bool

type DecodedInstruction

type DecodedInstruction struct {
	Group byte
	Op    byte
	Data  [3]byte
}

func NewDecodedInstruction

func NewDecodedInstruction(group, op, data0, data1, data2 byte) (*DecodedInstruction, error)

func NewDecodedInstructionImmediate

func NewDecodedInstructionImmediate(group, op, data0 byte, imm Word) (*DecodedInstruction, error)

func (*DecodedInstruction) Encode

func (this *DecodedInstruction) Encode() *Instruction

func (*DecodedInstruction) Immediate

func (this *DecodedInstruction) Immediate() Word

func (*DecodedInstruction) SetImmediate

func (this *DecodedInstruction) SetImmediate(value Word)

type Dword

type Dword uint32

type ExecutionUnit

type ExecutionUnit func(*Core, *DecodedInstruction) error

type Instruction

type Instruction Dword

func (Instruction) Decode

func (this Instruction) Decode() (*DecodedInstruction, error)

type IoDevice

type IoDevice interface {
	Begin() Word
	End() Word
	Load(address Word) (Word, error)
	Store(address, value Word) error
	RespondsTo(address Word) bool
	Startup() error
	Shutdown() error
}

type IrisError

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

func (IrisError) Error

func (this IrisError) Error() string

type MoveOp

type MoveOp func(*Core, *DecodedInstruction) error

func (MoveOp) Invoke

func (fn MoveOp) Invoke(core *Core, inst *DecodedInstruction) error

type SystemCall

type SystemCall ExecutionUnit

type Word

type Word uint16

Jump to

Keyboard shortcuts

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