\documentclass{report}

\usepackage{alltt}
\usepackage{longtable}

\oddsidemargin 0pt
\evensidemargin 0pt
\topmargin -1in
\textheight 9.5in
\textwidth 6.5in
\parindent 0pt
\parskip 3pt

\begin{document}

\begin{center}
{\Large\bf 1401 Test Tape Loader}
\end{center}

The first record on the IBM diagnostics tape contains a loader for the
programs on the tape.  After the initial load, it halts at 400 (I-address
register 404) with the A-address register 433.

Pushing start results in another halt at 3000 (I-star 3001).  Then if
1277 is

\begin{itemize}
\item[1] The program is loaded if 73-76 $\neq$ 1273-1276
\item[2] The program is loaded if 73-76 = 1273-1276
\item[3] The program is loaded if 73-74 $\neq$ 1273-1274
\item[4] The program is loaded if 73-74 = 1273-1274
\item[Else] The program isn't loaded.
\end{itemize}

This is a routine that checks for errors and starts over at the beginning
of the tape when the end-of-file is noticed.  It occupies 3000-3498.

Pushing start reset and then start after the halt at 400 causes positions
73-76 of tape records after headers to be compared with 1273-1276.  It
only checks program codes that have no zone in the second character
(74).  If sense switch F is on, it runs the first program that matches. 
If sense switch F is off, it runs the first program that doesn't match. 
This loader fits on 1400-character machines.

\begin{center}
{\Large\bf 1401 Test Tape and Decks --- Revised}
\end{center}

Programs can be stacked in the card reader, or run from tape.  When run
from tape, a program that selects which programs to run, called the
\emph{chain loader}, decides which programs to run based upon parameters
pre-loaded into core.  When run from cards, the chain loader simply loads
the next program.

The following are assumed to be in 181-199 when a program, including the
tape chain loader, runs:

\begin{tabular}{ll}
181     & {\tt /} for ``run if target ID not equal to test ID,'' \\
        & {\tt S} for ``run if target ID equal to test ID,'' \\
        & {\tt T} for ``run if target ID less than test ID,''\\
        & {\tt U} for ``run if target ID greater than test ID,''\\
        & Blank for ``run everything.'' \\
        & {\tt B} \dots\ {\tt G} for ``run if the specified sense switch is on.''\\
182     & Last digit of address of target and test IDs: 3, 4, 5 or 6.
          Run everything if blank.\\
183-186 & Target ID. \\
187-189 & Top address to clear, max 3999, use 3999 if last character blank. \\
190     & Print headers if not blank. \\
191-199 & Programs can look here for options. \\
\end{tabular}

These can be loaded either from the console switches, or by a one-card
loader:

{\tt\begin{verbatim}
  1     SW   8,12
  8     SW   19
 12     SW   26,30
 19     SW   37,44
 26     SW   45
 30     LCA  63,199         LOAD PARAMETERS
 37     MN   2,81           CLOBBER GM IN CASE LOADING FROM CARDS
 44     H
 45     DCW  #1    181      D MODIFIER FOR TARGET ID TEST
 46     DC   #1    182      LAST DIGIT OF ADDRESS FOR TARGET, 3-6
 47-50  DC   #4    183-186  TARGET ID
 51-53  DC   #3    187-189  TOP ADDRESS TO CLEAR, USE 3999 IF BLANK 
 54     DC   #1    190      HEADER PRINTER PRINTS IF NOT BLANK
 55-63  DC   #12   188-199  PROGRAMS CAN LOOK HERE FOR OPTIONS

....5...10...15...20...25...30...35...40...45...50...55...60...65...70...75...80
,008012,019,026030,037044,045L063199D002081./#ididTTThBCDEFGHIJ  PARAMS     01 A
1      1   1      1      1   1      1      11
\end{verbatim}}

It is intended that this would be loaded from the card reader.  When it
halts, the tests would be loaded either from cards or tape.

Core locations 1-80 are cleared before a program is run no matter whether
it is run from cards or tape.  If programs are run from tape, 100-180 and
200 to the address in 187-189 are also cleared.  If 189 is blank, 3999 is
used for the top address.

If run from cards, core (including the parameter area from 181-199) is
cleared if the clear storage cards (the first two produced by Autocoder)
are included in the run deck, and not cleared otherwise.  The clear
storage cards \emph{should not} be included ahead of the chain loader. 
Otherwise, every program will be run.

