arch

package
v0.0.0-...-cf91f57 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None Opcode = 0

	ADD  = 1
	ADDI = 2
	SUB  = 3
	SUBI = 4
	AND  = 5
	OR   = 6
	XOR  = 7
	LSL  = 8
	LSR  = 9

	LDREG  = 20
	LDWORD = 21
	LDHWRD = 22
	LDBYTE = 23
	STREG  = 24
	STWORD = 25
	STHWRD = 26
	STBYTE = 27

	MOVZ = 30
	MOVK = 31

	B     = 32
	BREG  = 33
	BLR   = 34
	B_EQ  = 35
	B_NEQ = 36
	B_LT  = 37
	B_LE  = 38
	B_GT  = 39
	B_GE  = 40
	BL    = 41

	PUSH = 42
	POP  = 43

	SYSCALL = 61
	HALT    = 62
	NOOP    = 63
)
View Source
const (
	ENO_IO                = 1
	ENO_BadFileDescriptor = 2
)

Variables

View Source
var (
	ByteOrder = binary.LittleEndian
)

Functions

This section is empty.

Types

type ATypeImmInstruction

type ATypeImmInstruction struct {
	Opcode    Opcode
	RegDest   RegisterValue
	RegA      RegisterValue
	Immediate uint16
}

func DecodeATypeImmInstruction

func DecodeATypeImmInstruction(instruction Instruction, opcode Opcode) ATypeImmInstruction

type ATypeInstruction

type ATypeInstruction struct {
	Opcode  Opcode
	RegDest RegisterValue
	RegA    RegisterValue
	RegB    RegisterValue
}

func DecodeATypeInstruction

func DecodeATypeInstruction(instruction Instruction, opcode Opcode) ATypeInstruction

type BTypeImmInstruction

type BTypeImmInstruction struct {
	Opcode Opcode
	Offset int16
}

func DecodeBTypeImmInstruction

func DecodeBTypeImmInstruction(instruction Instruction, opcode Opcode) BTypeImmInstruction

type BTypeInstruction

type BTypeInstruction struct {
	Opcode Opcode
	RegA   RegisterValue
}

func DecodeBTypeInstruction

func DecodeBTypeInstruction(instruction Instruction, opcode Opcode) BTypeInstruction

type ETypeInstruction

type ETypeInstruction struct {
	Opcode    Opcode
	RegDest   RegisterValue
	Immediate uint16
}

func DecodeETypeInstruction

func DecodeETypeInstruction(instruction Instruction, opcode Opcode) ETypeInstruction

type Instruction

type Instruction = uint32

func EncodeATypeImmInstruction

func EncodeATypeImmInstruction(instruction ATypeImmInstruction) Instruction

func EncodeATypeInstruction

func EncodeATypeInstruction(instruction ATypeInstruction) Instruction

func EncodeBTypeImmInstruction

func EncodeBTypeImmInstruction(instruction BTypeImmInstruction) Instruction

func EncodeBTypeInstruction

func EncodeBTypeInstruction(instruction BTypeInstruction) Instruction

func EncodeETypeInstruction

func EncodeETypeInstruction(instruction ETypeInstruction) Instruction

func EncodeMTypeInstruction

func EncodeMTypeInstruction(instruction MTypeInstruction) Instruction

func EncodeOTypeInstruction

func EncodeOTypeInstruction(instruction OTypeInstruction) Instruction

func EncodeRTypeInstruction

func EncodeRTypeInstruction(instruction RTypeInstruction) Instruction

type InstructionType

type InstructionType uint8
const (
	IType_Invalid InstructionType = iota
	IType_A
	IType_AI
	IType_M
	IType_E
	IType_B
	IType_BI
	IType_R
	IType_O
)

func GetInstructionType

func GetInstructionType(opcode Opcode) InstructionType

type MTypeInstruction

type MTypeInstruction struct {
	Opcode    Opcode
	RegA      RegisterValue
	RegB      RegisterValue
	Immediate int16
}

func DecodeMTypeInstruction

func DecodeMTypeInstruction(instruction Instruction, opcode Opcode) MTypeInstruction

type OTypeInstruction

type OTypeInstruction struct {
	Opcode Opcode
}

func DecodeOTypeInstruction

func DecodeOTypeInstruction(instruction Instruction, opcode Opcode) OTypeInstruction

type Opcode

type Opcode uint8

func GetOpcode

func GetOpcode(instruction Instruction) Opcode

func (Opcode) String

func (o Opcode) String() string

type RTypeInstruction

type RTypeInstruction struct {
	Opcode Opcode
	RegA   RegisterValue
}

func DecodeRTypeInstruction

func DecodeRTypeInstruction(instruction Instruction, opcode Opcode) RTypeInstruction

type RegisterValue

type RegisterValue = uint8
const (
	ZeroRegister          RegisterValue = 0
	SyscallResultRegister RegisterValue = 7
	SyscallErrorRegister  RegisterValue = 8
	SyscallRegister       RegisterValue = 9
	StackRegister         RegisterValue = 14
	ReturnRegister        RegisterValue = 15
)

Jump to

Keyboard shortcuts

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