cpu

package
v0.0.0-...-56e39c6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

The Censor 932 CPU package.

After the machine description at:

http://www.veteranklubbenalfa.se/veteran/13q1/130215.pdf

The cpu package includes instructions, instruction decoding, memory interfaces, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AD type3

AD

func (AD) Execute

func (i AD) Execute(c *CPU) uint32

type ADW

type ADW type1

ADW

func (ADW) Execute

func (i ADW) Execute(c *CPU) uint32

type AH

type AH type1

AH

func (AH) Execute

func (i AH) Execute(c *CPU) uint32

type AS

type AS type2

AS

func (AS) Execute

func (i AS) Execute(c *CPU) uint32

type ATS

type ATS type1

ATS

func (ATS) Execute

func (i ATS) Execute(c *CPU) uint32

type AW

type AW type1

AW

func (AW) Execute

func (i AW) Execute(c *CPU) uint32

type CD

type CD type3

CD

func (CD) Execute

func (i CD) Execute(c *CPU) uint32

type CH

type CH type1

CH

func (CH) Execute

func (i CH) Execute(c *CPU) uint32

type CLD

type CLD type3

CLD

func (CLD) Execute

func (i CLD) Execute(c *CPU) uint32

type CLH

type CLH type1

CLH

func (CLH) Execute

func (i CLH) Execute(c *CPU) uint32

type CLW

type CLW type1

CLW

func (CLW) Execute

func (i CLW) Execute(c *CPU) uint32

type CP

type CP type1

CP

type CPU

type CPU struct {
	G      [16]uint32
	IC     uint32 // This is technically an 18-bit entity
	PS     uint64
	MIR    uint32 // Actually a 24-bit entity
	Memory []MemoryPlugin
	CC     uint8
}

Basic CPU data structure

func NewCPU

func NewCPU() *CPU

func (*CPU) FetchHalfWord

func (c *CPU) FetchHalfWord(address uint32) uint16

Fetch a 16-bit word from a specific address

func (*CPU) FetchWord

func (c *CPU) FetchWord(address uint32) uint32

Fetch a 32-bit word from a specific address

func (*CPU) RegisterMemory

func (c *CPU) RegisterMemory(r MemoryRange, m MemoryBackend) error

Register a memory backend with a specific memory range. Return an error if the memory plugin is colliding with an alread-registered plugin.

func (*CPU) Step

func (c *CPU) Step()

Make the CPU take another "step" (this is a fetch, execute, optionally stop)

func (*CPU) StoreHalfWord

func (c *CPU) StoreHalfWord(address uint32, word uint16) uint16

func (*CPU) StoreWord

func (c *CPU) StoreWord(address, word uint32) uint32

type CW

type CW type1

CW

func (CW) Execute

func (i CW) Execute(c *CPU) uint32

type DD

type DD type3

DD

func (DD) Execute

func (i DD) Execute(c *CPU) uint32

type DH

type DH type1

DH

func (DH) Execute

func (i DH) Execute(c *CPU) uint32

type DS

type DS type2

DS

func (DS) Execute

func (i DS) Execute(c *CPU) uint32

type DW

type DW type1

DW

func (DW) Execute

func (i DW) Execute(c *CPU) uint32

type DirectMemory

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

Various stuff for implementing "local" memory

func NewDirectMemory

func NewDirectMemory(size uint32) *DirectMemory

func (*DirectMemory) FetchHalfWord

func (m *DirectMemory) FetchHalfWord(address uint32) uint16

func (*DirectMemory) FetchWord

func (m *DirectMemory) FetchWord(address uint32) uint32

func (*DirectMemory) WriteHalfWord

func (m *DirectMemory) WriteHalfWord(address uint32, data uint16) uint16

func (*DirectMemory) WriteWord

func (m *DirectMemory) WriteWord(address, data uint32) uint32

type EX

type EX type1

EX

func (EX) Execute

func (i EX) Execute(c *CPU) uint32

type IH

type IH type1

Interchange half word

func (IH) Execute

func (i IH) Execute(c *CPU) uint32

type IW

type IW type1

Interchange full word

func (IW) Execute

func (i IW) Execute(c *CPU) uint32

type Instruction

type Instruction interface {
	Execute(*CPU) uint32 // Return the next IC
}

General Instruction abstraction

func BuildADFunc

func BuildADFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildADWFunc

func BuildADWFunc(op, r, ix uint8, as uint16) Instruction

func BuildAHFunc

func BuildAHFunc(op, r, ix uint8, as uint16) Instruction

func BuildASFunc

func BuildASFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildATSFunc

