instructions

package
v0.0.0-...-193fe54 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	IHeaderHlt uint8 = 0x00 // Halt
	IHeaderDbg uint8 = 0x01 // Debug

	IHeaderMovLiteral  uint8 = 0x08 // Move value
	IHeaderMovRegister uint8 = 0x09 // Move register

	IHeaderPush uint8 = 0x10 // Push value
	IHeaderDup  uint8 = 0x11 // Duplicate value
	IHeaderDrop uint8 = 0x12 // Drop value
	IHeaderSwap uint8 = 0x13 // Swap values

	IHeaderLd uint8 = 0x20 // Load value
	IHeaderSt uint8 = 0x21 // Store value

	IHeaderAdd uint8 = 0x30 // Add
	IHeaderSub uint8 = 0x31 // Subtract
	IHeaderMul uint8 = 0x32 // Multiply
	IHeaderDiv uint8 = 0x33 // Divide
	IHeaderMod uint8 = 0x34 // Modulo

	IHeaderLabel uint8 = 0xA0 // Label
	IHeaderCall  uint8 = 0xA1 // Call
	IHeaderJmp   uint8 = 0xA2 // Jump
	IHeaderJmpZ  uint8 = 0xA3 // Jump if zero
	IHeaderJmpNZ uint8 = 0xA4 // Jump if not zero
	IHeaderJmpP  uint8 = 0xA5 // Jump if positive
	IHeaderJmpN  uint8 = 0xA6 // Jump if negative
	IHeaderRet   uint8 = 0xA7 // Return

	IHeaderPutN uint8 = 0xB0 // Put number
	IHeaderPutC uint8 = 0xB1 // Put character
)
View Source
const (
	ISizeHlt = 1 // {header}
	ISizeDbg = 1 // {header}

	ISizeMovLiteral  = 10 // {header, reg, value[8]}
	ISizeMovRegister = 3  // {header, reg, source}

	ISizePush = 9 // {header, value[8]}
	ISizeDup  = 1 // {header}
	ISizeDrop = 1 // {header}
	ISizeSwap = 1 // {header}

	ISizeLd = 2 // {header, reg}
	ISizeSt = 2 // {header, reg}

	ISizeAdd = 1 // {header}
	ISizeSub = 1 // {header}
	ISizeMul = 1 // {header}
	ISizeDiv = 1 // {header}
	ISizeMod = 1 // {header}

	ISizeLabel = 3 // {header, label[2]}
	ISizeCall  = 3 // {header, label[2]}
	ISizeJmp   = 3 // {header, label[2]}
	ISizeJmpZ  = 3 // {header, label[2]}
	ISizeJmpNZ = 3 // {header, label[2]}
	ISizeJmpP  = 3 // {header, label[2]}
	ISizeJmpN  = 3 // {header, label[2]}
	ISizeRet   = 1 // {header}

	ISizePutN = 1 // {header}
	ISizePutC = 1 // {header}
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstAdd

type InstAdd struct{}

func (InstAdd) Emit

func (i InstAdd) Emit() []byte

type InstCall

type InstCall struct {
	Label uint16
}

func (InstCall) Emit

func (i InstCall) Emit() []byte

type InstDbg

type InstDbg struct{}

func (InstDbg) Emit

func (i InstDbg) Emit() []byte

type InstDiv

type InstDiv struct{}

func (InstDiv) Emit

func (i InstDiv) Emit() []byte

type InstDrop

type InstDrop struct{}

func (InstDrop) Emit

func (i InstDrop) Emit() []byte

type InstDup

type InstDup struct{}

func (InstDup) Emit

func (i InstDup) Emit() []byte

type InstHlt

type InstHlt struct{}

func (InstHlt) Emit

func (i InstHlt) Emit() []byte

type InstJmp

type InstJmp struct {
	Label uint16
}

func (InstJmp) Emit

func (i InstJmp) Emit() []byte

type InstJmpN

type InstJmpN struct {
	Label uint16
}

func (InstJmpN) Emit

func (i InstJmpN) Emit() []byte

type InstJmpNZ

type InstJmpNZ struct {
	Label uint16
}

func (InstJmpNZ) Emit

func (i InstJmpNZ) Emit() []byte

type InstJmpP

type InstJmpP struct {
	Label uint16
}

func (InstJmpP) Emit

func (i InstJmpP) Emit() []byte

type InstJmpZ

type InstJmpZ struct {
	Label uint16
}

func (InstJmpZ) Emit

func (i InstJmpZ) Emit() []byte

type InstLabel

type InstLabel struct {
	Label uint16
}

func (InstLabel) Emit

func (i InstLabel) Emit() []byte

type InstLd

type InstLd struct {
	Register uint8
}

func (InstLd) Emit

func (i InstLd) Emit() []byte

type InstMod

type InstMod struct{}

func (InstMod) Emit

func (i InstMod) Emit() []byte

type InstMovLiteral

type InstMovLiteral struct {
	Register uint8
	Value    int64
}

func (InstMovLiteral) Emit

func (i InstMovLiteral) Emit() []byte

type InstMovRegister

type InstMovRegister struct {
	Register uint8
	Source   uint8
}

func (InstMovRegister) Emit

func (i InstMovRegister) Emit() []byte

type InstMul

type InstMul struct{}

func (InstMul) Emit

func (i InstMul) Emit() []byte

type InstPush

type InstPush struct {
	Value int64
}

func (InstPush) Emit

func (i InstPush) Emit() []byte

type InstPutC

type InstPutC struct{}

func (InstPutC) Emit

func (i InstPutC) Emit() []byte

type InstPutN

type InstPutN struct{}

func (InstPutN) Emit

func (i InstPutN) Emit() []byte

type InstRet

type InstRet struct{}

func (InstRet) Emit

func (i InstRet) Emit() []byte

type InstSt

type InstSt struct {
	Register uint8
}

func (InstSt) Emit

func (i InstSt) Emit() []byte

type InstSub

type InstSub struct{}

func (InstSub) Emit

func (i InstSub) Emit() []byte

type InstSwap

type InstSwap struct{}

func (InstSwap) Emit

func (i InstSwap) Emit() []byte

type Instruction

type Instruction interface {
	Emit() []byte
}

Jump to

Keyboard shortcuts

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