emu

package
v0.0.0-...-9fd96d6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeInstruction

func DecodeInstruction(memory *Memory, address int) (*asm.EvaluatedInstruction, error)

Gets the value of the given memory address, as an EvaluatedLine.

Types

type CPU

type CPU struct {
	// Registers
	ProgramCounter      *Register
	InstructionRegister *Register
	AddressRegister     *Register
	Accumulator         *Register

	// Other
	Instructions map[asm.Opcode]Instruction
}

func CreateLmcCpu

func CreateLmcCpu() *CPU

func (*CPU) Execute

func (c *CPU) Execute(memory *Memory) error

type Instruction

type Instruction func(cpu *CPU, memory *Memory) bool

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

A representation of RAM within an emulated system.

func CreateMemory

func CreateMemory(initialValues [100]int) *Memory

Creates memory with the provided initial values

func (*Memory) GetValue

func (m *Memory) GetValue(address int) int

Gets the integer value of a given memory address.

func (*Memory) SetValue

func (m *Memory) SetValue(address int, value int)

Sets the integer value of a given memory address.

type Register

type Register struct {
	// contains filtered or unexported fields
}

A representation of a register within a CPU.

func CreateRegister

func CreateRegister(initialValue int) *Register

Creates a register, using the provided data

func (*Register) GetValue

func (r *Register) GetValue() int

Gets the integer value of the register.

func (*Register) Increment

func (r *Register) Increment()

Increments the integer value of the register by 1.

func (*Register) IncrementAndGet

func (r *Register) IncrementAndGet() int

Gets the integer value of the register returns it, then increments by 1.

func (*Register) SetValue

func (r *Register) SetValue(value int)

Sets the integer value of the register.

Jump to

Keyboard shortcuts

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