\documentclass{article}

\usepackage{ifthen}
\usepackage{longtable}
\pagestyle{empty}

\textheight 10in
\topmargin -1in
\textwidth 7.5in
\oddsidemargin -0.5in

\begin{document}

\newcommand{\bs}{$\backslash$}
\makeatletter
\bfseries\sffamily

% 1 = title, 2 = 12, 3 = 0-2-8, 4 = 3-8, 5 = 4-8, 6 = 0-4-8, 7 = 0-5-8, 8 = 7-8, 9 = 0-7-8, 10 = 12-7-8
\def\Encoding#1{%
 \def\TN{{#1}}% \TN is "table name"
 \EncRelay%
}
\def\EncRelay#1#2#3#4#5#6#7#8#9{%
\begin{longtable}{|l|c|rrrr|rlllllllllllllll|}
\multicolumn{22}{c}{\large \TN\ Encoding} \\ % \TN is "table name"
\hline
Card & Core  & \multicolumn{4}{c|}{Core}          &     & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & \multicolumn{5}{l|}{Card Row Punch} \\
\cline{7-22}
Zone & Units & \multicolumn{4}{c|}{Hundreds Zone} & \multicolumn{9}{l}{Core Digit Bits} & 1 & 2   & 3  & 4  & 5      & 6   & 7  \\
\cline{3-6}
Row  & Zone  & none &  A &  B & AB &                  0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 8 & 8   & 8  & 8  & 8      & 8   & 8  \\
\hline
none & none  &    0 &  1 &  2 &  3 &                    & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0   & #3 & #4 & :      & $>$ & #7 \\
0    & A     &    4 &  5 &  6 &  7 &           $\wedge$ & / & S & T & U & V & W & X & Y & Z & #2  & ,  & #5 & #6     & \bs & #8 \\
11   & B     &    8 &  9 & 10 & 11 &                  - & J & K & L & M & N & O & P & Q & R & !   & \$ & *  & ]      & ;   & \underline{\ } \\
12   & AB    &   12 & 13 & 14 & 15 &                 #1 & A & B & C & D & E & F & G & H & I & ?   & .  & )  & [      & $<$ & #9 \\
\hline
\end{longtable}
}
\newcommand{\Notes}{
Notes:\\
Zero (0) is represented internally as C82 but punched as 0.\\
Record mark (\rlap{$\;|$}$=$ on 1403, $|$ in Pierce encodings, ' in
SimH encoding) is represented internally as A82 but is punched as 0-2-8
--- because 0 can't simultaneously be used for A and 82.\\
The A bit alone (\^{\ }) has no input punch on 1401 without a free RPQ
(which number I've forgotten).  With the RPQ or on 1410 it's 2-8.  It
might punch as 0.
}

%==============================================================================

{\bfseries\sffamily\Large\parskip 12pt \parindent 0pt

\begin{centering}
\LARGE 1401 BCD Encodings in ASCII\\
and Tables for Addressing above 1K

\end{centering}
\vskip 0.25in

The following pages have tables of:
\begin{itemize}
\item Pierce Primary (A chain) BCD encoding,
\item Pierce Alternative (H chain) BCD encoding, and
\item Traditional SimH BCD encoding.
\end{itemize}

Each table includes a Secret Decoder Ring for addressing above 1k.

Page 2 has six copies of Pierce Primary encoding; page 3 has six copies
of Pierce Alternative encoding; page 4 has six copies of SimH encoding.

If you print pages 2 and 3 duplex and page 4 simplex, you can laminate
the sheets and cut each one into six pieces, giving shirt-pocket size
reference cards for the three encodings.

Page 5 has two copies of all three encodings, but even if cut in half
each set of tables is a bit too large for a shirt-pocket reference.

Page 6 has three copies of the Pierce encodings, while page 7 has three
copies of the SimH encoding, with space for one table below each.  If you
print pages 6 and 7 duplex and laminate the sheet, you can cut it into
three shirt-pocket size reference cards with Pierce encodings one one
side and SimH encodings on the other.

\Notes

--- Van Snyder\\
23 March 2010
}

%==============================================================================
\newpage

\newcounter{i}
\setcounter{i}{1}

\whiledo{\value{i}<7}{
%                                    12  0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Primary (A chain)} {\&} {$|$} {\#} {@} {\%} {$\sim$} {\{} {"}   {\}}
\addtocounter{i}{1}
}

%==============================================================================
\newpage

\setcounter{i}{1}

\whiledo{\value{i}<7}{
%                                       12   0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Alternative (H chain)} {+}  {$|$} {=}  {'} {(}  {$\sim$} {\{} {"}   {\}}
\addtocounter{i}{1}
}

%==============================================================================
\newpage

\setcounter{i}{1}

\whiledo{\value{i}<7}{
%                                12  0-2-8 3-8  4-8 0-4-8 0-5-8 7-8 0-7-8 12-7-8
\Encoding{Traditional SimH BCD} {\&}  {'}  {\#} {@} {\%}  {=}   {(} {+}   {"}
\addtocounter{i}{1}
}

%==============================================================================
\newpage

\setcounter{i}{1}
\whiledo{\value{i}<3}{
%                                    12  0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Primary (A chain)} {\&} {$|$} {\#} {@} {\%} {$\sim$} {\{} {"}   {\}}

%                                       12   0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Alternative (H chain)} {+}  {$|$} {=}  {'} {(}  {$\sim$} {\{} {"}   {\}}

%                                12  0-2-8 3-8  4-8 0-4-8 0-5-8 7-8 0-7-8 12-7-8
\Encoding{Traditional SimH BCD} {\&}  {'}  {\#} {@} {\%}  {=}   {(} {+}   {"}

\addtocounter{i}{1}
}

%==============================================================================
\newpage

\setcounter{i}{1}
\whiledo{\value{i}<4}{

%                                    12  0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Primary (A chain)} {\&} {$|$} {\#} {@} {\%} {$\sim$} {\{} {"}   {\}}

%                                       12   0-2-8 3-8  4-8 0-4-8 0-5-8   7-8 0-7-8 12-7-8
\Encoding{Pierce Alternative (H chain)} {+}  {$|$} {=}  {'} {(}  {$\sim$} {\{} {"}   {\}}
\addtocounter{i}{1}
}

%==============================================================================
\newpage

\setcounter{i}{1}
\whiledo{\value{i}<4}{
%                                12  0-2-8 3-8  4-8 0-4-8 0-5-8 7-8 0-7-8 12-7-8
\Encoding{Traditional SimH BCD} {\&}  {'}  {\#} {@} {\%}  {=}   {(} {+}   {"}

\parbox{7in}{\parindent 0pt
\Notes
}

\vskip 0.72in

\addtocounter{i}{1}
}

\end{document}
