Altair 8800 Simulator with Z80 support
======================================

0. Revision History

- 25-Feb-2003, Peter Schorn (added support for real time simulation)
-  9-Oct-2002, Peter Schorn (added support for simulated hard disk)
- 28-Sep-2002, Peter Schorn (number of tracks per disk can be configured)
- 19-Sep-2002, Peter Schorn (added WARNROM feature)
- 31-Aug-2002, Peter Schorn (added extended ROM features suggested
                             by Scott LaBombard)
-  4-May-2002, Peter Schorn (added description of MP/M II sample software)
- 28-Apr-2002, Peter Schorn (added periodic timer interrupts and three
                             additional consoles)
- 15-Apr-2002, Peter Schorn (added memory breakpoint)
-  7-Apr-2002, Peter Schorn (added ROM / NOROM switch)
Original version of this document written by Charles E Owen


1. Background.

  The MITS (Micro Instrumentation and Telemetry Systems) Altair 8800 was
announced on the January 1975 cover of Popular Electronics, which boasted
you could buy and build this powerful computer kit for only $397. The kit
consisted at that time of only the parts to build a case, power supply,
card cage (18 slots), CPU card, and memory card with 256 *bytes* of memory.
Still, thousands were ordered within the first few months after the
announcement, starting the personal computer revolution as we know it
today.

  Many laugh at the small size of the that first kit, noting there were no
peripherals and the 256 byte memory size.  But the computer was an open
system, and by 1977 MITS and many other small startups had added many
expansion cards to make the Altair quite a respectable little computer. The
"Altair Bus" that made this possible was soon called the S-100 Bus, later
adopted as an industry standard, and eventually became the IEE-696 Bus.


2. Hardware

  We are simulating a fairly "loaded" Altair 8800 from about 1977, with the
following configuration:

  device    simulates
  name(s)

  CPU       Altair 8800 with Intel 8080 CPU board, 62KB
            of RAM, 2K of EPROM with start boot ROM.
  SIO       MITS 88-2SIO Dual Serial Interface Board. Port 1
            is assumed to be connected to a serial "glass
            TTY" that is your terminal running the Simulator.
  PTR       Paper Tape Reader attached to port 2 of the 2SIO board.
  PTP       Paper Tape Punch attached to port 2 of the
            2SIO board.  This also doubles as a printer port.
  DSK       MITS 88-DISK Floppy Disk controller with up
            to eight drives.


2.1 CPU

  We have 2 CPU options that were not present on the original machine but
are useful in the simulator.  We also allow you to select memory sizes, but
be aware that some sample software requires the full 64K (i.e. CP/M) and
the MITS Disk Basic and Altair DOS require about a minimum of 24K.

  SET CPU 8080  Simulates the 8080 CPU (normal)
  SET CPU Z80   Simulates the Z80 CPU. Note that some software (e.g. most
      original Altair software such as 4K Basic) requires an 8080 CPU and
      will not or not properly run on a Z80. This is mainly due to the use
      of the parity flag on the 8080 which has not always the same
      semantics on the Z80.

  SET CPU ITRAP  Causes the simulator to halt if an invalid opcode
      is detected (depending on the chosen CPU).
  SET CPU NOITRAP  Does not stop on an invalid Opcode.  This is
      how the real 8080 works.

  SET CPU 4K
  SET CPU 8K
  SET CPU 12K
  SET CPU 16K
    ...... (in 4K steps)
  SET CPU 64K  All these set various CPU memory configurations.

  SET CPU BANKED Enables the banked memory support. The simulated memory
      has eight banks with address range 0..'common' (see registers below)
      and a common area from 'common' to 0xfff which is common to all
      banks. The currently active bank is determined by register 'bank'
      (see below). You can only switch to banked memory if the memory
      is set to 64K. The banked memory is used by CP/M 3.

  SET CPU NONBANKED Disables banked memory support.

  SET CPU ROM Enables the ROM from address 'ROMLOW' to 'ROMHIGH'
      (see below under CPU Registers) and prevents write access
      to these locations. This is the default setting.

  SET CPU NOROM Disables the ROM.

  SET CPU ALTAIRROM Enables the slightly modified but downwards compatible
      Altair boot ROM at addresses 0FF00 to 0FFFF. This is the default.

  SET CPU NOALTAIRROM Disables standard Altair ROM behavior.

  SET CPU WARNROM Enables warning messages to be printed when the CPU
      attempts to write into ROM or into non-existing memory. Also prints
      a warning message if the CPU attempts to read from non-existing
      memory.

  SET CPU NOWARNROM Suppreses all warning message of "WARNROM". Note that
      some software tries on purpose to write to ROM in order to detect
      the available RAM.

  The BOOT EPROM card starts at address 0FF00 if it has been enabled by
'SET CPU ALTAIRROM'.  Jumping to this address will boot drive 0 of the
floppy controller (CPU must be set to ROM or equivalent code must be
present).  If no valid bootable software is present there the machine
crashes.  This is historically accurate behavior.

  The real 8080, on receiving a HLT (Halt) instruction, freezes the
