Go Home Page
The Go Programming Language

Package pdp1

import "exp/spacewar"

This package and spacewar.go implement a simple PDP-1 emulator complete enough to run the original PDP-1 video game Spacewar! See ../../nacl/README for details on running them.

They are a translation of the Java emulator pdp1.java in http://spacewar.oversigma.com/sources/sources.zip.

See also the PDP-1 handbook at http://www.dbit.com/~greeng3/pdp1/pdp1.html

http://spacewar.oversigma.com/readme.html reads:

Spacewar! was conceived in 1961 by Martin Graetz, Stephen Russell,
and Wayne Wiitanen. It was first realized on the PDP-1 in 1962 by
Stephen Russell, Peter Samson, Dan Edwards, and Martin Graetz,
together with Alan Kotok, Steve Piner, and Robert A Saunders.
Spacewar! is in the public domain, but this credit paragraph must
accompany all distributed versions of the program.

This is the original version! Martin Graetz provided us with a
printed version of the source. We typed in in again - it was about
40 pages long - and re-assembled it with a PDP-1 assembler written
in PERL. The resulting binary runs on a PDP-1 emulator written as
a Java applet. The code is extremely faithful to the original. There
are only two changes. 1)The spaceships have been made bigger and
2) The overall timing has been special cased to deal with varying
machine speeds.

The "a", "s", "d", "f" keys control one of the spaceships. The "k",
"l", ";", "'" keys control the other. The controls are spin one
way, spin the other, thrust, and fire.

Barry Silverman
Brian Silverman
Vadim Gerasimov

Package files

pdp1.go

type HaltError

type HaltError Word

func (HaltError) String

func (e HaltError) String() string

type LoopError

type LoopError Word

func (LoopError) String

func (e LoopError) String() string

type M

An M represents the machine state of a PDP-1. Clients can set Display to install an output device.

type M struct {
    AC, IO, PC, OV Word
    Mem            [010000]Word
    Flag           [7]bool
    Sense          [7]bool
    Halt           bool
}

func (*M) Load

func (m *M) Load(r io.Reader) os.Error

Load loads the machine's memory from a text input file listing octal address-value pairs, one per line, matching the regular expression ^[ +]([0-7]+)\t([0-7]+).

func (*M) Step

func (m *M) Step(t Trapper) os.Error

Step runs a single machine instruction.

type Trapper

A Trapper represents an object with a Trap method. The machine calls the Trap method to implement the PDP-1 IOT instruction.

type Trapper interface {
    Trap(y Word)
}

type UnknownInstrError

type UnknownInstrError struct {
    Inst Word
    PC   Word
}

func (UnknownInstrError) String

func (e UnknownInstrError) String() string

type Word

type Word uint32

Other packages

main