
    Alick Glennie Autocode compiler 

    Rewriten by Roberto Sancho Apr/2023 
    using doc on compiler form original author
            
    https://archiveshub.jisc.ac.uk/data/gb133-muc/5-9/muc/9/14

      (a) Photocopy of a 16-page typewritten manual describing 
          Glennies AUTOCODE routine. (Probably a draft for a 
          manual to be entitled The Routine AUTOCODE and its use).   

      (b) Photocopy of 14 pages of Glennies lecture notes on 
          The automatic coding of an electronic computer dated 
          14th December 1952.


    [Col /          E ]                 [Col @          A ]              
                                                                          
    | OIYO | / | H:/C |                 | PIYO | / | STA/ | 
    | A:YG | E | @//N |                 | E:YG | E | E/// |
    | A//T | @ | @//A |                 | D//T | @ | //TE | testb
    | D/$$ | A | A/QO |                 | S@$$ | A | STB/ |                        
    | E:QO | : | LIPO |                 | H/QO | : | E/// |
    | PIQB | S | JEPG |                 | Y/YO | S | CONT | control                  
    | I/QO | I | /UPZ |                 | //$/ | I | ROL/ |                          
    | QS/P | U | UEQO |                 | TITJ | U | E/// |
    | :C/V | # | QS/P |                 | E:TN | # | //EN | entry 
    | QE$$ | D | @C/V |                 | E:/M | D | TRY/ |                         
    | /:YO | R |      |                 | T@/P | R | E/// |
    | BIYG | J | //$Q |                 | K@QG | J | //ER | erase   
    | W//T | N |      |                 | E:YG | N | ASE/ |         
    | A:QO | F | PIYO |                 | A@/T | F | E/// |
    | K//P | C | KE/T |                 | DS/Q | C | ///L | loop
    | :/$$ | K | $E$$ |                 | A/// | K | OOP/ |               
    | L/QO | T | BIYO |                 | T@$$ | T | A/// |
    | K//P | Z | A:YG |                 | @/$/ | Z | /REP | repeat        
    | A/// | L | WE/T |                 | ///S | L | EAT/ |       
    | K/$$ | W | GE$$ |                 | //PO | W | :/// |
    | XA// | H | PIQO |                 | H@QO | H | SUBR | subroutine     
    | N/// | Y | PEQG |                 | QS/P | Y | OUTI |                
    | /:YO | P | Z$$$ |                 | NC/V | P | E/// |                         
    | BIYG | Q | PIQB |                 |      | Q | ADRO | adroutine          
    | DS/O | O | OEQO |                 |      | O | UTIN |                                      
    | TSO: | B | QS/P |           write | //WR | B | E/// |
    | B//: | G | RC/V |                 | ITE/ | G | //CL | close                           
    | V:/C | " | PIQO |                 | E/// | " | OSE/ |                                 
    | @//A | M | XEQG |       fractions | FRAC | M | //// |               
    | @//N | X | K$$$ |                 | TION | X | //ST | start        
    | B//: | V | $E/P |                 | @/// | V | ART/ |              
    | @//A | $ | PE$$ |           testa | //TE | $ | S/// |               
                                                                          
       
    [End]

                 process assign, define vars, set op
                 calls INPUT.3 to process commands
                 calls TRANS.1 to translate sentences

                 assign
            
    0  //  OIYO  B5=[OI] nchars - number of chars read from sentence
    1  E/  A:YG  B5=B5-2
    2  @/  A//T  if (B>=0) goto 10 -> if (nchars >= 2) goto because not the first char of sentence
    3  A/  D/$$  cn goto 10

                 SENTENCE ->a[r] (OP=1)

    4  :/  E:QO  B7=1

                 set sentence OP then goto read_ch 

    5  S/  PIQB  [PI] OP operation to assemble = B7

                 goto read_ch

    6  I/  I/QO  B7=*  
    7  U/  QS/P  transfer to adroutine
    8  #/  :C/V  cue to INPUT.1 (read_ch)
    9  D/  QE$$  cn goto 56 translate

                 check if sentence is a->r or r->a

   10  R/  /:YO  B5=0
   11  J/  BIYG  B5=B5-[nvars]
   12  N/  W//T  if (B>=0) goto 16 -> nvars=0 so sentence is r->a

                 SENTENCE a->r (OP=2)

   13  F/  A:QO  B7=2
   14  C/  K//P  goto 5 set op
   15  K/  :/$$  cn goto 5 set op

                 SENTENCE r->a (OP=3)

   16  T/  L/QO  B7=3
   17  Z/  K//P  goto 5 set op
   18  L/  A///  const 3
   19  W/  K/$$  cn goto 16
   20  H/  XA//  const addr of last command entry in command table 
   21  Y/  N///  const 12 - total num of last command 

                 define var addr

   22  P/  /:YO  B5=0
   23  Q/  BIYG  B5=B5-[nvars]
   24  O/  DS/O  if (B>=0) goto * -> if nvars = 0 then dynamic stop here
                 SYNTAX ERROR: @ with no var                       

                 read from PTR 2 chars -> the address ab of var

   25  B/  TSO:  clear acc
   26  G/  B//:  read PTR (first of two chars addr ab)
   27  "/  V:/C  process them to set B7
   28  M/  @//A  
   29  X/  @//N  
   30  V/  B//:  read PTR (second of two chars addr ab)
   31  $/  @//A  
   32  /E  H:/C  
   33  EE  @//N  
   34  @E  @//A  [@/ A/]=AM, AM=0
   35  AE  A/QO  B7=ab//
   36  :E  LIPO  B6=[Var0] get the var we are defining
   37  SE  JEPG  B6=B6 - //$Q to change B6 to B7 and instr TZ to TB
   38  IE  /UPZ  [B6+/U]=B7  colum /U holds the table of var addrs
   39  UE  UEQO  B7=*  
   40  #E  QS/P  transfer to adroutine
   41  DE  @C/V  cue to INPUT.1 (read_sentence)
   42  RE   
   43  JE  //$Q  const -//E#
   44  NE  

                 Set OP - calculate OP for terminated sentence

   45  FE  PIYO  B5=[PI] OP operation to assemble 
   46  CE  KE/T  if (B>=0) goto 64 -> if OP>=0, OP is already set, so take goto to continue 
   47  KE  $E$$  cn goto 64
 
                 check if sentence is mult or addition

   48  TE  BIYO  B5=[nvars]
   49  ZE  A:YG  B5=B5-2
   50  LE  WE/T  if (B>=0) goto 59 -> if (nvars >= 2) goto mult  
   51  WE  GE$$  cn goto 59

                 SENTENCE +var (OP=5) or -var (OP=6)

   52  HE  PIQO  B7=[PI] OP operation to assemble 
   53  YE  PEQG  B7=B7+10+5
   54  PE  Z$$$  const -15

                 set sentence OP 

   55  QE  PIQB  [PI] OP operation to assemble = B7
   
                 goto translate
           
   56  OE  OEQO  B7=*
   57  BE  QS/P  transfer to adroutine
   58  GE  RC/V  cue to TRANS.1 (translate)

                 SENTENCE +mult (OP=7) or -mult (OP=8)

   59  "E  PIQO  B7=[PI] OP operation to assemble 
   60  ME  XEQG  B7=B7+10+7
   61  XE  K$$$  const -17
   62  VE  $E/P  goto 55 set op 
   63  $E  PE$$  cn goto 55 set op 

                 check if OP>0 (so sentence parsed) or OP=0 (sentence is a command yet to be parsed)

   64  /@  PIYO  B5=[OP]
   65  E@  E:YG  B5=B5-1
   66  @@  D//T  if (B>=0) goto Translate -> if OP>0, goto to translate sentence
   67  A@  S@$$  cn goto 70
            
                 check command in cmd variable

   68  :@  H/QO  B7=XA// addr of last command entry in command table
   69  S@  Y/YO  B5=12
   70  I@  //$/  AL=[B7], AM=0
   71  U@  TITJ  AL=AL XOR cmd
   72  #@  E:TN  AL=AL-1
   73  D@  E:/M  if (A>=0) skip 1 instr
   74  R@  T@/P  goto 81 found
   75  J@  K@QG  B7=B7-3
   76  N@  E:YG  B5=B5-1
   77  F@  A@/T  if (B>=0) goto 70
   78  C@  DS/Q  goto * -> if cmd not found then dynamic stop here
                 SYNTAX ERROR: unknown command  
            
   79  K@  A///  const 3
   80  T@  T@$$  cn goto found

                 command found

   81  Z@  @/$/  AL=[B7+2] get b/// param type
   82  L@  ///S  [//]=AL save it
   83  W@  //PO  B6=[//]
   84  H@  H@QO  B7=*
   85  Y@  QS/P  transfer to adroutine
   86  P@  NC/V  cue to INPUT.3 (read_cmd_params), enter with B5=func num, B6=b/// (param type)
   87  Q@  
   88  O@  
   
           start to command table
           
   89  B@  comm
   90  G@  and/
   91  "@  param type
   92  M@     / -> no param 
   93  X@     E -> one teleprinter char as param label 
   94  V@     @ -> fractions param
   95  $@     A -> loop param
   96  /A     : -> repeat param
   97  EA     S -> start param: one optional teleprinter char as param label 
   98  @A  
   99  AA  
  100  :A  
  101  SA  
  102  IA  
  103  UA  
  104  #A  
  105  DA  
  106  RA  
  107  JA  
  108  NA  
  109  FA  
  110  CA  
  111  KA  
  112  TA  
  113  ZA  
  114  LA  
  115  WA  
  116  HA  
  117  YA  
  118  PA  
  119  QA  
  120  OA  
  121  BA  
  122  GA  
  123  "A  
  124  MA  
  125  XA  
  126  VA  
  127  $A  
