   
     MANCHESTER UNIVERSITY COMPUTING MACHINE LABORATORY
    
     Programme Sheet B                  Date. 18.May.1955

    
    [Routine INPUT(1)      ] p4

    [Col  /    ]                        [     E    ]              
                                                                          
    | / | //T$ |                        | / | E:WC | (3)                                     
    | E | //T$ |                        | E | E:WC | (2)           
    | @ | //T$ |                        | @ | E:WC | (1)                                    
    | A | VA/: | set tube 3             | A | ##/P | (0)                                 
    | : | $A/: | set tubes 4,5          | : | @/IF |                                        
    | S | :DPO | B6=VS//                | S | @/PA |                                        
    | I | /:YO | clear switch           | I | NE@P |___ 2-way switch (dec.pt)               
    | U | /:HO | clears non-dec switch  | U | :/P/ | counts num of 
    | # | J#/P | clears +- switch       | # | E:TN | fractional digits                     
    | D | /:LO | clears dec.pt.switch   | D | :/PA | 
    | R | TSO: | clears A               | R | /:HO | clear non.dec switch                                                          
    | J | R//: | reads next char a      | J | $J/P |___ 
    | N | ///A |---                     | N | DE// |               
    | F | ///C |                        | F | IE// |               
    | C | J:/N | transfers a///         | C | E:LO | sets dec.pt switch
    | K | ///A | to B7                  | K | NE/P |___            
    | T | //QO |                        | T | A:QO | (>)           
    | Z | /JUP |___                     | Z | /@/P |___            
    | L | EDQO | prepare to read FIGS   | L | E:QO | (>=)          
    | W | E:/Q |___                     | W | /@/P |___            
    | H | /DQO | prepare to read        | H | JDQO | (!=)          
    | Y | Z/QB |               LETTERS  | Y | "IQB | plants code number describing inequality
    | P | J//P |___                     | P | RDQO | plants code number                 
    | Q | MDT/ | calls in               | Q | OIQB | corresponds to operation           
    | O | //ZA |   TRANSLATE(7)         | O | USQO | sets y                             
    | B | R//P |____                    | B | JIQB | switch                             
    | G | E:WC |(9)                     | G | UDPO | B6=RI//                            
    | " | E:WC |(8)                     | " | E:HO | sets non decimal switch            
    | M | E:WC |(7)                     | M | N@/P |___ to #/       
    | X | E:WC |(6)                     | X | YIQO | (=)           
    | V | E:WC |(5)                     | V | XA/P |___            
    | $ | E:WC |(4)                     | $ | /@// |               
                                                                                 
    [End]

   0  //  //T$    
   1  E/  //T$  Entry point: dummy instr 
   2  @/  //T$  dummy instr  
   3  A/  VA/:  Read: from Track 34R to Tube S3 (MagInstr @EEI -> read cols I U (VARS.TXT) 
   4  :/  $A/:  Read: from Track 33L to Tube S4 S5 (MagInstr read cols # D R J (INPUT.2A.txt, INPUT.2B.txt))
   5  S/  :DPO  B6=VS// 
   6  I/  /:YO  B5=0 -> clear switch 
   7  U/  /:HO  B4=0 -> clears non-dec switch 
   8  #/  J#/P  goto 266 (in INPUT.2A.txt) -> clears +/- switch in B3, goto 9
   9  D/  /:LO  B2=0 -> clears dec.pt.switch 

                Read next char from source   
                                        Q -> set Q switch to ///T

                ignore (skip) space, <LF> and $
                


  10  R/  TSO:  Clear Acc AL=AM=0 (+ const goto addr TS// -> entry in PERM for RCS goto ad-routine)
  11  J/  R//:  Read PTR char 

                Set B7=read char
  12  N/  ///A     [// E/]=AM -> Save char //// ///c, AM=0
  13  F/  ///C     D=//// ///c char read
  14  C/  J:/N     shift -> AL=0, AM=c/// ////
  15  K/  ///A     [// E/]=c/// ////, AM=0
  16  T/  //QO     B7=c read char

  17  Z/  /JUP  goto [B7 + /J] -> jump table on read char
          /RUP     if $ (autocode Erase) -> goto 10 -> read next char
                   if / (autocode fig shift) -> goto 18
                   if " (autocode letter shift) -> goto 20
          /RUP  if letter shift active 
                   if V (autocode $) -> goto 10 -> read next char
                   if X (autocode ?) -> goto 10 -> read next char
                   if O (autocode X) -> goto 98
                   if B (autocode Y) -> goto 100
                   if G (autocode Z) -> goto 102
                   if # (autocode H) -> goto 104
                   if H (autocode T) -> goto 106
                   if Z (autocode Q) -> goto 121
                   if I (autocode F) -> goto 273 -> func Fm()
                   if L (autocode R) -> goto 275 -> R sqrt func
          /JUP  if figure shift active 
                   if E@W:YPU#B (autocode 1..9) -> goto 34..26
                   if T (autocode 0) -> goto 261
                   if M (autocode .) -> goto 46
                   if G (autocode +) -> goto 73
                   if J (autocode -) -> goto 77
                   if O (autocode x) -> goto 69
                   if A (autocode *) -> goto 118
                   if A (autocode %) -> goto 71
                   if X (autocode n) -> goto 84
                   if R (autocode =) -> goto 61
                   if N (autocode v) -> goto 82
                   if F (autocode <LF>) -> goto 10 -> read next char
                   if C (autocode space) -> goto 10 -> read next char
                   if V (autocode <CR>) -> goto 278 (B1=HSI/, goto 23) -> translate the line
                   if S (autocode "(") -> goto 270
                   if I (autocode ")") -> goto 271
                   if H (autocode j) -> goto 94

                process autocode char fig shift
  18  L/  EDQO  B7=/JUP -> instr for jump table with fig shift 
  19  W/  E:/Q  goto 21

                process autocode char letter shift
  20  H/  /DQO  B7=/RUP -> instr for jump table with fig shift 
  21  Y/  Z/QB  [Z/]=B7 -> set the jump table for read chars (either /JUP or /RUP
  22  P/  J//P  goto 11 -> read next char

  23  Q/  MDT/  A=[MD]=$E// RE@/ -> cue to TRANSLATE(7)
  24  O/  //ZA  Save cue in addr [B1]
  25  B/  R//P  call entry for ad.routine in RCS SchemeC

                process autocode char '9' down to '1' char 
  26  G/  E:WC  
  27  "/  E:WC  
  28  M/  E:WC  
  29  X/  E:WC  
  30  V/  E:WC  
  31  $/  E:WC  
  32  /E  E:WC  
  33  EE  E:WC  
  34  @E  E:WC  incr AL -> AL=1..9 as the numeric char value
  35  AE  ##/P  goto 259 -> set D=10, check decimal const not too long, cont to 36
  36  :E  @/IF  if (B6=VS//) AL=AL+[/I]*10  -> add digit to [/I]=instruction label
                   (B6=TI//) AL=AL+[LI]*10  ->              [LI]=int part of z
                   (B6=:I//) AL=AL+[II]*10  ->              [II]=int part of x
                   (B6=RI//) AL=AL+[NI]*10  ->              [NI]=int part of y
                   (B6=HI//) AL=AL+[PI]*10  ->              [PI]=int part of j
  37  SE  @/PA  if (B6=VS//) [/I]=AL  -> [/I]=instruction label
                   (B6=TI//) [LI]=AL     [LI]=int part of z
                   (B6=:I//) [II]=AL     [II]=int part of x
                   (B6=RI//) [NI]=AL     [NI]=int part of y
                   (B6=HI//) [PI]=AL     [PI]=int part of j
  38  IE  NE@P  if (B2 dec.pt switch=0) goto 42
                                     1  goto 39  
                decimal point set -> decr decimal exp
  39  UE  :/P/  if (B6=:I//) AL=[#I] =decimal part of x
  40  #E  E:TN  decr AL
  41  DE  :/PA  if (B6=:I//) [#I]:AL =decimal part of x

  42  RE  /:HO  B4=0 clears non-dec switch 
  43  JE  $J/P  goto 10 -> read next char

  44  NE  DE//  
  45  FE  IE//  

                handle autocode decimal point
  46  CE  E:LO  B2=1 -> set dec.pt.switch 
  47  KE  NE/P  goto 42

                process autocode > char (teletype Z)
  48  TE  A:QO  B7=2
  49  ZE  /@/P  goto 53

                process autocode >= char (teletype L)
  50  LE  E:QO  B7=1
  51  WE  /@/P  goto 53

                process autocode != char (teletype D)
  52  HE  JDQO  B7=3 

  53  YE  "IQB  ["I]=B7, ["I]= nature of inequation = 1->'>=', 2->'>', 3->'!=', 4 ->'='
  54  PE  RDQO  B7=-2 -> set substraction as operation to plant
  
                Handle + operator
  55  QE  OIQB  [IO]=B7 -> [OI]=num for main op: -1 add, -2 sub, -3 mult, -4 div

  56  OE  USQO  B7=///T
  57  BE  JIQB  [JI]=B7=///T -> y switch set
  58  GE  UDPO  B6=RI// -> y vars are next to set by parsing

  59  "E  E:HO  B4=1 -> set non-decimal switch
  60  ME  N@/P  goto 8

                process autocode = char (teletype R)
  61  XE  YIQO  B7=[YI] -> B7=j switch
  62  VE  XA/P  goto 309, check B7, goto 65  
  63  $E  /@//  
  64  /@  HE//    

                process x 
  65  E@  USQO  B7=///T
  66  @@  SIQB  [SI]=B7  -> set x switch: the = usual threatement: now will process x
  67  A@  IDPO  B6=:I// 
  68  :@  ZD/P  goto 59 -> to set non-decimal switch 

                process autocode (x) char (teletype char O) -> circled cross as multiplication operator
  69  S@  DDQO  B7=-3 -> -3 is the code for mult operation 
  70  I@  J@/P  goto 55

                process autocode % or / char (teletype char Q) -> division
  71  U@  NSQO  B7=-4 -> -4 is the code for div operation 
  72  #@  J@/P  goto 55

                process autocode + char (teletype char G)
  73  D@  DSQO  B7=-1 -> this is the operation code for operator +
  74  R@  J@:P  if (B4=1) goto 8   B4=is non-dec switch -> B4=1->not and operator 
                    B4=0  goto 55  the '+' operator in an expression
  75  J@  PE//  
  76  N@  U///  
                process autocode - char (teletype char J)
  77  F@  C@:P  if (B4=1) goto 80   B4=is non-dec switch
                       0  goto 55   
  78  C@  YE//  
  79  K@  K@//  

  80  T@  TDWO  B3=///V -> B3= +- switch 
  81  Z@  B#/P  goto 267
                process autocode v char (teletype char N)
  82  L@  USQO  B7=///T
  83  W@  AIQB  [AI]=///T -> n/v switch for x set to 'v'
                process autocode n char (teletype char X)
  84  H@  Y@:P  if (B4=0) -> goto 87  B4=is non-dec switch
                       1          XXX

  85  Y@  P@//  
  86  P@  B@//  

  87  Q@  #DPO  B6=TI// next number read will be v/n subscript (v/n count)
  88  O@  USQO  B7=///T
  89  B@  ZIQB  [ZI z switch]=B7 
  90  G@  //P/  AL=[B6] v/n count for x/y/z
  91  "@  E:TC  incr AL
  92  M@  //PA  [B6]=AL -> incr v/n count
                           if (b6=TI//) -> n var -> incr [TI] v/n count
  93  X@  ZD/P  goto 59

                handle j -> jump to label
  94  V@  SDPO  B6=HI//
  95  $@  USQO  B7=///T
  96  /A  YIQB  [YI]=B7 -> set j switch
  97  EA  ZD/P  goto 59

                (fix to restore X Y Z to working condition)

  98  @A  SAQG  B7=B7-23   SO X -> B7=1, Y -> B7=2, Z -> B7=3
  99  AA  BIQB  [BI]=B7   -> [BI]=num for incidental. op
 100  :A  VJ/P  goto 278  -> process line as if <cr> has been encountered
   


                process autocode X char (print <cr>)
  98  @A  E:QO  B7=1
  99  AA  LD/P  goto 109

                process autocode Y char (print <lf>)
 100  :A  A:QO  B7=2
 101  SA  LD/P  goto 109

                process autocode Z char (Space)
 102  IA  JDQO  B7=3
 103  UA  LD/P  goto 109

                process autocode H char (Halt)
 104  #A  S:QO  B7=4
 105  DA  LD/P  goto 109 

                process autocode T char (Read Tape)
 106  RA  NDQO  B7=5
 107  JA  LD/P  goto 109 

 108  NA  FDQO  B7=6 
 109  FA  BIQB  [BI]=B7 -> set incidental operation = 6 -> input
 110  CA  J//P  goto 11 -> read next char

                Handle (
 111  KA  E:QO  B7=1
 112  TA  E:/Q  goto 114

                Handle )
 113  ZA  A:QO  B7=2
 114  LA  "D/:  read directory from Track 15LR to S6 S7 (cols N F C K)
 115  WA  MKQB  [MK]=B7 -> set bracket switch in directory
 116  HA  GD/:  save back to drum the directory
 117  YA  J//P  goto 11

                Handle * -> print z value of instr
 118  PA  USQO  B7=///T 
 119  QA  GIQB  [GI]=///T -> set p switch (print switch)
 120  OA  J//P  goto 11

                process autocode Q char (set complex mode)
 121  BA  USQO  B7=///T
 122  GA  @IQB  [@I]=B7 -> reset Q switch to ///T -> quit complex mode
 123  "A  J//P  goto 11

                process autocode I char (input)
 124  MA  SITB  [SI]=0 -> x-switch = ////
 125  XA  HD/P  goto 108

 126  VA  @EEI  MagInstr to Read from Track 34R to Tube S3 -> read cols I U (VARS.TXT) 
 127  $A  EE@#  MagInstr to Read from Track 33LR to Tube S4,S5 -> read cols # D R J (INPUT.2A.txt, INPUT.2B.txt)

 256  /#  OIQB  [OI]=B7 -> set [OI]=main op=1 -> func call  
 257  E#  ZD/P  goto 59
 258  @#  AE//   

                Process decimal Char 1..9: check if too many digits in numeric constant
 259  A#  DSQO  B7=///T
 260  :#  BDQB  [BD]=B7=///T  -> reading a number
 261  S#  BDZG  incr B1 -> one digit parsed
 262  I#  NE/T  if (B>=0) goto XXX -> too many digits 
 263  U#  @D/C  D=10
 264  ##  @#/P  goto 36 
 
                Init Autocode   
 265  D#  H$$$  const -12
 266  R#  /:WO  B3=0 -> clear +- switch 

 267  J#  D#ZO  B1=-12 init max num of digit in a number
 268  N#  BDTB  [BD]=0 
 269  F#  U:/P  goto back to 9 
 
                process autocode "(" char (teletype S)
 270  C#  V#SP  if (B5=0) goto 111 -> start "(" inmediate mode
                if (B5=1) goto 65 -> set to process x (reading "(" for start of func parameters)

                process autocode ")" char (teletype I)
 271  K#  M#SP  if (B5=0) goto 113 -> end ")" inmediate mode
                if (B5=1) goto 6 -> read next char (reading ")" for end of func parameters)

                process autocode "," char (teletype K)
 272  T#  G#SP  if (B5=0) goto 65 -> set to process x) <- when , used to separate params of func call
                if (B5=1) goto 56 -> set to process y <- when , used to separate params of func call

                process autocode "F" char (teletype I)
 273  Z#  E:YO  B5=1 set switch
 274  L#  SDPO  B6=[SD]=HI// gives address of j data                                       

                process autocode "R" char (teletype L)
 275  W#  E:QO  B7=1
 276  H#  WD/P  goto 256
 277  Y#  HSI/ 
 
                process autocode <CR> char (teletype V)
 278  P#  Y#ZO  B1=HSI/ -> restore B1 stack pointer
 279  Q#  O#/P  goto 23

 280  O#  P///  
 281  B#  R#//  
 282  G#  /@//  
 283  "#  QE//  
 284  M#  TA//  
 285  X#  S///  
 286  V#  CA//  
 287  $#  /@//  
 288  /D  /RUP  
 289  ED  /JUP  
 290  @D  R///  
 291  AD  ////  
 292  :D  VS//  
 293  SD  HI//  
 294  ID  :I//  
 295  UD  RI//  
 296  #D  TI//  
 297  DD  X$$$  
 298  RD  V$$$  
 299  JD  A///  
 300  ND  S///  
 301  FD  I///  
 302  CD  U///  
 303  KD  D///  
 304  TD  ///V  
 305  ZD  GE//  
 306  LD  NA//  
 307  WD  ZU//  
 308  HD  JA//  

                process '='. B7=j switch
 309  YD  ZE/T  if (B>=0) goto 65 -> it is an assignement

                equal operator for conditional jump
 310  PD  S:QO  B7=4 -> nature of inequation = 4 -> '='
 311  QD  /@/P  goto 53

 312  OD  ////  
 313  BD  ////  
 314  GD  K/RN  
 315  "D  K/@N  
 316  MD  $E//  
 317  XD  RE@/  
 318  VD  @EEI  
 319  $D  EE@#  

 320  /R  Z///    
 321  ER  D#//   
 322  @R  ////   
 323  AR  A#//   
 324  :R  ////   
 325  SR  S#//   
 326  IR  ////   
 327  UR  ////   
 328  #R  UA//   
 329  DR  "A//   
 330  RR  ////  
 331  JR  ////  
 332  NR  U#//  
 333  FR  J#//  
 334  CR  ////  
 335  KR  ////  
 336  TR  ////  
 337  ZR  OA//  
 338  LR  E#//  
 339  WR  ////  
 340  HR  DA//  
 341  YR  ////  
 342  PR  YA//  
 343  QR  ////  
 344  OR  EA//  
 345  BR  AA//  
 346  GR  SA//  
 347  "R  W///  
 348  MR  FE//  
 349  XR  ////  
 350  VR  ////  
 351  $R  D///  

                jumptable to process input chars 

                PTR char    Autocode source char
 352  /J  Z///  /           FigShift 
 353  EJ  EE//  E           1 -> goto 34
 354  @J  /E//  @           2 -> goto 33
 355  AJ  YA//  A           *
 356  :J  V///  :           4 -> goto 31
 357  SJ  F#//  S           (
 358  IJ  C#//  I           )
 359  UJ  "///  U           7 -> goto 28
 360  #J  G///  #           8 -> goto 27 
 361  DJ  WE//  D           !=
 362  RJ  ME//  R (autocode =) -> goto 61
 363  JJ  N@//  J           -
 364  NJ  Z@//  N (autocode v) -> goto 82
 365  FJ  D///  F (autocode <LF>) -> goto 10
 366  CJ  D///  C (autocode space) -> goto 10
 367  KJ  K#//  K           ,
 368  TJ  @E//  T           0
 369  ZJ  KE//  Z           > 
 370  LJ  ZE//  L           >=
 371  WJ  $///  W           3 -> goto 32
 372  HJ  X@//  H           j
 373  YJ  X///  Y           5 -> goto 30
 374  PJ  M///  P           6 -> goto 29 
 375  QJ  I@//  Q           /    also can use char %
 376  OJ  :@//  O           (x)
 377  BJ  B///  B           9 -> goto 26
 378  GJ  #@//  G           +
 379  "J  W///  "           Letter Shift
 380  MJ  FE//  M           .
 381  XJ  W@//  X           n
 382  VJ  P///  V (autocode <CR>) -> goto 278 (translate line)
 383  $J  D///  $           erase


B1=-12 init max num of digit in a number
B2=0 -> clears dec.pt.switch 
B3=0 -> clear +- switch 
B4=0 -> clears non-dec switch 
B5=0 -> clear switch. used to diferentiate char '(' handling in func call / in bracket mode
                      used to diferentiate char ',' handling in j sentence / into Fm( ) param list
                 
B6=  -> addr where to store the any number read from source line

B7= c/// -> current PTR read char

[BD]=0 
    =///T -> reading a number
    

[@Q]=///T -> real numbers (Q switch)
    =//// -> complex numbers 