processor and only an interrupt or CPU hardware reset will restore it.  The
simulator is alot nicer, it will halt but send you back to the simulator
command line.

CPU Registers include the following:

  Name  Size  Comment

  PC      16  The Program Counter
  AF      16  The accumulator and the flag register
              F = S Z - AC - P/V N C
                S    = Sign flag.
                Z    = Zero Flag.
                AC   = Auxillary Carry flag.
                P/V  = Parity flag on 8080
                       Parity / Overflow flag on Z80
                -    = not used (undefined)
                N    = Internal sign flag
                C    = Carry flag.
  BC      16  The BC register pair.
              Register B is the high 8 bits, C is the lower 8 bits
  DE      16  The DE register pair.
              Register D is the high 8 bits, E is the lower 8 bits.
  HL      16  The HL register pair.
              Register H is the high 8 bits, L is the lower 8 bits.
  AF1     16  The alternate AF register (on Z80 only)
  BC1     16  The alternate BC register (on Z80 only)
  DE1     16  The alternate DE register (on Z80 only)
  HL1     16  The alternate HL register (on Z80 only)
  IX      16  The IX index register     (on Z80 only)
  IY      16  The IY index register     (on Z80 only)
  IFF      8  Interrupt flag            (on Z80 only)
  INT      8  Interrupt register        (on Z80 only)

  SR      16  The front panel switches (use D SR 8 for 4k Basic).
  WRU      8  The interrupt character.  This starts as 5
              (ctrl-E) but some Altair software uses this
              keystroke so best to change this to something
              exotic such as 035 (which is Ctl-]).

  BANK     3  The currently active memory bank (if banked memory
              is activated - see memory options above)
  COMMON  16  The starting address of common memory. Originally set
              to 0xc000 (note this setting must agree with the
              value supplied to GENCPM for CP/M 3 system generation)
  ROMLOW  16  The starting address of the ROM. Default is 0FF00.
  ROMHIGH 16  The final address of the ROM. Default is 0FFFF.
  CLOCK   32  The clock speed of the simulated CPU in kHz or 0 to run
              at maximum speed. To set the clock speed for a typical
              4 MHz Z80 CPU, use D CLOCK 4000. The CP/M utility SPEED
              measures the clock speed of the simulated CPU.


2.2 The Serial I/O Card (2SIO)

  This simple programmed I/O device provides 2 serial ports to the outside
world, which could be hardware jumpered to support RS-232 plugs or a TTY
current loop interface.  The standard I/O addresses assigned by MITS was
10-11 (hex) for the first port, and 12-13 (hex) for the second. We follow
this standard in the Simulator.

  The simulator directs I/O to/from the first port to the screen. The
second port reads from an attachable "tape reader" file on input, and
writes to an attachable "punch file" on output.  These files are considered
a simple stream of 8-bit bytes.

  The SIO can be configured in SIMH with the following commands:

  SET SIO TTY      Bit 8 is set to zero on console output
  SET SIO ANSI     Bit 8 is not touched on console output

  SET SIO ALL      Console input support lower- and upper case
  SET SIO UPPER    Console input is transformed to upper case characters only
                   (This feature is useful for most Altair software)

  SET SIO BS       Map the delete character to backspace
  SET SIO DEL      Map the backspace character to delete

  SET SIO QUIET    Do not print warning messages
  SET SIO VERBOSE  Print warning messages (useful for debugging)
                   The register SIOWL determines how often the same warning
                   is displayed. The default is 3.

  You can also attach the SIO to a port:

  ATTACH SIO 23    Console IO goes via a Telnet connection on port 23
  DETACH SIO       Console IO goes via the regular SIMH console


2.3 The SIMH pseudo device

  The SIMH pseudo device facilitates the communication between the
simulated ALTAIR and the simulator environment. This device defines a
number of (most R/O) registers (see source code) which are primarily useful
for debugging purposes.

  The SIMH pseudo device can be configured with

  SET SIMH QUIET    Do not print warning messages
  SET SIMH VERBOSE  Print warning messages (useful for debugging)

  SET SIMH TIMERON  Start periodic timer interrupts
  SET SIMH TIMEROFF Stop the periodic timer interrupts

  The following variables determine the behavior of the timer:

  TIMD    This is the delay between consecutive interrupts in milliseconds.
          Use D TIMD 20 for a 50 Hz clock.
  TIMH    This is the address of the interrupt handler to call for a
          timer interrupt.


2.4 The 88-DISK controller.

  The MITS 88-DISK is a simple programmed I/O interface to the MITS 8-inch
floppy drive, which was basically a Pertec FD-400 with a power supply and
buffer board builtin.  The controller supports neither interrupts nor DMA,
so floppy access required the sustained attention of the CPU. The standard
I/O addresses were 8, 9, and 0A (hex), and we follow the standard.  Details
on controlling this hardware are in the altair_dsk.c source file.

  The only difference is that the simulated disks may be larger than the