Each test block consists of the test program header record, the test
program, and its detail records.  The first two detail records, which
are present even if the program needs no other detail records, are the
page headings that are printed if 190 is not blank.

Header records are actually little programs that run in 1-80.  All other
programs are loaded into 201.  The last address loaded is limited by the
origin of the program that writes programs on tape -- 3694 -- but programs
can use core at higher addresses, for example, for tape input/output
areas.

When run from cards, several decks can be stacked in the card reader. 
Each test program loads the next one.

Program headers have  A  in column 80, ID in 73-76,  C in 79 for the chain
loader, T in 79 for test programs, E in 79 for the end-of-file program, an
optional title in 49-71, and the following in 1-27 if it's not an
end-of-file program and the clear storage cards produced by Autocoder are
included:

{\tt\begin{verbatim}
  1  SW   8,15
  8  SW   26,30
 15  B    26
     ORG  26
 26  R    1
 26  DCW  #1

....5...10...15...20...25...30
,008015,026030B026       1001
1      1      1          1   1
\end{verbatim}}

which works with all clear routines produced by Autocoder or SPS, or the
following in 1-40, which only works for Autocoder programs, if the clear
storage cards are removed:

{\tt\begin{verbatim}
  1  SW   8,15
  8  SW   36,40
 15  B    36
 36  R    1
 26  DCW  #1

....5...10...15...20...25...30...35...40
,008015,036040B036                 1001
1      1      1                    1   1
\end{verbatim}}

The program that writes programs onto tape replaces 1-30 by

{\tt\begin{verbatim}
  1  RTW  1,201
  9  BER  21
 14  CS   ###,80
 21  BSP  1
 26  H    1
 30  DCW  #1

....5...10...15...20...25...30
L%U1201RB018L/###080U%U1B.001
1       1    1      1    1   1
\end{verbatim}}

The \verb=###= is filled from the entry address on the END card of the
program's object deck.

If the header is an end-of-file program, the following is expected in
1-36:

{\tt\begin{verbatim}
  1  SW   8,15
  8  SW   22,27
 15  SW   31,32
 22  RWD  1
 27  NOP  99
 31  H
 32  B    1
 36  DC   #1

....5...10...15...20...25...30...35.
,008015,022027,031032U%U1RN099.B001
1      1      1      1    1   11
\end{verbatim}}

Each program has a routine that reads and prints its page headings if 190
is not blank, and reads its detail records or the header record for the
next program.  It reads from cards if there are any.  Then if there are no
cards and 81 is a group mark (the tape drive deposits a group mark in 81
if the program is loaded from tape) it reads them from tape.  If a header
has A in column 80 the detail-reading routine branches to 1.

{\tt\begin{verbatim}
     *
     * Halts:
     * 99 in A-star and B-star if no more detail records and no header.
     *    Pushing start tries again.  If reading detail from tape it
     *    is nonetheless possible to read more detail from cards here.
     * 86 in A-star and B-star if tape error.  Pushing start tries again.
     *    It is possible to read more detail from cards here.
     *
               org  336            At 336 to allow chaining CS to W
     headpr    equ  190            Print first two detail if not blank.
 336 headct    dcw  0              How many detail read?  Print first 2.
 337 taperr    bsp  1              Backspace
 342           nop  86             86 if tape error
 346           h                   Halt with 86 in A-star and B-star
 347 detail    sw   1,81           1 for header, 81 under GM if tape
 354           blc  nocard         No cards left?
 359           r    testhd         Read a detail or header card
 363 nocard    bce  tapehd,81,"    Tape load puts GM in 81
 371           b    finis
 375 tapeof    bsp  1
 380 finis     nop  99             99 if no tape or EOF
 384           h                   Halt with 99 in A-star and B-star
 385           b    detail         Try again
 389 tapehd    rtw  1,1            Read a detail or header tape record
 397           ber  taperr         Error?
 402           bef  tapeof         Eof?
 407 testhd    bce  1,80,a         Execute if a header
 415           bce  cont,headct,2  Headers printed yet?
 423           bce  skiphd,headpr,  Skip header printing?
 431           lca  77,277         Print the first two headers
 438           w
 439           cs
 440           cs
 441           w
 442 skiphd    a    *-6,headct
 449           b    detail
 453 cont      equ  *&1
     * Continue here after reading detail
\end{verbatim}}

The {\tt CONT} label is where the program continues if the next record
does not have {\tt A} in column 80.

