Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadOperands ¶
func ReadOperands(def *Definition, ins Instructions) ([]int, int)
ReadOperands disassembles a single instruction
func ReadUint16 ¶
ReadUint16 reads the next two bytes in the instructions as a 16 bit number
Types ¶
type Definition ¶
type Definition struct {
// The name of the opcode
Name string
// The length of the entire instruction
TotalLength int
// Lengths of all the operands
OperandWidths []int
}
Definition defines a single instruction - opcode and operand widths
type Instructions ¶
type Instructions []byte
Instructions = the program
func (Instructions) String ¶
func (ins Instructions) String() string
type Opcode ¶
type Opcode byte
Opcode represents a single instruction carried out by the VM
const ( // OpPush - retrieves a constant via its operand and pushes it OpPush Opcode = iota // OpPop - Pops the topmost element off the stack OpPop // OpAdd - Pops the top two values off the stack, adds them and pushes the result OpAdd // OpSub - Does the same thing as OpAdd, but performs subtraction OpSub // OpMul - OpSub but multiplication OpMul // OpDiv - OpMul but division OpDiv // OpBWAnd - Bitwise And OpBWAnd // OpBWOr - Bitwise Or OpBWOr // OpBWXOR - Bitwise XOR OpBWXOR // OpBWNOT - Bitwise NOT OpBWNOT // OpTrue - Pushes true to the stack OpTrue // OpFalse - Pushes false to the stack OpFalse // OpEq - Tells the vm to test two objects for equality OpEq // OpNE - Tells the vm to test for inequality OpNE // OpGT - Tells the vm to test for greater than OpGT // OpGE - Tells the vm to test for greater than or equal to OpGE // OpMinus - For prefix negation OpMinus // OpBang - For boolean negation OpBang )
Click to show internal directories.
Click to hide internal directories.