func BuildATSFunc(op, r, ix uint8, as uint16) Instruction

func BuildAWFunc

func BuildAWFunc(op, r, ix uint8, as uint16) Instruction

func BuildCDFunc

func BuildCDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildCHFunc

func BuildCHFunc(op, r, ix uint8, as uint16) Instruction

func BuildCLDFunc

func BuildCLDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildCLHFunc

func BuildCLHFunc(op, r, ix uint8, as uint16) Instruction

func BuildCLWFunc

func BuildCLWFunc(op, r, ix uint8, as uint16) Instruction

func BuildCWFunc

func BuildCWFunc(op, r, ix uint8, as uint16) Instruction

func BuildDDFunc

func BuildDDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildDHFunc

func BuildDHFunc(op, r, ix uint8, as uint16) Instruction

func BuildDSFunc

func BuildDSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildDWFunc

func BuildDWFunc(op, r, ix uint8, as uint16) Instruction

func BuildEXFunc

func BuildEXFunc(op, r, ix uint8, as uint16) Instruction

func BuildIHFunc

func BuildIHFunc(op uint8, r1, r2 uint8, rest uint16) Instruction

func BuildIWFunc

func BuildIWFunc(op uint8, r1, r2 uint8, rest uint16) Instruction

func BuildJCFunc

func BuildJCFunc(op, r, ix uint8, as uint16) Instruction

func BuildJOAFunc

func BuildJOAFunc(op, r, ix uint8, as uint16) Instruction

func BuildJOSFunc

func BuildJOSFunc(op, r, ix uint8, as uint16) Instruction

func BuildJSFunc

func BuildJSFunc(op, r, ix uint8, as uint16) Instruction

func BuildJTSFunc

func BuildJTSFunc(op, r, ix uint8, as uint16) Instruction

func BuildLCFunc

func BuildLCFunc(op uint8, r1, r2 uint8, rest uint16) Instruction

func BuildLDFunc

func BuildLDFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildLDWFunc

func BuildLDWFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildLHFunc

func BuildLHFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildLNFunc

func BuildLNFunc(op uint8, r1, r2 uint8, rest uint16) Instruction

func BuildLPFunc

func BuildLPFunc(op uint8, r1, r2 uint8, rest uint16) Instruction

func BuildLRSFunc

func BuildLRSFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildLTFunc

func BuildLTFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildLWFunc

func BuildLWFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildMDFunc

func BuildMDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildMHFunc

func BuildMHFunc(op, r, ix uint8, as uint16) Instruction

func BuildMSFunc

func BuildMSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildMWFunc

func BuildMWFunc(op, r, ix uint8, as uint16) Instruction

func BuildNDFunc

func BuildNDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildNHFunc

func BuildNHFunc(op, r, ix uint8, as uint16) Instruction

func BuildNOPFunc

func BuildNOPFunc(op, r, ix uint8, as uint16) Instruction

func BuildNSFunc

func BuildNSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildNTSFunc

func BuildNTSFunc(op, r, ix uint8, as uint16) Instruction

func BuildNWFunc

func BuildNWFunc(op, r, ix uint8, as uint16) Instruction

func BuildODFunc

func BuildODFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildOHFunc

func BuildOHFunc(op, r, ix uint8, as uint16) Instruction

func BuildOSFunc

func BuildOSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildOTSFunc

func BuildOTSFunc(op, r, ix uint8, as uint16) Instruction

func BuildOWFunc

func BuildOWFunc(op, r, ix uint8, as uint16) Instruction

func BuildRLDFunc

func BuildRLDFunc(op, r, ix uint8, as uint16) Instruction

func BuildRLSFunc

func BuildRLSFunc(op, r, ix uint8, as uint16) Instruction

func BuildRRDFunc

func BuildRRDFunc(op, r, ix uint8, as uint16) Instruction

func BuildRRSFunc

func BuildRRSFunc(op, r, ix uint8, as uint16) Instruction

func BuildRZHFunc

func BuildRZHFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildRZWFunc

func BuildRZWFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildSDFunc

func BuildSDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildSDWFunc

func BuildSDWFunc(op, r, ix uint8, as uint16) Instruction

func BuildSFSFunc

func BuildSFSFunc(op, r, ix uint8, as uint16) Instruction

func BuildSHFunc

func BuildSHFunc(op, r, ix uint8, as uint16) Instruction

func BuildSLAFunc

func BuildSLAFunc(op, r, ix uint8, as uint16) Instruction

func BuildSLDAFunc

func BuildSLDAFunc(op, r, ix uint8, as uint16) Instruction

