The MOD8 MONITOR-8 program is an amazing bit of software for it's time (mid
70s). In only 1790 bytes of program code, and on a fairly limited processor,
it implements Octal load/dump, BNPF load/dump, a memory editor, block copy,
an EPROM programmer, breakpoints, code relocation, and an 8008 assembler and
disassembler.

The command interface is however fairly clunky, and it's easy to come to the
conclusion that it's not working, when in fact, you are just not giving it the
input it needs. This document contains information to get started with the
monitor. For complete details on the MONITOR-8 program, please refer to the
oritinal MOD8 documentation scans which are posted at my web site.

When you start the MONITOR-8, the first thing you will see is the '--------'
prompt, which tells you the monitor is ready to receive a command.

Commands are three letter names, some of which take numeric operands. Please
note the following rules:

- Due to the way the bit-bash uart works, characters you type will always
  be echoed - so don't take the echoing of characters typed as an indication
  the the monitor is working, or accepting data.

- Do not type SPACE characters into most commands. The monitor automatically
  provides needed spaces, and extra typed spaces will confuse it.

- Do not type the ENTER key. The monitor "knows" when commands are finished,
  and extra typed ENTER keys will confuse it.

- All numeric data is entered as OCTAL values. Byte values are always entered
  as three digits - word values are entered as six digits. Word values are
  split-octal - two groups of three digits representing 8 bits each (NOT a
  single group of six digits representing 16-bits).
  IE: The octal equivalent of an all-1's 16-bit word is: 377377

- When waiting for numeric data, the monitor will ignore any non-numeric
  data entered, and continue waiting for the numeric digits. This can be
  quite confusing as you type new commands and nothing happens.

- Some commands move to a new line and prompt with '*' when they are
  waiting for extra address values.

Often the monitor will NOT provide an error indication if the above rules
are not followed, however the action performed will not be correct.

Here are the monitor commands, enter them exactly as shown without SPACEs
or ENTER. Byte values shown as 'bbb' are three octal digits, word values
shown as 'wwwwww' are six octal digits in split-octal format.

LOC wwwwww                 - set current LOCation pointer (CLP)

DLP                        - Display cLP

DPS                        - DumP Symbolic (disassemble)
*wwwwww wwwwww               = Starting and ending address

LDO                        - LoaD Octal
*wwwwww wwwwww               = Starting and ending address
/ bbb bbb bbb ...            = Data bytes, '/' and SPACEs are required here
 ... More lines as needed ...

DPO                         - DumP Octal
*wwwwww wwwwww                = Starting and ending address
                              = Press any key after address to start dump

LBF                         - Load BnpF data
*wwwwww wwwwww                = Starting and ending address
BxxxxxxxxF ...                = BNPF data,  x: N=0, P=1

DBF                         - Dump BnpF data
*wwwwww wwwwww                = Starting and ending address
                              = Press any key after address to start dump

EDT                         - EDiT memory (at CLP)
 Sub-commands:                = Prompts with wwwwww/ (address)
   bbb                          = Enter byte value
   (space)                      = Display current value and advance
   ^                            = Backup to previous location
   R                            = Return to monitor prompt
   @ wwwwww                     = Execute at wwwwww

XQT wwwwww                  - eXeQuTe at address

CPY                         - CoPY block of memory
*wwwwww wwwwww                = Source starting and ending address
*wwwwww                       = Destination address

TRN                         - TRaNslate code (relocate)
*wwwwww wwwwww                = Starting and ending address
bbb bbb                       = Original and new bank (256 byte page)

SBP                         - Set BreakPoint
*wwwwww                       = Breakpoint address

CBP                         - Clear BreakPoint

PRG                         - PRoGram eprom
*wwwwww wwwwww                = Starting and ending address
%A or N                       = Select 1702A or 1702(N)

You may also enter any of the following 8008 instructions at the monitor
prompt, and it will be assembled and placed in memory at the CLP :
  r = Register: A, B, C, D, E, H, L, M
  f = Flag bit: C=Carry, Z=Zero, S=Sign, P=Parity