original ones: The original disk had 77 tracks while the simulated disks
support up to 254 tracks (only relevant for CP/M). You can change the
number of tracks per disk by setting the appropriate value in TRACKS[..].
For example "D TRACKS[0] 77" sets the number of tracks for disk 0 to the
original number of 77. The command "D TRACKS[0-7] 77" changes the highest
track number for all disks to 77.

  For debugging purposes you can set the trace level of some disk I/O
functions. To do so the following bits in TRACE (a register of the disk)
have been defined with the following meaning:

  1 Trace all IN and OUT instructions on the disk ports 8 and 9
  2 Trace all read and writes to full sectors on the disk
  4 Print a message whenever an unnecessary step-in or step out of the
    disk head occurs (often an indication of an infinite loop)
  8 Print a message whenever the disk head appears to be waiting for a
    sector which does not show up (often an indication of an infinite
    loop)

For example the command "D TRACE 10" will trace options 2+8 from above.

  The DSK device can be configured with

  SET DSK<n> QUIET         Do not print warning messages for disk <n>
  SET DSK<n> VERBOSE       Print warning messages for disk <n>
                           (useful for debugging)
                           The register DSKWL determines how often the
                           same warning is displayed. The default is 3.

  SET DSK<n> WRITEENABLED  Allow write operations for disk <n>
  SET DSK<n> LOCKED        Disk <n> is locked, i.e. no write operations
                           will be allowed.


2.5 The simulated hard disk

  In order to increase the available storage capacity, the simulator
features 8 simulated hard disks with a capacity of 8MB (HDSK0 to HDSK7).
Currently only CP/M supports two hard disks as devices I: and J:.

  For debugging purposes one can set the trace flag by executing the
command "D HDTRACE 1". The default for "HDTRACE" is 0 (no trace).

  The HDSK device can be configured with

  SET HDSK<n> QUIET         Do not print warning messages for hard disk <n>
  SET HDSK<n> VERBOSE       Print warning messages for hard disk <n>
                            (useful for debugging)

  SET HDSK<n> WRITEENABLED  Allow write operations for hard disk <n>
  SET HDSK<n> LOCKED        Hard disk <n> is locked, i.e. no
                            write operations will be allowed.


3. Sample Software

  Running an Altair in 1977 you would be running either MITS Disk Extended
BASIC, or the brand new and sexy CP/M Operating System from Digital
Research.  Or possibly, you ordered Altair DOS back when it was promised in
1975, and are still waiting for it to be delivered in early 1977.

  We have samples of all three for you to check out.  We can't go into the
details of how they work, but we'll give you a few hints.


3.1 CP/M Version 2.2

  This version is my own port of the standard CP/M to the Altair. There
were some "official" versions but I don't have them.  None were endorsed or
sold by MITS to my knowledge, however.

  To boot CP/M:

  sim> attach dsk cpm2.dsk
  sim> boot dsk

  CP/M feels like DOS, sort of.  DIR will work.  I have included all the
standard CP/M utilities, plus a few common public-domain ones.  I also
include the sources to the customized BIOS and some other small programs.
TYPE will print an ASCII file.  DUMP will dump a binary one.  LS is a
better DIR than DIR.  ASM will assemble .ASM files to Hex, LOAD will "load"
them to binary format (.COM).  ED is a simple editor, #A command will bring
the source file to the buffer, T command will "type" lines, L will move
lines, E exits the editor.  20L20T will move down 20 lines, and type 20. 
Very DECish.  DDT is the debugger, DO is a batch-type command processor. A
sample batch file that will assemble and write out the bootable CP/M image
(on drive A) is "SYSCPM2.SUB".  To run it, type "DO SYSCPM2".

  In order to efficiently transfer files into the CP/M environment use the
included program R <filename.ext>. If you have a file named foo.ext in the
current directory (i.e. the directory where SIMH is), executing R FOO.EXT
under CP/M will transfer the file onto the CP/M disk. Transferring a file
from the CP/M environment to the SIMH environment is accomplished by
W <filename.ext> for text files or by W <filename.ext> B for binary files.
The simplest way for transferring multiple files is to create a ".SUB"
batch file which contains the necessary R resp. W commands.

  If you need more storage space you can use a simulated hard disk on
drives I: and J:. To use do "attach HDSK0 hdi.dsk" and issue the
"XFORMAT I:" resp.  "XFORMAT J:" command from CP/M do initialize the disk
to an empty state.

