pdp11

package
v0.0.0-...-e9d1169 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMem  = fmt.Errorf("invalid memory access")
	ErrTrap = fmt.Errorf("trap")
	ErrInst = fmt.Errorf("invalid instruction")
	ErrBPT  = fmt.Errorf("bpt instruction")
	ErrIOT  = fmt.Errorf("iot instruction")
	ErrEMT  = fmt.Errorf("emt instruction")
	ErrFPT  = fmt.Errorf("floating point trap")
)

Functions

func Asm

func Asm(pc uint16, text string) (codes []uint16, err error)

Types

type ArrayMem

type ArrayMem [1 << 16]byte

An ArrayMem is a Memory implementation backed by a 64kB array. All addresses are valid.

func (*ArrayMem) ReadB

func (m *ArrayMem) ReadB(addr uint16) (uint8, error)

func (*ArrayMem) ReadW

func (m *ArrayMem) ReadW(addr uint16) (uint16, error)

func (*ArrayMem) WriteB

func (m *ArrayMem) WriteB(addr uint16, val uint8) error

func (*ArrayMem) WriteW

func (m *ArrayMem) WriteW(addr uint16, val uint16) error

type CPU

type CPU struct {
	R    [8]uint16  // registers
	PS   PS         // processor status word
	Inst uint16     // instruction being executed (actual instruction bits)
	Mem  Memory     // attached memory
	F    [6]float64 // floating-point registers
	FPS  FPS        // floating point status word
	FEC  uint8      // fp error code
	FEA  uint8      // fp exception address
}

A CPU represents a single PDP-11 CPU, connected to a memory.

func (*CPU) Disasm

func (cpu *CPU) Disasm(pc uint16) (asm string, next uint16, err error)

func (*CPU) ReadB

func (cpu *CPU) ReadB(addr uint16) (uint8, error)

ReadB reads and returns the byte at addr.

func (*CPU) ReadW

func (cpu *CPU) ReadW(addr uint16) (uint16, error)

ReadW reads and returns the word at addr.

func (*CPU) Step

func (cpu *CPU) Step(n int) (err error)

func (*CPU) WriteB

func (cpu *CPU) WriteB(addr uint16, val uint8) error

WriteB writes the byte val to addr.

func (*CPU) WriteW

func (cpu *CPU) WriteW(addr uint16, val uint16) error

WriteW writes the word val to addr.

type FPS

type FPS uint16

An FPS is the processor status word. Only the condition codes are used.

const (
	FC FPS = 1 << iota // C = 1 if result generated carry
	FV                 // V = 1 if result overflowed
	FZ                 // Z =1 if result was zero
	FN                 // N = 1 if result was negative

	FT   // truncate bit
	FL   // long-precision integer mode
	FD   // double-precision mode
	FIC  // floating interrupt on integer conversion error (TODO)
	FIV  // floating interrupt on overflow (TODO)
	FIU  // floating interrupt on underflow (TODO)
	FIUV // floating interrupt on undefined variable (TODO)

	FID // floating interrupt disable (TODO)
	FER // floating error condiiton present (TODO)
)

func (FPS) C

func (p FPS) C() uint16

C returns the carry bit as a uint16 that is 0 or 1.

func (FPS) N

func (p FPS) N() uint16

N returns the sign (negative) bit as a uint16 that is 0 or 1.

func (*FPS) SetC

func (p *FPS) SetC(b bool)

SetC sets the carry bit according to the boolean value.

func (*FPS) SetN

func (p *FPS) SetN(b bool)

SetN sets the sign (negative) bit according to the boolean value.

func (*FPS) SetV

func (p *FPS) SetV(b bool)

SetV sets the overflow bit according to the boolean value.

func (*FPS) SetZ

func (p *FPS) SetZ(b bool)

SetZ sets the zero bit according to the boolean value.

func (FPS) String

func (p FPS) String() string

func (FPS) V

func (p FPS) V() uint16

V returns the overflow bit as a uint16 that is 0 or 1.

func (FPS) Z

func (p FPS) Z() uint16

Z returns the zero bit as a uint16 that is 0 or 1.

type Memory

type Memory interface {
	ReadB(addr uint16) (uint8, error)
	ReadW(addr uint16) (uint16, error)
	WriteB(addr uint16, val uint8) error
	WriteW(addr uint16, val uint16) error
}

A Memory represents a PDP-11 memory.

type PS

type PS uint16

A PS is the processor status word. Only the condition codes are used.

const (
	PS_C PS = 1 << 0 // C = 1 if result generated carry
	PS_V PS = 1 << 1 // V = 1 if result overflowed
	PS_Z PS = 1 << 2 // Z =1 if result was zero
	PS_N PS = 1 << 3 // N = 1 if result was negative
)

func (PS) C

func (p PS) C() uint16

C returns the carry bit as a uint16 that is 0 or 1.

func (PS) N

func (p PS) N() uint16

N returns the sign (negative) bit as a uint16 that is 0 or 1.

func (*PS) SetC

func (p *PS) SetC(b bool)

SetC sets the carry bit according to the boolean value.

func (*PS) SetN

func (p *PS) SetN(b bool)

SetN sets the sign (negative) bit according to the boolean value.

func (*PS) SetV

func (p *PS) SetV(b bool)

SetV sets the overflow bit according to the boolean value.

func (*PS) SetZ

func (p *PS) SetZ(b bool)

SetZ sets the zero bit according to the boolean value.

func (PS) V

func (p PS) V() uint16

V returns the overflow bit as a uint16 that is 0 or 1.

func (PS) Z

func (p PS) Z() uint16

Z returns the zero bit as a uint16 that is 0 or 1.

type RegNum

type RegNum uint8

A RegNum is a register number (0..7).

const (
	PC RegNum = 7 // R7 is program counter
	SP RegNum = 6 // R6 is stack pointer
)

func (RegNum) String

func (r RegNum) String() string

String returns the register name for r: r0, r1, r2, r3, r4, r5, sp, or pc.

Jump to

Keyboard shortcuts

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