func BuildSLDLFunc

func BuildSLDLFunc(op, r, ix uint8, as uint16) Instruction

func BuildSLLFunc

func BuildSLLFunc(op, r, ix uint8, as uint16) Instruction

func BuildSRAFunc

func BuildSRAFunc(op, r, ix uint8, as uint16) Instruction

func BuildSRDAFunc

func BuildSRDAFunc(op, r, ix uint8, as uint16) Instruction

func BuildSRDLFunc

func BuildSRDLFunc(op, r, ix uint8, as uint16) Instruction

func BuildSRLFunc

func BuildSRLFunc(op, r, ix uint8, as uint16) Instruction

func BuildSRSFunc

func BuildSRSFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildSSFunc

func BuildSSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildSTDWFunc

func BuildSTDWFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildSTHFunc

func BuildSTHFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildSTWFunc

func BuildSTWFunc(op, r1, r2 uint8, rest uint16) Instruction

func BuildSWFunc

func BuildSWFunc(op, r, ix uint8, as uint16) Instruction

func BuildXDFunc

func BuildXDFunc(op, r1, r2 uint8, d uint16) Instruction

func BuildXHFunc

func BuildXHFunc(op, r, ix uint8, as uint16) Instruction

func BuildXSFunc

func BuildXSFunc(op, r1, r2 uint8, as uint16) Instruction

func BuildXTSFunc

func BuildXTSFunc(op, r, ix uint8, as uint16) Instruction

func BuildXWFunc

func BuildXWFunc(op, r, ix uint8, as uint16) Instruction

type InstructionBuilder

type InstructionBuilder func(op uint8, r1, r2 uint8, rest uint16) Instruction

type JC

type JC type1

JC

func (JC) Execute

func (i JC) Execute(c *CPU) uint32

type JOA

type JOA type1

JOA

func (JOA) Execute

func (i JOA) Execute(c *CPU) uint32

type JOS

type JOS type1

JOS

func (JOS) Execute

func (i JOS) Execute(c *CPU) uint32

type JS

type JS type1

JS

func (JS) Execute

func (i JS) Execute(c *CPU) uint32

type JTS

type JTS type1

JTS

func (JTS) Execute

func (i JTS) Execute(c *CPU) uint32

type LC

type LC type1

Load Complement

func (LC) Execute

func (i LC) Execute(c *CPU) uint32

type LD

type LD type3

Load Direct

func (LD) Execute

func (i LD) Execute(c *CPU) uint32

type LDW

type LDW type1

Load Double Word

func (LDW) Execute

func (i LDW) Execute(c *CPU) uint32

type LH

type LH type1

Load Half Word

func (LH) Execute

func (i LH) Execute(c *CPU) uint32

type LN

type LN type1

Load Negative

func (LN) Execute

func (i LN) Execute(c *CPU) uint32

type LP

type LP type1

LOC LOU LP

func (LP) Execute

func (i LP) Execute(c *CPU) uint32

type LRS

type LRS type2

LRS

func (LRS) Execute

func (i LRS) Execute(c *CPU) uint32

type LT

type LT type1

LT

func (LT) Execute

func (i LT) Execute(c *CPU) uint32

type LW

type LW type1

LW

func (LW) Execute

func (i LW) Execute(c *CPU) uint32

type MD

type MD type3

MD

func (MD) Execute

func (i MD) Execute(c *CPU) uint32

type MH

type MH type1

MH

func (MH) Execute

func (i MH) Execute(c *CPU) uint32

type MS

type MS type2

MS

func (MS) Execute

func (i MS) Execute(c *CPU) uint32

type MW

type MW type1

MW

func (MW) Execute

func (i MW) Execute(c *CPU) uint32

type MemoryBackend

type MemoryBackend interface {
	// Retrieve a HalfWord from the specified memory address
	FetchHalfWord(uint32) uint16
	// Store a HalfWord to a specific memory address, return the
	// previous value stored there.
	WriteHalfWord(uint32, uint16) uint16
	// Retrieve a Word from the specified address and adress + 1
	FetchWord(uint32) uint32
	// Store a Word to the specified address (and address + 1),
	// return the Word that was previously stored there.
	WriteWord(uint32, uint32) uint32
}

The general interface for MemoryBackend storage.

type MemoryPlugin

type MemoryPlugin struct {
	Range   MemoryRange
	Backend MemoryBackend
}

Rgeister a given MemoryBackend as the storage backend starting at Range.Low, ending at Range.High.

type MemoryRange

type MemoryRange struct {
	Low, High uint32
}

A struct providing upper and lower bounds for a MemoryBackend

type ND

