As was mentioned earlier, the central section of the control system of 
this printer is a 32-state state machine. This is sufficiently small to 
be easily understandable, so a state-by-state description of it will be 
given. 

From the current state and the contents of the ROM location associated 
with that state it is possible to determine the condition that will be 
tested, the possible next states and which (if any) output signals are 
generated. And thus a `source listing' of the state machine can be 
produced. This will be given below in 3 parts, the character entry routine; 
the (quite short) paper advancing routine and finally, of course, the 
print cycle. 

Each state  will be given as a pair of hexadecimal numbers followed by a 
1-line description. The first number is the current state. the second 
number is the contents of the state machine ROM for that state. The 
description decodes these numbers to give the condition that is tested, 
the possible next states and the signal generated (if any). This will be 
followed by a longer description of how this state affects the printer.

\section{Character Input}

This routine reads characters form the host interface. until a linefeed is 
received. It ignores non-printable cheaters and stores others in the 
buffer shift register. When a linefeed is read, then if no characters 
have been loaded since the last linefeed, the paper is simply advanced, 
otherwise a full print cycle is started.

\begin{verbatim}
00 : 20    if(Stb/) goto (00,02) , ClrFlg
\end{verbatim}

\noindent
The character entry routine starts in state 0, which is also the state 
where it starts on a hardware reset (after power-on, the printer needs to 
load characters before it can print them). The interface flag flip-flop 
is cleared, indicating to the host that the printer is ready to accept a 
character. The machine remains in this 
state until it gets a strobe signal from the host indicating that there 
is a character to load. it then goes to state 2

\begin{verbatim}
02 : 2B    goto (06) 
06 : C2    if(PrtChar) goto (12,11) , InClk
\end{verbatim}

\noindent
State 2 is a no-operation state, added simply due to the interaction between 
the states, next states, condition and output signals. It goes directly 
to state 6. This state outputs (\bf InClk) which loads the character 
into the input register and also sets the interface flag flip-flop, 
indicating the printer is busy. The character is tested  to see if it is one 
that the printer should handle (that it is not a control character other 
than linefeed). If it is not to be processed, the state machine skips 
over the input routine, thus ignoring this character.

\begin{verbatim}
12 : F4    if(LF/) goto (19,1B) 
\end{verbatim}

\noindent
The character is now tested to see if it's a line feed. 

\begin{verbatim}
1B : CF    if(Empty/) goto (17,15) 
\end{verbatim}

\noindent
If it was a linefeed, the next test is whether the buffer is empty (that 
is, whether the `empty' flip-flop is set). If there are characters in the 
buffer, start a print cycle, Otherwise just feed the paper.

\begin{verbatim}
19 : C1    if(Start/) goto (14,11) 
\end{verbatim}

\noindent
The state machine gets to this state if it is a printable character. If 
the character counter is 0 and the buffer is non-empty, it indicates that 
the buffer is completely full. In that case, ignore the character, thus 
truncating the line. 

\begin{verbatim}
14 : 9D    goto (0D) , SClk
\end{verbatim}

\noindent
The state machine gets to this state if it's a printable character and 
there is still space in the buffer shift register. It now clocks the 
shift register to load in this character/

\begin{verbatim}
0D : C4    goto (11) , PHOut
\end{verbatim}