The disk "cpm2.dsk" contains the following files:
Name    Ext  Size   Comment
ASM     .COM   8K ; CP/M assembler
BDOS    .MAC  68K ; Basic Disk Operating System assembler source code
BOOT    .COM   1K ; transfer control to boot ROM
BOOT    .MAC   2K ; source for BOOT.COM
BOOTGEN .COM   2K ; put a program on the boot sectors
CBIOSX  .MAC  48K ; CP/M 2 BIOS source for Altair
CCP     .MAC  26K ; Console Command Processor assembler source code
COPY    .COM   2K ; copy disks
CPMBOOT .COM  12K ; CP/M operating system
CPU     .COM   2K ; get and set the CPU type (8080 or Z80)
CPU     .MAC   2K ; source for CPU.COM
CREF80  .COM   4K ; cross reference utility
DDT     .COM   6K ; 8080 debugger
DDTZ    .COM  10K ; Z80 debugger
DIF     .COM   4K ; determine differences between two files
DO      .COM   2K ; batch processing
DSKBOOT .MAC   8K ; source for boot ROM
DUMP    .COM   2K ; hex dump a file
ED      .COM   8K ; line editor
ELIZA   .BAS  10K ; Eliza game in Basic
EX8080  .COM  12K ; exercise 8080 instruction set
EXZ80N  .COM  12K ; exercise Z80 instruction set, No undefined status bits
EXZ80U  .COM  12K ; exercise Z80 instruction set, Undefined status bits
EXZ80   .MAC  54K ; source for EX8080.COM, EXZ80N.COM, EXZ80U.COM
EX      .SUB   2K ; benchmark execution of EX8080.COM, EXZ80N.COM, EXZ80U.COM
FORMAT  .COM   2K ; format disks
GO      .COM   0K ; start the currently loaded program at 100H
HDSKBOOT.MAC   6K ; boot code for hard disk
L80     .COM  12K ; Microsoft linker
LADDER  .COM  40K ; game
LADDER  .DAT   2K ; high score file for LADDER.COM
LIB80   .COM   6K ; library utility
LOAD    .COM   2K ; load hex files
LS      .COM   4K ; directory utility
LU      .COM  20K ; library utility
M80     .COM  20K ; Microsoft macro assembler
MBASIC  .COM  24K ; Microsoft Basic interpreter
MC      .SUB   2K ; assemble and link an assembler program
MCC     .SUB   2K ; read, assemble and link an assembler program
MCCL    .SUB   2K ; assemble, link and produce listing
MEMCFG  .LIB   2K ; defines the memory configuration
MOVER   .MAC   2K ; moves operating system in place
OTHELLO .COM  12K ; Othello (Reversi) game
PIP     .COM   8K ; Peripheral Interchange Program
PRELIM  .COM   2K ; preliminary CPU tests
PRELIM  .MAC   6K ; source code for PRELIM.COM
R       .COM   4K ; read files from SIMH environment
RSETSIMH.COM   2K ; reset SIMH interface
RSETSIMH.MAC   2K ; assembler source for RSETSIMH.COM
SHOWSEC .COM   3K ; show sectors on a disk
SID     .COM   8K ; debugger for 8080
SPEED   .COM   2K ; utility to measure the clock speed of the simulated CPU
STAT    .COM   6K ; provide information about currently logged disks
SURVEY  .COM   2K ; system survey
SURVEY  .MAC  16K ; assembler source for SURVEY.COM
SYSCOPY .COM   2K ; copy system tracks between disks
SYSCPM2 .SUB   2K ; create CP/M 2 on drive A:
TIMER   .COM   2K ; perform various timer operations
TIMER   .MAC   2K ; source code for TIMER.COM
UNCR    .COM   8K ; un-crunch utility
UNERA   .COM   2K ; un-erase a file
UNERA   .MAC  16K ; source for UNERA.COM
USQ     .COM   2K ; un-squeeze utility
W       .COM   4K ; write files to SIMH environment
WM      .COM  12K ; word master screen editor
WM      .HLP   3K ; help file for WM.COM
WORM    .COM   4K ; worm game for VT100 terminal
XFORMAT .COM   2K ; initialise a drive (floppy or hard disk)
XSUB    .COM   2K ; support for DO.COM
ZAP     .COM  10K ; SuperZap 5.2 disk editor configured for VT100
ZSID    .COM  10K ; debugger for Z80
ZTRAN4  .COM   4K ; translate 8080 mnemonics into Z80 equivalents


3.2 CP/M Version 3 with banked memory

  CP/M 3 is the successor to CP/M 2.2. A customised BIOS (BIOS3.MAC) is
included to facilitate modification if so desired. The defaults supplied in
GENCPM.DAT for system generation can be used. BOOTGEN.COM is used to place
the CP/M loader (LDR.COM) on the boot tracks of a disk.

  Running CP/M 3 with banked memory:
  sim> attach dsk cpm3.dsk
  sim> reset cpu
  sim> set cpu banked
  sim> set cpu itrap
  sim> boot dsk

  Executing "DO SYSCPM3" will re-generate the banked version of CP/M 3. You
can boot CP/M 3 with or without a Z80 CPU. The Z80 CPU is needed for both
sysgens due to the use of BOOTGEN.COM which requires it.