type ND type3

ND

func (ND) Execute

func (i ND) Execute(c *CPU) uint32

type NH

type NH type1

NH

func (NH) Execute

func (i NH) Execute(c *CPU) uint32

type NOP

type NOP type1

NOP

func (NOP) Execute

func (i NOP) Execute(c *CPU) uint32

type NS

type NS type2

NS

func (NS) Execute

func (i NS) Execute(c *CPU) uint32

type NTS

type NTS type1

NTS

func (NTS) Execute

func (i NTS) Execute(c *CPU) uint32

type NW

type NW type1

NW

func (NW) Execute

func (i NW) Execute(c *CPU) uint32

type OD

type OD type3

OD

func (OD) Execute

func (i OD) Execute(c *CPU) uint32

type OH

type OH type1

OH

func (OH) Execute

func (i OH) Execute(c *CPU) uint32

type OS

type OS type2

OS

func (OS) Execute

func (i OS) Execute(c *CPU) uint32

type OTS

type OTS type1

OTS

func (OTS) Execute

func (i OTS) Execute(c *CPU) uint32

type OW

type OW type1

OW

func (OW) Execute

func (i OW) Execute(c *CPU) uint32

type RLD

type RLD type1

RLD

func (RLD) Execute

func (i RLD) Execute(c *CPU) uint32

type RLS

type RLS type1

RLS

func (RLS) Execute

func (i RLS) Execute(c *CPU) uint32

type RRD

type RRD type1

RRD

func (RRD) Execute

func (i RRD) Execute(c *CPU) uint32

type RRS

type RRS type1

RRS

func (RRS) Execute

func (i RRS) Execute(c *CPU) uint32

type RZH

type RZH type1

RZH

func (RZH) Execute

func (i RZH) Execute(c *CPU) uint32

type RZW

type RZW type1

RZW

func (RZW) Execute

func (i RZW) Execute(c *CPU) uint32

type SD

type SD type3

SD

func (SD) Execute

func (i SD) Execute(c *CPU) uint32

type SDW

type SDW type1

SDW

func (SDW) Execute

func (i SDW) Execute(c *CPU) uint32

type SFS

type SFS type1

SFS

func (SFS) Execute

func (i SFS) Execute(c *CPU) uint32

type SH

type SH type1

SH

func (SH) Execute

func (i SH) Execute(c *CPU) uint32

type SLA

type SLA type1

SLA

func (SLA) Execute

func (i SLA) Execute(c *CPU) uint32

type SLDA

type SLDA type1

SLDA

func (SLDA) Execute

func (i SLDA) Execute(c *CPU) uint32

type SLDL

type SLDL type1

SLDL

func (SLDL) Execute

func (i SLDL) Execute(c *CPU) uint32

type SLL

type SLL type1

SLL

func (SLL) Execute

func (i SLL) Execute(c *CPU) uint32

type SRA

type SRA type1

SRA

func (SRA) Execute

func (i SRA) Execute(c *CPU) uint32

type SRDA

type SRDA type1

SRDA

func (SRDA) Execute

func (i SRDA) Execute(c *CPU) uint32

type SRDL

type SRDL type1

SRDL

func (SRDL) Execute

func (i SRDL) Execute(c *CPU) uint32

type SRL

type SRL type1

SRL

func (SRL) Execute

func (i SRL) Execute(c *CPU) uint32

type SRS

type SRS type2

SIC SIU SRS

func (SRS) Execute

func (i SRS) Execute(c *CPU) uint32

type SS

type SS type2

SS

func (SS) Execute

func (i SS) Execute(c *CPU) uint32

type STDW

type STDW type1

STDW

func (STDW) Execute

func (i STDW) Execute(c *CPU) uint32

type STH

type STH type1

STH

func (STH) Execute

func (i STH) Execute(c *CPU) uint32

type STW

type STW type1

STW

func (STW) Execute

func (i STW) Execute(c *CPU) uint32

type SW

type SW type1

SW

func (SW) Execute

func (i SW) Execute(c *CPU) uint32

type XD

type XD type3

XD

func (XD) Execute

func (i XD) Execute(c *CPU) uint32

type XH

type XH type1

XH

func (XH) Execute

func (i XH) Execute(c *CPU) uint32

type XS

type XS type2

XS

func (XS) Execute

func (i XS) Execute(c *CPU) uint32

type XTS

type XTS type1

XTS

func (XTS) Execute

func (i XTS) Execute(c *CPU) uint32

type XW

type XW type1

XW

func (XW) Execute

func (i XW) Execute(c *CPU) uint32

Jump to

Keyboard shortcuts

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