Lrr            - Load register from register (LMM invalid)
LrI bbb        - Load register with immediate value
INr            - Increment register (INA, INM invalid)
DCr            - Decrement register (DCA, DCM invalid)
ADr            - Add register to A
ACr            - Add register with carry to A
SUr            - Subtract register from A
SBr            - Subtract register with borrow from A
NDr            - AND register with A
ORr            - OR register with A
XRr            - Exclusive OR register with A
CPr            - Compare register with A
ADI bbb        - Add immediate to A
ACI bbb        - Add immediate with carry to A
SUI bbb        - Subtract immediate from A
SBI bbb        - Subtract immediate with borrow from A
NDI bbb        - And immediate with A
ORI bbb        - Or immediate with A
XRI bbb        - Exclusive OR immediate with A
CPI bbb        - Compare immediate with A
RLC            - Rotate A left
RRC            - Rotate A right
RAL            - Rotate A left (through carry)
RAR            - Rotate A right (through carry)
JMP wwwwww     - Unconditional jump
JFf wwwwww     - Jump if False flag
JTf wwwwww     - Jump if True flag
CAL wwwwww     - Unconditional Call
CFf wwwwww     - Call if False flag
CTf wwwwww     - Call if True flag
RET            - Return from subroutine
RFf            - Return if False flag
RTf            - Return if True flag
RST bbb        - Restart
INP bbb        - Input from port
OUT bbb        - Output to port
HLT            - Halt CPU

Excercises:

Start the MOD8 simulator and hit 'G' to begin executing MONITOR-8. You
should see the '--------' prompt on the screen.

-- Displaying memory:

Try dumping the first few locations of the monitor in octal with:

DPO
*000000 000177
(press any key)

You should see the first 128 bytes of memory dumped out in octal
format.

Try dumping the first few instructions of the monitor code with:

DPS
*000000 000037

Try dumping the data in BNPF format:

DBF
*000000 000077
(press any key)


-- Editing memory:

LOC 007000
EDT
007000/111
007001/222
007002/333
007003/444
007004/R

DPO
*007000 007003
(press any key)

You should see the data you entered.

-- Executing a program

In the early days of microcomputers, you had to "hand assemble" your program
code - you would decide what you wanted to do, then lookup the instructions
in the processor manual, and work out the values to place in memory for those
instructions. You would also note the number of bytes used by each instruction
so that you could keep track of the memory address of each instruction. This
is needed when coding jumps and calls to target the right destination address.

The following is an example of a "coding chart" which might have been used
for a little program that outputs a number counting down from 10 to the
MOD8 024 output port, with a software timing loop between each write.

Address:     The memory address where each instruction is located
Instruction: The instruction that you want to code at each address
#:           The number of bytes used by each instruction
Code:        The code values representing instruction (to be placed in memory)
Comment:     A description of what the instruction is doing


Address Instruction   #  Code         Comment
-------------------------------------------------------------------------
007000  LAI   012     2  006 012      Start count at 10 (decimal)
007002  OUT   024     1  151          Write to output port
007003  LDI   000     2  036 000      Start delay(low) at 0
007005  LCI   000     2  026 000      Start delay(high) at 0
007007  DCB           1  011          Reduce delay low (wraps)
007010  JFZ   007007  3  110 007 007  Loop until delay-low back to 0
007013  DCC           1  021          Reduce delay high (wraps)
007014  JFZ   007007  3  110 007 007  Loop until delay-high back 0 (again)
007017  SBI   001     2  034 001      Subtract 1 from main count
007021  JFZ   007002  3  110 002 007  And repeat util it hits 0
007024  RST   000     2  005          Go back to MONITOR 8


After filling out this chart, you could then enter the code values into
memory using the EDT command:

LOC 007000
EDT
007000/006
007001/012
007002/151
 ... enter all data from chart ...
007021/110
007022/002
007023/007
007024/005
007025/R

If you did it right, your code should be in memory, and

DPS
*007000 007024

should show you the same instructions that are listed in the chart.

You can execute this program with:

XQT 007000

You should see the count down occuring in the simulator output register
at the lower right-hand corner of the screen, then the monitor will
restart.

This method of hand-assembling instructions was the ONLY method for many
early systems, however MONITOR-8 actually has the ability to assemble the
code for you - this saves the step of looking up the code values in the
processor manual.

LOC 007000
LAI 012
OUT 024
LDI 000
LCI 000
DCB
JFZ 007007
DCC
JFZ 007007
SBI 001
JFZ 007002
RST 000

XQT 007000

The code should run, same as before.

Try replacing the first instruction with LAI 377 (255 decimal)

LOC 007000
LAI 377
XQT 007000

Now you will see it count all the way down from 11111111 (binary).