The disk "cpm3.dsk" contains the following files:
ASM     .COM   8K ; CP/M assembler
ASSIGN  .SYS   2K
BDOS3   .SPR  10K
BIOS3   .MAC  28K ; CP/M 3 BIOS source for Altair SIMH
BIOS3   .SPR   4K
BNKBDOS3.SPR  14K
BNKBIOS3.SPR   4K
BOOT    .COM   2K ; transfer control to boot ROM
BOOTGEN .COM   2K ; put a program on the boot sectors
CCP     .COM   4K
COPYSYS .COM   2K
CPM3    .SYS  18K
CPMLDR  .MAC  38K ; CP/M 3 loader assembler source
DATE    .COM   4K ; date utility
DDT     .COM   6K ; 8080 debugger
DDTZ    .COM  10K ; Z80 debugger
DEFS    .LIB   2K ; include file for BIOS3.MAC to create banked CP/M 3
DEVICE  .COM   8K
DIF     .COM   4K ; determine differences between two files
DIR     .COM  16K ; directory utility
DO      .COM   6K ; batch processing
DUMP    .COM   2K
ED      .COM  10K
ERASE   .COM   4K
GENCOM  .COM  16K
GENCPM  .COM  22K
GENCPM  .DAT   4K ; CP/M generation information for banked version
GENCPMNB.DAT   4K ; CP/M generation information for non-banked version
GET     .COM   8K
HELP    .COM   8K ; help utility
HELP    .HLP  62K ; help files
HEXCOM  .CPM   2K
HIST    .UTL   2K
INITDIR .COM  32K
L80     .COM  12K ; Microsoft linker
LDR     .COM   4K ; CP/M loader with optimised loader BIOS
LDRBIOS3.MAC  14K ; optimised (for space) loader BIOS
LIB     .COM   8K ; Digital Research librarian
LINK    .COM  16K ; Digital Research linker
LOAD    .COM   2K
M80     .COM  20K ; Microsoft macro assembler
MC      .SUB   2K ; assemble and link an assmbler program
MCC     .SUB   2K ; read, assemble and link an assembler program
PATCH   .COM   4K
PIP     .COM  10K ; Peripheral Interchange Program
PROFILE .SUB   2K ; commands to be executed at start up
PUT     .COM   8K
R       .COM   4K ; read files from SIMH environment
RENAME  .COM   4K
RESBDOS3.SPR   2K
RMAC    .COM  14K ; Digital Research macro assembler
RSETSIMH.COM   2K ; reset SIMH interface
SAVE    .COM   2K
SCB     .MAC   2K
SET     .COM  12K
SETDEF  .COM   6K
SHOW    .COM  10K
SHOWSEC .COM   4K ; show sectors on a disk
SID     .COM   8K ; 8080 debugger
SYSCOPY .COM   2K ; copy system tracks between disks
SYSCPM3 .SUB   2K ; create banked CP/M 3 system
TRACE   .UTL   2K
TSHOW   .COM   2K ; show split time
TSTART  .COM   2K ; create timer and start it
TSTOP   .COM   2K ; show final time and stop timer
TYPE    .COM   4K
UNERA   .COM   2K ; un-erase a file
W       .COM   4K ; write files to SIMH environment
XREF    .COM  16K ; cross reference utility
ZSID    .COM  10K ; Z80 debugger


3.3 MP/M II with banked memory

  MP/M II is an acronym for MultiProgramming Monitor Control Program for
Microprocessors. It is a multiuser operating system for an eight bit
microcomputer. MP/M II supports multiprogramming at each terminal. This
version supports four terminals available via Telnet. To boot:

  sim> attach dsk mpm.dsk
  sim> set cpu itrap
  sim> set cpu z80
  sim> set cpu rom
  sim> set cpu banked
  sim> attach sio 23
  sim> d common b000
  sim> boot dsk

  Now connect a Telnet session to the simulator and type "MPM" at the "A>"
prompt. Now you can connect up to three additional terminals via Telnet to
the Altair running MP/M II. To re-generate the system perform "DO SYSMPM"
in the CP/M environment (not possible under MP/M since XSUB is needed).

