Version: v0.0.0-...-3f1fa26 Latest Latest

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 6 Imported by: 0




This section is empty.


This section is empty.


func Instruction_Length

func Instruction_Length(instr Instruction) (int, error)

func IsInt

func IsInt(op Operand) bool

func IsRegister

func IsRegister(op Operand) bool


type Instruction

type Instruction interface {
	Encode() (MachineCode, error)
	String() string

type Instructions

type Instructions []Instruction

func (Instructions) Add

func (Instructions) Encode

func (i Instructions) Encode() (MachineCode, error)

func (Instructions) String

func (i Instructions) String() string

type MachineCode

type MachineCode []uint8

func CompileInstruction

func CompileInstruction(instr []Instruction, debug bool) (MachineCode, error)

func (MachineCode) Add

func (MachineCode) Execute

func (m MachineCode) Execute(debug bool) int

func (MachineCode) String

func (m MachineCode) String() string

type Operand

type Operand interface {
	Type() Type
	String() string
	Width() Size

type Size

type Size uint8
const (
	BYTE     Size = 1
	WORD     Size = 2
	DOUBLE   Size = 4
	QUADWORD Size = 8
	OWORD    Size = 16
	YWORD    Size = 32
	ZWORD    Size = 64

type Type

type Type uint8
const (
	T_Register          Type = iota // e.g. %rax
	T_IndirectRegister  Type = iota // e.g. (%rax)
	T_RIPRelative       Type = iota // e.g. -$0x18(%rip)
	T_SIBRegister       Type = iota // e.g. (%rax, %rcx, 8)  (the address of %rxc * 8 + %rax)
	T_DisplacedRegister Type = iota // e.g. 0x9(%rax)
	// TODO
	T_DisplacedSIBRegister Type = iota // e.g. 0x9(%rax, %rcx, 8) the address of %rcx * 8 + %rax + 9)
	T_Uint8                Type = iota
	T_Uint16               Type = iota
	T_Uint32               Type = iota
	T_Uint64               Type = iota
	T_Int32                Type = iota
	T_Float32              Type = iota
	T_Float64              Type = iota

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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