Scheme/T PERM & the Routine Changing Sequence    Date: 1952
     
    Author: J.N. PATTERSON HUME

    Love Letters - Bodleian Special Collection
    MS. Eng. misc. b. 259-C.34
    p2, p13 

    Toronto University version of Scheme A for FERUT computer
    Only doc on Scheme/T comes from Mathematical Tables and Other Aids to Computation, 
    Vol. 8, No. 45 (Jan., 1954), pp. 30-36 
    (Input and organization of sub-routines for FERUT (jan 1954).pdf)
    

    [Routine PERM/T & RCS/T ]           
                                        
    [Col : S  Track 5L]                 [Col : S  Track 7L]
                                                           
    | //// | / | //// |                 |      | / | //// | Save
    | E/// | E | ///@ |                 |      | E | //// | AM 
    | //// | @ | //// |                 |      | @ | //// | Save B7
    | @/// | A | ///: |                 |      | A |      |     
    | //// | : | //// |                 |      | : |      |     
    | :/// | S | ///# |                 |      | S |      |     
    | //// | I | //// |                 |      | I |      |     
    | #/// | U | ///T |                 |      | U |      |     
    | //// | # | //// |                 |      | # |      |     
    | T/// | D | $$$$ | const -1        |      | D |      |     
    | //// | R | $$$$ |                 |      | R |      |     
    | /E// | J | //// |                 |      | J |      |
    | //// | N | QSQG |                 |      | N | I/@/ |
    | /@// | F | /I/A |                 |      | F | //// |
    | //// | C | $$UJ |                 |      | C | //H/ |
    | /:// | K | E:/M |                 |      | K | S//: |
    | //// | T | XS/: |                 |      | T | KS/: |
    | /#// | Z | A:/O |                 |      | Z | FS/J |     
    | //// | L | @IZZ |                 |      | L | /S/A |     
    | /T// | W | MSZG |                 |      | W | @SQB |
    | //// | H | @IEA |                 |      | H | ESQO |
    | //E/ | Y | /I/J |                 |      | Y | NS/: |
    | //// | P | A:/Q |                 |      | P | //QT |
    | //@/ | Q | X$VO |                 |      | Q | ESQB |
    | //// | O | A:ZG |                 |      | O | /S/J |
    | //:/ | B | AIE: |                 |      | B | @SQO |
    | //// | G | JS/L |                 |      | G | TS/P |
    | //#/ | " | @IEP |                 |      | " |      |
    | //// | M | V$$$ |                 |      | M |      |
    | //T/ | X | U//: |                 |      | X |      |
    | //// | V | //// |                 |      | V |      |
    | ///E | $ | //// |                 |      | $ |      |
                  
    [End]
                         
    The Routine changing sequence is entered
    by instruction G S / P

       ss    ssQO    set B7=ss, its own address
       ss+1  GS/P    enters RCS
       ss+2  nn//    entry for subroutine (will transfer to nn+1)
       ss+3  mag     magnetic instr to read routine into storage
       ss+4  ...     execution will continue here when routine returns

    A subroutine call needs 4 short lines

    B1 index is next free entry in LINK LIST at column /I. 
    Its initial value is //I/. Acts as stack pointer

    N S / P  return from subroutine. 
    
    As [VS] is not used, the routines made for RCS/A can be
    used with RCS/T without modifications (as long as they
    does not calls in turn a subroutine)

    if B7 is set to positive value, e.g by

       ss    /:QO    set B7=////
       ss+1  GS/P    enters RCS
       ss+2  nn//    entry for adroutine (will transfer to nn+1)
       ss+3  mag     magnetic instr to read routine into storage

    then the routine is called as an ad-routine, instead of as a 
    subroutine.
    
    instead of mag (magnetic instr read routine from drum to storage)
    it is possible to use
       
        true line : nn$$  -> nn is address of directory entry for routine.
                             the RCS routine will read dir into S0 and S1, 
                             and get magnetic instruction from dir entry nn. 
                             
        false line: nn//  -> nn is address of directory entry for routine
                             warning char F ss+3 will replace it by magnetic
                             instr from directory entry nn. 

                             F warning char can be viewed as a "linker
                             resolution address" command. It replaces a link
                             with the physical address
                             
    The directory is stored in tracks 6L and 6R
    It is read to S6 S7 by INPUT, and to S0 S1 by RCS.
    
    Each dir entry contains the magnetic instruction that loads
    the routine in storage
              
    LINK LIST 

    /I    save ...
    EI         ... AM

    @I    Return address (ssQO = B7 value on call to RCS)
    AI    mag instr to load routine     

    :I    routine entry point 
    SI    mag instr to load routine

    II    ...
    UI
    

    