The disk "mpm.dsk" contains the following files:
Name    Ext  Size   Comment
ABORT   .PRL   2K ; abort a process
ABORT   .RSP   2K
ASM     .PRL  10K ; MP/M assembler
BNKBDOS .SPR  12K ; banked BDOS
BNKXDOS .SPR   2K ; banked XDOS
BNKXIOS .SPR   4K ; banked XIOS
BOOTGEN .COM   2K ; copy an executable to the boot section
CONSOLE .PRL   2K ; print console number
CPM     .COM   2K ; return to CP/M
CPM     .MAC   2K ; source for CPM.COM
DDT     .COM   6K ; MP/M DDT
DDT2    .COM   6K ; CP/M DDT
DDTZ    .COM  10K ; CP/M DDT with Z80 support
DIF     .COM   4K ; difference between two files
DIR     .PRL   2K ; directory command
DO      .COM   2K ; CP/M submit
DSKRESET.PRL   2K ; disk reset command
DUMP    .MAC   6K ; source for DUMP.PRL
DUMP    .PRL   2K ; dump command
ED      .PRL  10K ; MP/M line editor
ERA     .PRL   2K ; erase command
ERAQ    .PRL   4K ; erase comand (verbose)
GENHEX  .COM   2K
GENMOD  .COM   2K
GENSYS  .COM  10K
L80     .COM  12K ; Microsoft linker
LDRBIOS .MAC  14K ; loader BIOS
LIB     .COM   8K ; library utility
LINK    .COM  16K ; linker
LOAD    .COM   2K ; loader
M80     .COM  20K ; Microsoft macro assembler
MC      .SUB   2K ; assemble and link an assmbler program
MCC     .SUB   2K ; read, assemble and link an assembler program
MPM     .COM   8K ; start MP/M II
MPM     .SYS  26K ; MP/M system file
MPMD    .LIB   2K ; define a banked system
MPMLDR  .COM   6K ; MP/M loader without LDRBIOS
MPMSTAT .BRS   6K ; status of MP/M system
MPMSTAT .PRL   6K
MPMSTAT .RSP   2K
MPMXIOS .MAC  26K ; XIOS for MP/M
PIP     .PRL  10K ; MP/M peripheral interchange program
PIP2    .COM   8K ; CP/M peripheral interchange program
PRINTER .PRL   2K
PRLCOM  .PRL   4K
R       .COM   4K ; read a file from the SIMH environment
RDT     .PRL   8K ; debugger for page relocatable programs
REN     .PRL   4K ; rename a file
RESBDOS .SPR   4K ; non-banked BDOS
RMAC    .COM  14K ; Digital Research macro assembler
RSETSIMH.COM   2K ; reset SIMH interface
SCHED   .BRS   2K ; schedule a job
SCHED   .PRL   4K
SCHED   .RSP   2K
SDIR    .PRL  18K ; fancy directory command
SET     .PRL   8K ; set parameters
SHOW    .PRL   8K ; show status of disks
SPOOL   .BRS   4K ; spool utility
SPOOL   .PRL   4K
SPOOL   .RSP   2K
STAT    .COM   6K ; CP/M stat command
STAT    .PRL  10K ; MP/M stat command
STOPSPLR.PRL   2K ; stop spooler
SUBMIT  .PRL   6K ; MP/M submit
SYSCOPY .COM   2K ; copy system tracks
SYSMPM  .SUB   2K ; do a system generation
SYSTEM  .DAT   2K ; default values for system generation
TMP     .SPR   2K
TOD     .PRL   4K ; time of day
TSHOW   .COM   2K ; show split time
TSTART  .COM   2K ; create timer and start it
TSTOP   .COM   2K ; show final time and stop timer
TYPE    .PRL   2K ; type a file on the screen
USER    .PRL   2K ; set user area
W       .COM   4K ; write a file to SIMH environment
XDOS    .SPR  10K ; XDOS
XREF    .COM  16K ; cross reference utility
XSUB    .COM   2K ; for CP/M DO


3.4 CP/M application software

  There is also a small collection of sample application software
containing the following items:

- SPL:        a Small Programming Language with a suite of sample programs
- PROLOGZ:    a Prolog interpreter written in SPL with sources
- PASCFORM:   a Pascal pretty printer written in Pascal
- Pascal MT+: Pascal language system needed to compile PASCFORM

The sample software comes on "app.dsk" and to use it do

  sim> attach dsk1 app.dsk

before booting CP/M.

The disk "app.dsk" contains the following files:
Name    Ext  Size   Comment
BOOTGEN .COM   2K
BOOTGEN .SPL   6K ; SPL source for BOOTGEN.COM
C       .SUB   2K ; batch file for compiling an SPL source file
CALC    .PRO   4K ; Prolog demo program: Calculator
CC      .SUB   2K ; compile an SPL source which is on the underlying
                    file system
DECLARAT.     12K ; common include file, SPL source
DIF     .COM   4K
DIF     .SPL  10K ; SPL source for DIF.COM
EDIT    .SPL  10K ; screen editor for PROLOGZ, SPL source
FAMILY  .PRO   4K ; Prolog demo program: Family relations
INTEGER .PRO   2K ; Prolog demo program: Integer arithmetic
KNAKE   .PRO   2K ; Prolog demo program: Logic puzzle
LINKMT  .COM  12K ; Pascal MT+ 5.5 linker
MAIN    .SPL  14K ; main module for PROLOGZ, SPL source
MOVE    .MAC   4K ; helper functions for PROLOGZ in assembler
MTERRS  .TXT   6K ; Pascal MT+ error messages
MTPLUS  .000  14K ; Pascal MT+ 5.5 compiler file
MTPLUS  .001  12K ; Pascal MT+ 5.5 compiler file
MTPLUS  .002   8K ; Pascal MT+ 5.5 compiler file
MTPLUS  .003   8K ; Pascal MT+ 5.5 compiler file
MTPLUS  .004  18K ; Pascal MT+ 5.5 compiler file
MTPLUS  .005   8K ; Pascal MT+ 5.5 compiler file
MTPLUS  .006   6K ; Pascal MT+ 5.5 compiler file
MTPLUS  .COM  36K ; Pascal MT+ 5.5 compiler
PASCFORM.COM  36K ; Pascal formatter
PASCFORM.PAS  54K ; Pascal formatter source code
PASCFORM.SUB   2K ; create Pascal formatter
PASLIB  .ERL  24K ; Pascal MT+ 5.5 run time library
PINST   .COM   4K ; terminal installation program for PROLOGZ
PINST   .SPL  16K ; terminal installation program for PROLOGZ,
                    SPL source