If the program is run from tape, but one wants to read some detail records
from cards and then read more from tape, put the following one-card
program after the detail records read from cards:

{\tt\begin{verbatim}
  1  SW   8,15
  8  SW   22,29
 15  LCA  33,358  LCA  33,DETAIL&11
 22  CS   347,80  CS   DETAIL,80
 29  B    363     B    NOCARD

....5...10...15...20...25...30...35...40...45...50...55...60...65...70...75...80
,008015,022029L033358/347080B363
1      1      1      1      1
\end{verbatim}}

\begin{center}
{\Large\bf Loading programs onto tape}
\end{center}

To write programs on tape, put the program to write programs on tape at
the head of the deck.  Then put a copy of the chain loader header and
chain loader program ahead of each test block.  Finally, put an
end-of-file header at the end of the deck.

The program that loads programs onto tape reads heading cards, programs
and detail cards, and writes them to tape.  The headers are modified as
described above.  All records on the tape are written with word marks.
The sequence of records for a program block is

\begin{description}
\item[Header record]  Header records are read into 1-80, with word marks. 
This results in a group mark in 81.  The header record loads the program.

\item[Program]  Programs are written from 201 to their group mark with a
word mark, and read into 201 with word marks when they are run.  They
should therefore not depend upon initializations of core below 201.  Also,
the parameter block that the chain loader and header printer use, and
options that programs might find useful, are in 181-199.

\item[Detail records]  Other than the page headings, these are optional.
\end{description}

The end-of-file header is not followed by a program or detail records.

The sequence of program blocks on the tape is

\begin{description}
\item[Chain loader] This program reads further on the tape and decides
which programs to load and execute.  It uses specifications in 181-186 to
decide.

\item[Test program] This is the program that actually does the tests.
\end{description}

\begin{center}
{\Large\bf Program Listing -- Write Chain Tape}
\end{center}

\input{write}

\begin{center}
{\Large\bf Program Listing -- Chain Loader}
\end{center}

\input{chain}
\begin{itemize}
\item[1-6]   Lengths of up to five instructions in test
\item[7-45]  Instructions to implement test
\item[46-52] A field
\item[53-66] B field
\item[67-80] Correct result
\end{itemize}

A test can consist of up to seven instructions, provided the last one is
an unconditional branch (which it almost certainly will be), since a
five-character branch with a blank D-modifier doesn't need a word mark.

The infrastructure sets word marks in 46, 56 and 76.  Then it sets
a word mark in 7, and thereafter up to six more according to the lengths
given in 1-6.  The test is run by branching to 7.  The test should return
to {\tt WORKED} if the test succeeds, and {\tt FAILED} if it fails (see
the listing below).

\begin{center}
{\Large\bf Program Listing -- Infrastructure for one-card tests}
\end{center}

\input{new-2/infrastructure}

\begin{center}
{\Large\bf Program Listing -- Test examples}
\end{center}

\begin{verbatim}
* Test BCE equal and unequal                                               0050
840000b5430538b583                           8      8             BRANCH
811400b5830551bbb543                         1       24           NO BRANCH
* Test BWZ equal and unequal                                               0060
840000v543054bb583                           B       A            BRANCH
811140v583056Bvvvb543                        B      *KT4          NO BRANCH
* Test Compare and branch unequal                                          0100
754000c049056b543/b583                         h7     hh          UNEQUAL
754000c049056b583/b543                         rw     rw          EQUAL
754000c049057b543/b583 uneq because b longer   rw      rw         UNEQUAL
* Test load chain
714750L057157L)153C155076B583/B543           111111111111         1111111111
714750L057157L)153C155076B583/B543           akt4 akt4            akt4 akt4
\end{verbatim}

\begin{center}
{\Large\bf Program Listing -- Test examples output}
\end{center}

\begin{verbatim}
A/D----        B-------------      SHOULD BE-----      ACTUAL--------      STATUS
* TEST BCE EQUAL AND UNEQUAL                                               0050
8              8                   BRANCH              8                   OK
1               24                 NO BRANCH            24                 OK
* TEST BWZ EQUAL AND UNEQUAL                                               0060
B               A                  BRANCH               A                  OK
B              *KT4                NO BRANCH           *KT4                OK
* TEST COMPARE AND BRANCH UNEQUAL                                          0100
  H7             HH                UNEQUAL               HH                OK
  RW             RW                EQUAL                 RW                OK
  RW              RW               UNEQUAL                RW               OK