\noindent.
In the character entry mode, {\bf PHOut} will increment the character 
counter (as one more character has been loaded ) and set the `empty' 
flip-flop (as there is now something in the buffer)

\begin{verbatim}
11 : C0    if(Stb/) goto (10,11) 
\end{verbatim}

\noindent
The state machine gets to this state when the current input character has 
been processed. It waits for the host to deassert the strobe signal  

\begin{verbatim}
10 : 00    goto (00) , ClrFlg
\end{verbatim}

\noindent
When the strobe signal becomes inactive, the state machine clears the 
interface flag and goes back to the start to process the next character.

\section{Paper Feed}

This routine drives the stepper motor and increments the dot row counter 
until the latter has got to 0. It thus completes the inter-line gap if 
characters have been printed and feeds the paper by an entire character 
line for a blank line. 

\begin{verbatim}
15 : 94    goto (09) , Autofeed
\end{verbatim}

\noindent
Send a step pulse to the motor control circuit to advance the paper by 
one dot row

\begin{verbatim}
09 : 93    if(Timing) goto (0E,09)
\end{verbatim}

\noindent
Wait until the timing monostable circuit U26b (on the {\bf Control} PCB) 
has timed out, This gives the motor and mechansim time to move.

\begin{verbatim} 
0E : FF    goto (1F) , RowClk
\end{verbatim}

\noindent
Increment the dot row counter

\begin{verbatim}
1F : C5    if(RotEn) goto (15,11) 
\end{verbatim}

\noindent
Go around again if the counter has not got back to 0 (that is, if {\bf 
RotEn} is still 1). Otherwise go back  and wait for the strobe signal from 
the host to be inactive and then wait for next character to be sent.

\section{Print Cycle}

This routine prints the contents of the buffer shift register. It begins 
by filling the remainder of the shift register with space characters, in 
the process moving the input characters to the start of the lien. It 
then prints each dot row of the characters by sending each fourth 
character from the buffer to the printhead shift register via the 
character generator. Once this section of the line is printed, the 
remaining 3 quarters are printed in turn. Then the paper is advanced  by 
one dot row and the process repeated until the entire characters have  
been printed.

The first part of this routine, therefore, fills the remainder of the 
buffer with spaces.

\begin{verbatim}
17 : 89    if(Start/) goto (04,05) , ForceSpace
\end{verbatim}

\noindent
Set the input register flip-flops to a space character. Exit this loop 
when the character counter has wrapped around to 0. This can be thought of 
as a while(buffer not full) loop.

\begin{verbatim}
04 : 10    goto (08) , SClk
\end{verbatim}

\noindent
Clock the space into the data buffer shift register.

\begin{verbatim}
08 : EF    goto (17) , PHClk
\end{verbatim}

\noindent
Increment the character counter and go round again to load the next space 
character.

The line buffer now full and ready for printing

\begin{verbatim}
05 : E6    goto (13) , Autofeed
\end{verbatim}

\noindent
Advance the paper by one dot row

\begin{verbatim}
13 : E3    if(Timing) goto (16,13) 
\end{verbatim}

\noindent
Wait for the timing monostable to time out to give the motor and 
mechanism time to move the paper

\begin{verbatim}
16 : 3E    if(Row7) goto (0B,0E) , InClk
\end{verbatim}

\noindent
Check to see if 7 dot rows have been printed -- that is, the complete 
character. if so, the go to the paper feed routine, other wise continue 
with printing this character line

\begin{verbatim}
0B : 7B    goto (1E) 
1E : 84    goto (01) , RowClk
\end{verbatim}

\noindent
Increment the dot row counter. This will automatically set {\bf RotEn}, 
thus selecting the print (rather than input) mode for the printer control 
system.

\begin{verbatim}
01 : 50    goto (18) 
18 : BF    goto (0F) , PHClk
\end{verbatim}

\noindent
Clock the printhead shift registers. This will transfer the bitmap for 
the current row of the current character into these shift registers

\begin{verbatim}
0F : DA    if(char0/) goto (1A,1D) 
\end{verbatim}

\noindent
Have all 80 characters in the line been processed. If so, then skip the 4 
character rotation at the end of the line so that the shift register is 
left in the same state at the start and end of the line. This is 
essential so that the dot rows of each character are aligned. 

\begin{verbatim}
1A : AF    goto (07) 
07 : 59    goto (1C) , ForceSpace
\end{verbatim}

\noindent
Otherwise, rotate the line buffer by a  total of 4 characters to select the 
next character to be printed in this pass. The {\bf ForceSpace} signal now 
increments the 4-state Shift Counter

\begin{verbatim}
1C : A7    if(LnFlg) goto (07,03) , SClk
\end{verbatim}

\noindent
Rotate the buffer shift register and go round again until {\bf LnFlg} is 
asserted. This is a total of 4 times round this loop. 

\begin{verbatim}
03 : D8    if(newbank/) goto (18,1D) 
\end{verbatim}

\noindent
Have 20 characters --  a complete quarter of the line -- been loaded into 
the printhead shift register? If not, go round again. 

\begin{verbatim}
1D : 32    goto (0A) , PHOut
\end{verbatim}

\noindent
Trigger the timing monostables to activate the printhead and `burn' this 
part of the line onto the paper.

\begin{verbatim}
0A : 31    if(Timing) goto (0C,0A) 
\end{verbatim}

\noindent
Wait for the timing monostable to time out to give the printhead time to 
act.

\begin{verbatim}
0C : 8C    if(firstbank/) goto (01,05) , SClk
\end{verbatim}

\noindent
Rotate the line buffer by one character to move the next quarter into 
position. If the character counter has wrapped around then all 4 quarters  
have been printed, so go back to the start to advance the paper by one 
dot row and start to print the next dot row of these characters. if not, 
then go back to print the next quarter of the line.