PROLOGZ .COM  18K ; PROLOGZ interpreter and screen editor
PROLOGZ .SPL   2K ; PROLOGZ main program, SPL source
PROLOGZ .TXT  40K ; PROLOGZ documentation in German
PROVE   .SPL  16K ; backtrack theorem prover for PROLOGZ, SPL source
PZCLEAN .SUB   2K ; PROLOGZ: remove all created ".rel" and ".lst" files
PZLINK  .SUB   2K ; PROLOGZ: create PINST, PROLOGZ and personalise the
                    serial number
PZMAKE  .SUB   2K ; PROLOGZ: compiles the sources (you can ignore
                    any compiler errors)
QUEEN   .PRO   2K ; Prolog demo program: N-queens problem
READ    .COM   4K
READ    .SPL  10K ; SPL source for R.COM
SHOWSEC .COM   4K
SHOWSEC .SPL   6K ; SPL source for SHOWSEC.COM
SPEED   .COM   2K ; utility to measure the clock speed of the simulated CPU
SPEED   .SPL   2K ; SPL source for SPEED.COM, requires SWLIB.MAC
SPL     .COM  38K ; the SPL compiler itself
SPL     .TXT  56K ; SPL language and compiler documentation in German
SPLERROR.DAT  12K ; error messages of the compiler (in German)
SPLIB   .REL   6K ; SPL runtime library
STDIO   .      2K ; include file for SPL programs
SWLIB   .MAC   2K ; assembler utility routines needed by SPEED.SPL
SYSCOPY .COM   2K
SYSCOPY .SPL   6K ; SPL source for SYSCOPY.COM
TERMBDOS.SPL   2K ; terminal interface to CP/M for PROLOGZ, SPL source
UTIL    .SPL  18K ; utility functions for PROLOGZ, SPL source
WRITE   .COM   4K
WRITE   .SPL   8K ; SPL source for W.COM
XFORMAT .COM   2K
XFORMAT .SPL   6K ; SPL source for XFORMAT.COM


3.5 MITS Disk Extended BASIC Version 4.1

  This was the commonly used software for serious users of the Altair
computer.  It is a powerful (but slow) BASIC with some extended commands to
allow it to access and manage the disk.  There was no operating system it
ran under.  To boot:

  sim> set cpu 8080          ;Z80 will not work
  sim> attach dsk mbasic.dsk
  sim> set sio upper
  sim> go ff00

  MEMORY SIZE? [return]
  LINEPRINTER? [C return]
  HIGHEST DISK NUMBER? [0 return]  (0 here = 1 drive system)
  NUMBER OF FILES? [3 return]
  NUMBER OF RANDOM FILES? [2 return]

  44041 BYTES FREE
  ALTAIR BASIC REV. 4.1
  [DISK EXTENDED VERSION]
  COPYRIGHT 1977 BY MITS INC.
  OK
  [MOUNT 0]
  OK
  [FILES]


3.6 Altair DOS Version 1.0

  This was long promised but not delivered until it was almost irrelevant.
A short attempted tour will reveal it to be a dog, far inferior to CP/M. To
boot:

  sim> d tracks[0-7] 77   ;set to Altair settings
  sim> set cpu altairrom
  sim> attach dsk altdos.dsk
  sim> set sio upper
  sim> go ff00

  MEMORY SIZE? [return]
  INTERRUPTS? N [return]
  HIGHEST DISK NUMBER? [0 return]  (3 here = 4 drive system)
  HOW MANY DISK FILES? [3 return]
  HOW MANY RANDOM FILES? [2 return]

  056449 BYTES AVAILABLE
  DOS MONITOR VER 1.0
  COPYRIGHT 1977 BY MITS INC
  .[MNT 0]

  .[DIR 0]


3.7 Altair Basic 3.2 (4k)

  In order to run the famous 4k Basic, use the following commands (the
trick is to get the Switch Register right).

  sim> set cpu 8080     ;note 4k Basic will not run on a Z80 CPU
  sim> set sio upper    ;4k Basic does not like lower case letters as input
  sim> set sio ansi     ;4k Basic produces 8-bit output, strip to seven bits
  sim> d sr 8           ;good setting for the Switch Register
  sim> load 4kbas.bin 0 ;load it at 0
  sim> go 0             ;and start it
  MEMORY SIZE? [return]
  TERMINAL WIDTH? [return]
  WANT SIN? [Y]

  61911 BYTES FREE

  BASIC VERSION 3.2
  [4K VERSION]

  OK


