Documentation ¶
Index ¶
- Variables
- func Calculate(a int, b int, t CalculateType, d DataType) int
- func Compare(a Operand, b Operand, d DataType) int
- func Execute(ctx context.Context, rt Runtime, inst *Inst)
- type AddressMode
- type CalculateType
- type CompareType
- type DataType
- type Inst
- type Memory
- type Opcode
- type Operand
- type Register
- type RegisterType
- type Runtime
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDataToShort = errors.NewClass("ErrDataToShort")
View Source
var ErrWrongInst = errors.NewClass("ErrWrongInst")
Functions ¶
Types ¶
type AddressMode ¶
type AddressMode uint8
const ( AddressRegister AddressMode = iota // 寄存器寻址 AddressRegisterDeferred // 寄存器间接寻址 AddressImmediate // 立即数 AddressDirect // 直接寻址 )
func (AddressMode) String ¶
func (v AddressMode) String() string
type CalculateType ¶
type CalculateType uint8
const ( ADD CalculateType = iota SUB MUL DIV MOD )
func (CalculateType) String ¶
func (c CalculateType) String() string
type CompareType ¶
type CompareType uint8
const ( Z CompareType = iota + 1 // Equal B // Blow BE // Blow or Equal A // Above AE // Above or Equal NZ // Not Equal )
func (CompareType) IsMatch ¶
func (ct CompareType) IsMatch(b CompareType) bool
func (CompareType) String ¶
func (ct CompareType) String() string
type Inst ¶
type Inst struct { DataType DataType CompareType CompareType CalculateType CalculateType Opcode Opcode A Operand B Operand Line int Comment string }
func (*Inst) GetComment ¶
func (*Inst) MarshalBinary ¶
func (*Inst) SetComment ¶
func (*Inst) UnmarshalBinary ¶
type Operand ¶
type Operand struct { V int32 // Address or Immediate value AddressMode AddressMode RT Runtime Symbol string // Symbol associated to this operand - run from assembly }
type RegisterType ¶
type RegisterType uint8
const ( RP RegisterType = iota // 程序计数器,指令寻址寄存器 RF // 标志寄存器,存储比较操作结果 RS // 栈寄存器 - 空栈顶地址,指向的是下一个准备要压入数据的位置 RB // 辅助栈寄存器 - 栈开始的地址(文件长度+2) R0 // #0 寄存器 R1 // #1 寄存器 R2 // #2 寄存器 R3 // #3 寄存器 )
func (RegisterType) String ¶
func (r RegisterType) String() string
Click to show internal directories.
Click to hide internal directories.