* TEST LOAD CHAIN                                      NOT MEANINGFUL      0110
1111111        11111               1111111111          11111               OK
AKT4 AK        T4                  AKT4 AKT4           T4                  OK
\end{verbatim}

To take over the test infrastructure with a bigger program than will fit
on one card:


followed by an autocoder-format deck, without clear or bootstrap cards.

After reporting the status of a test, the infrastructure still reads a
detail record, sets word marks as above, and returns to 7 to process each
detail record.  So the first five columns should have {\tt 400000}, and 7-10
should have a branch into the loaded test.  If the word marks are not
wanted, change the branch to {\tt SETUP} at {\tt HOOK} to branch to the
test.  The test should nonetheless set a word mark at 7, and plant a
branch to the test there, because the loops on sense switches B and D
return to 7.

To halt with 777 in A-star and B-star when everything is done (as opposed
to waiting on an empty card reader:

\begin{verbatim}
414000n777.b007                                        Halt when done      9999
\end{verbatim}

\begin{center}
{\Large\bf Listing of Tests}
\end{center}

There is a program that lists the one-card tests.  Output produced from above
input is below.  It shows the word marks under the code.

{\small\begin{verbatim}
CODE                                        A/D         B                     EXPECT
..10...15...20...25...30...35...40...45     ...50..     .55...60...65.     ..70...75...80
 * TEST BCE EQUAL AND UNEQUAL                                               0050
B5430538B583                                8           8                  BRANCH
1       1   1
B5830551BBB543                              1            24                NO BRANCH
1       111   1
 * TEST BWZ EQUAL AND UNEQUAL                                               0060
V543054BB583                                B            A                 BRANCH
1       1   1
V583056BVVVB543                             B           *KT4               NO BRANCH
1       1111   1
 * TEST COMPARE AND BRANCH UNEQUAL                                          0100
C049056B543/B583                              H7          HH               UNEQUAL
1      1    1   1
C049056B583/B543                              RW          RW               EQUAL
1      1    1   1
C049057B543/B583 UNEQ BECAUSE B LONGER        RW           RW              UNEQUAL
1      1    1   1
 * TEST LOAD CHAIN                                      NOT MEANINGFUL      0110
L057157L)153C155076B583/B543                1111111     11111              1111111111
1      11   1      1    1
L057157L)153C155076B583/B543                AKT4 AK     T4                 AKT4 AKT4
1      11   1      1    1
\end{verbatim}}

\begin{center}
{\Large\bf Yet another test infrastructure}
\end{center}

A small program prints page headings, prints test results, tests sense
switches, loads tests, and reads detail records and runs tests.  Records
with a 12 zone in 80 and  * in column 1 are simply printed.

Header cards that have * in column 1 contain:

\begin{itemize}
\item[1-72] Comment.
\item[73-77] Test block ID.
\item[78-80] Sequence number
\end{itemize}

The test block ID is copied to 292-296 and the sequence number is copied
to 298-300.  The comment is copied to 201-272.  Then if 190 is not blank,
the print area is printed.

Each test program is taken from a card with a 12 zone in column 80, but
not * in column 1.  Header cards that do not have * in 1 contain:

\begin{itemize}
\item[1-7] Lengths of instructions.
\item[8-72] Test program and title.
\item[73-77] Test block ID.
\item[78-80] Sequence number
\end{itemize}

The test block ID is copied to 292-296 and the sequence number is copied
to 298-300.  The test program and title in 8-72 are copied to 201-266 and
401-466 with word marks set as indicated by 1-7.  Then if 190 is not
blank, the print area is printed, with word marks.

After the test program is loaded, the infrastructure reads detail records,
which do not have a 12 zone in column 80.  Detail records have six fields,
which are copied to the print area:

\begin{longtable}{lll}
Card    & Print & \\
Columns & Columns & Contents \\
\hline
\endhead
1-20    & 201-220 & A field or D modifier \\
21-40   & 222-241 & B field \\
        & 243-262 & Test result \\
41-60   & 264-283 & Correct result \\
61-72   & 302-313 & Comment \\
73-77   & 292-296 & Test block ID \\
78-80   & 298-300 & Sequence number \\
\hline
\end{longtable}

After the detail record is loaded, the infrastructure branches to 401.
Test programs should develop the result in the print area, and then branch
to the infrastructure at one of the following addresses:

\begin{longtable}{llp{4.5in}}
Address & Label  & Function \\
\hline
\endhead
669     & FAILED & The test failed; rerun if SSB is on for scoping, else
                   do error processing. \\
674     & FAILNS & The test failed; don't test SSB; do error processing.
                   Presumably the test program tests SSB for a tighter
                   scoping loop.\\
636     & WORKED & The test worked; rerun if SSB is on for scoping, else
                   do successful test processing. \\
641     & WORKNS & The test worked; don't test SSB; do successful test
                   processing,  Presumably the test program tests SSB for
                   a tighter scoping loop.\\
699     & COMPAR & Compare the test result in 243-262 to the correct
                   result in 264-283, and branch to FAILED or WORKED
                   depending upon whether the result is unequal or not. \\
715     & COMPNS & Compare the test result in 243-262 to the correct
                   result in 264-283, and branch to FAILNS or WORKNS
                   depending upon whether the result is unequal or not. \\
706     & TEST   & Branch to FAILED or WORKED depending upon whether the
                   unequal indicator is set. \\
722     & TESTNS & Branch to FAILNS or WORKNS depending upon whether the
                   unequal indicator is set. \\
\hline
\end{longtable}

Sense switches are used as follows:

\begin{itemize}
\item[B] If on, execute a tight loop around the test, for scope analysis.
\item[C] If on, print correct test results.
\item[D] If on, repeat the test without reading another detail record. 
         This is useful for catching erratic errors.
\item[E] If on, halt on failures instead of printing.
\item[F, G] Not used by the infrastructure.
\end{itemize}

When the infrastructure starts, it tests three instructions superficially,
to make sure they work well enough to run the infrastructure.  If any
fail, the infrastructure halts.  The infrastructure also halts if a tape
error occurs while reading records from tape, or if a test fails and SSE
is on.  The halts are identified by having the following values in the A-
and B-address registers:

\begin{itemize}
\item[001] BWZ cannot reliably detect a 12 zone.
\item[002] Compare appears not to work.
\item[003] Add appears not to work.
\item[086] Tape error when reading a record from tape.
\item[099] Test failure.
\end{itemize}

\begin{center}
{\Large\bf Program Listing -- Infrastructure for one-card tests}
\end{center}

\input{new-3/infrastructure}

\begin{center}
{\Large\bf Program Listing -- Test examples}
\end{center}

\begin{verbatim}
* A/D field replaces * in BCE                                           0050  0A
7854574M001415B425021*B408BB674B408BM060262B641    BCE test equal       0050  0B
                                        branch                          0050  03
"                   "                   branch                          0050  04
* A/D field replaces * in BCE                                           0050  1A
7811740M001415B669023*BBM060262B636                BCE test unequal     0050  1B
1                    24                 no branch                       0050  15
1                   8/-                 no branch                       0050  16
7554000C002022B401BB636/B669 Compare and branch unequal -- equal fails  0100  1F
                     1                  UNEQUAL                         0100  17
\end{verbatim}

\begin{center}
{\Large\bf Program Listing -- Test examples output}
\end{center}

{\footnotesize\begin{verbatim}
* A/D FIELD REPLACES * IN BCE                                                              0050   0A
M001415B425021*B408BB674B408BM060262B641    BCE TEST EQUAL                                 0050   0B
1      1       1    1   1    1      1   1
--A/D FIELD--------- --B FIELD----------- --ACTUAL RESULT----- --CORRECT RESULT---- STATUS -ID-- SEQ
                                          BRANCH               BRANCH               OK     0050   03
"                    "                    BRANCH               BRANCH               OK     0050   04
* A/D FIELD REPLACES * IN BCE                                                              0050   1A
M001415B669023*BBM060262B636                BCE TEST UNEQUAL                               0050   1B
1      1       111      1   1
--A/D FIELD--------- --B FIELD----------- --ACTUAL RESULT----- --CORRECT RESULT---- STATUS -ID-- SEQ
1                     24                  NO BRANCH            NO BRANCH            OK     0050   15
1                    8/-                  NO BRANCH            NO BRANCH            OK     0050   16
C002022B401BB636/B669 COMPARE AND BRANCH UNEQUAL -- EQUAL FAILS                            0100   1F
1      1    1    1   1
A/D FIELD----------- B FIELD------------- ACTUAL RESULT------- CORRECT RESULT------ STATUS ID---
                      1                    1                   UNEQUAL              OK     0100   17
\end{verbatim}}

\end{document}