3.8 Altair 8k Basic
  Running 8k Basic follows the procedure for 4k Basic.

  sim> set cpu 8080     ;note 8k Basic will not run on a Z80 CPU
  sim> set sio upper    ;8k Basic does not like lower case letters as input
  sim> set sio ansi     ;8k Basic produces 8-bit output, strip to seven bits
  sim> d sr 8           ;good setting for the Switch Register
  sim> load 8kbas.bin 0 ;load it at 0
  sim> go 0             ;and start it
  MEMORY SIZE? [A]

  WRITTEN FOR ROYALTIES BY MICRO-SOFT

  MEMORY SIZE? [return]
  TERMINAL WIDTH? [return]
  WANT SIN-COS-TAN-ATN?  [Y]

  58756 BYTES FREE
  ALTAIR BASIC REV. 4.0
  [EIGHT-K VERSION]
  COPYRIGHT 1976 BY MITS INC.
  OK


3.9 Altair Basic 4.0

  Execute the following commands to run Altair Extended Basic:

  sim> set sio upper      ;Extended Basic does not like lower case letters as input
  sim> set sio ansi       ;Extended Basic produces 8-bit output, strip to seven bits
  sim> d sr 8             ;good setting for the Switch Register
  sim> load exbas.bin 0   ;load it at 0
  sim> go 0               ;and start it
  16384 Bytes loaded at 0.

  MEMORY SIZE? [return]
  WANT SIN-COS-TAN-ATN? [Y]

  50606 BYTES FREE
  ALTAIR BASIC REV. 4.0
  [EXTENDED VERSION]
  COPYRIGHT 1977 BY MITS INC.
  OK


3.10 Altair Disk Extended Basic Version 300-5-C

  This version of Basic was provided by Scott LaBombard. To execute use the
following commands:

  sim> d tracks[0-7] 77   ;set to Altair settings
  sim> at dsk extbas5.dsk
  sim> g 0

  MEMORY SIZE? [return]
  LINEPRINTER? [C]
  HIGHEST DISK NUMBER? [0]
  HOW MANY FILES? [3]
  HOW MANY RANDOM FILES? [3]

  42082 BYTES FREE

  ALTAIR DISK EXTENDED BASIC
  VERSION 300-5-C [01NOV78]
  COPYRIGHT 1978 BY MITS INC.

  OK


4. Special simulator features

  In addition to the regular SIMH features such as PC queue, breakpoints
etc., this simulator supports memory access breakpoints. A memory access
breakpoint is triggered when a pre-defined memory location is accessed
(read, write or update). To set a memory location breakpoint enter

sim> break -m <location>

  Execution will stop whenever an operation accesses <location>. Note that
a memory access breakpoint is not triggered by fetching code from memory
(this is the job of regular breakpoints). This feature has been implemented
by using the typing facility of the SIMH breakpoints.


5. Brief summary of all major changes to the original Altair simulator
- Full support for Z80. CP/M software requiring a Z80 CPU now runs
  properly. DDTZ and PROLOGZ are included for demonstration purposes.
- Added banked memory support.
- PC queue implemented.
- Full assembler and dis-assembler support for Z80 and 8080 mnemonics.
  Depending on the current setting of the CPU, the appropriate mnemonics
  are used.
- The BOOT ROM was changed to fully load the software from disk. The
  original code basically loaded a copy of itself from the disk and
  executed it.
- ROM and memory size settings are now fully honored. This means that you
  cannot write into the ROM or outside the defined RAM (e.g. when the RAM size
  was truncated with the SET CPU commands). This feature allows programs which
  check for the size of available RAM to run properly (e.g. 4k Basic). In
  addition one can enable and disable the ROM which is useful in special cases
  (e.g. when testing a new version of the ROM).
- The console can also be used via Telnet. This is useful when a terminal is
  needed which supports cursor control such as a VT100. PROLOGZ for example
  has a built-in screen editor which works under Telnet.
- Simplified file exchange for CP/M. Using the READ program under CP/M one
  can easily import files into CP/M from the regular file system. Note that PIP
  does not work properly on non-text files on PTR.
- The WRITE program can be used to transfer files from the CP/M environment to
  the regular environment (binary or ASCII transfer).
- The last character read from PTR is always Control-Z (the EOF character for
  CP/M). This makes sure that PIP (Peripheral Interchange Program on CP/M) will
  terminate properly.
- Fixed a bug in the BIOS warm boot routine which caused CP/M to crash.
- Modified the BIOS for CP/M to support 8 disks.
- Added CP/M 3 banked version as sample software
- Changed from octal to hex
- Made the DSK and SIO device more robust (previously malicious code could
  crash the simulator)
- Added memory access break points
- Added periodic timer interrupts (useful for MP/M)
- Added additional consoles (useful for MP/M)
- Added MP/M II banked version as sample software