S U M M A R Y
    
    Normal uses of pages                                       
    
    Column   Page   Use
    
    /        0      Instructions / INPUT ROUTINE
    E
    
    @        1      Instructions / INPUT ROUTINE
    A
    
    :        2      PERM
    S
    
    I        3      LINK LIST (starts at @I, [/I, EI]=AM)
    U               
    
    #        4      INPUT INFORMATION
    D
    
    R        5      INPUT INFORMATION
    J
    
    N        6      DIRECTORY
    F               
    
    C        7      DIRECTORY
    K               
    


		
Annotated program
Addr = addr into Storage when executing

      =Addr=  Instr Notes
  5L  172 NS  QSQG  RCS Entry point: update B7 (B7=ssQO)
      173 FS  /I/A  Save AM in [/I, EI], start of LINK LIST in column I (in S3 left), clear AM 
      174 CS  $$UJ  load AM using B7 to get RCS call params param
                    AM=nn// magi, where nn// = routine entry point from calling sequence
                                        magi = mag instr to load the routine
      175 KS  E:/M  if (A>=0) goto 177 -> if magi = dd$$ -> load second part of PERM to get mag instr from dir entry dd
      176 TS  XS/:  Read track 7L, second part of PERM, and continue there at addr 177 
      177 ZS  A:/O  if (B>=0) goto 180 -> B>0 if calling adroutine. If so, skip saving B7 (ret addr) and incr B1 (stack pointer)
      178 LS  @IZZ  [@I + B1]=B7 -> save return address in current entry in LINK LIST 
      179 WS  MSZG  B1=B1+2 -> incr B1 to point to next free entry in LINK LIST
      180 HS  @IEA  [@I + B1]=AM -> save routine entry addr + mag instr
      181 YS  /I/J  Restore AM
      182 PS  A:/Q  goto 185
      183 QS  X$VO  const
      184 OS  A:ZG  Ret from subroutine: B1=B1-2
      185 BS  AIE:  read from drum the called routine      
      186 GS  JS/L  Dummy stop /L + const goto 172 RCS entry
      187 "S  @IEP  goto routine entry address from saved addr [@I + B1]
      188 MS  V$$$  const -2
      189 XS  U//:  const: mag instr to read track 7L (the directory) 
      
      Note: this part of PERM is missing. It has been written by Roberto Sancho
            guessing what whould be the behaviour for true lines (as opposition
            on false lines). written in Jan 2023

  7L  172 NS  I/@/  Mag Instr: Read from Track 6L to Tube S0 S1
      173 FS  ////  const: //// //E/ - //// /N// = //// /H//
      174 CS  /H//
      175 KS  S//:  Mag intr to Read PERM from Track 5L to Tube S2   
      176 TS  KS/:  Read back PERM, 
              continue on regular PERM (track 5L)

              Enter from regular PERM (track 5L)
      177 ZS  FS/J  add //E/ to AM to remove $$ and substract /N
      178 LS  /S/A  Save AM in [/S] = nn// dd//
      179 WS  @SQB  Save B7 in [@S]
      180 HS  ESQO  B7=dd//
      181 YS  NS/:  Read Dir into S0 S1
      182 PS  //QT  //QT  B7=[B7] -> B7=mag instr in dir entry 
      183 QS  ESQB  Save B7 in [ES]
      184 OS  /S/J  restore AM, now AM=nn// magi
      185 BS  @SQO  restore B7
      186 GS  TS/P  goto 176
      187 "S  
      188 MS  
      189 XS  
