DataMuseum.dk

Presents historical artifacts from the history of:

RC4000/8000/9000

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RC4000/8000/9000

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦c6ebc0eb1⟧ TextFile

    Length: 168192 (0x29100)
    Types: TextFile
    Names: »tread«

Derivation

└─⟦00964e8f7⟧ Bits:30007478 RC8000 Dump tape fra HCØ.
    └─⟦b2ec5d50f⟧ 
        └─⟦0b92c64d5⟧ »ctb« 
            └─⟦this⟧ 

TextFile

(bread = set 1 disc
bread = slang proc.options
scope user bread
print bread integer words.4 0.6
)

b.  w.
p.1

s0=0,s1=0 ; clear checksums

s. h10 ,q0 w.  ;  h-names used for initialization links...


; rc 21.06.71          reader          read   ...1...

h9 , h10      ; 
78 09 15, 64; version id:
m.          boss 2  tread


; the reader coroutine is activated from some pseudo-job by an
; operation defining input buffer and reading mode.
;
; in both cases the reader waits for a paper tape to be inserted
; in rc 2000 and starts reading in the specified mode.
;
; if boss controlled input is ordered, the input buffer pages
; will be filled untill end of tape is read, and an end medium
; character is added to the character string.  any parity error
; will be converted to one substitute character followed by 0
; to 2 null-characters without further error indication.
;
; if job controlled input is ordered, each buffer page is 
; structured in blocks, each one headed by the first 3 words
; in the input answer. if no errors are detected during reading
; each block will occupy an entire page. if an parity error is
; detected the block length will be decreased in such a way that
; the last word in the block will contain the erroneous character
; as a substitute character  and 0 to 2 null characters.
; if the unused part of the buffer page is greater than 20 words
; a new block is inserted here and so on.
;
;
; the following options define the coroutine
;
; i39   job controlled input buffer on disc/drum (1/0)
; i40   boss controlled input buffer on disc/drum (1/0)
; i41   job  controlled input buffer length (in pages)
; i42   boss controlled input buffer length (in pages)
; i43   coroutine on disc or drum (1 or 0)
;
; the names in the code are used as follows:
; 
; a-names  local labels
; b-names  global variables
; c-names  global labels
; f-names  variables in initialization
; j-names  local variables
;
; the pages are used as follows:
;
; page 0   code and constants
; page 1   variables
; page 2   unused
; page 3   request line or free
; page 4   input buffer or free

; format of operation:
;  op+ 0 : chain
;    + 2 : controller (1 or 2 or 3) (i.e. boss- or job- controlled or special input device)
;    + 4 : answer semaphore
;    + 6 : mode (0, 2, 4 or 6)
;    + 8 : not used
;    +10 : not used
;    +12 : virtual request line address
;    +14 : reader device number
\f


; rc 04.07.71          initialize reader          read   ...2...
s. a20, b50, c10, d50, f35  w.
  
q0:
f24:
k=10000
f25=k-f24
  
 
;  externals in  code:
 
b2., b3., b4., b5., b6., b9., b10., b14., b29., b36., b37.
  
 
;   externals in initialization:
 
f2., f3., f4., f5., f10., f14., f17., f21., f22.
 
h0:  h1                ;    define link for initialization;
     jl.        f30.   ;
 
;  reader variable page:
 
d0  = k      , 0, 0         ;    start  of  variable  page
d1  = k-d0   ,<:readername:>;    process name;
               0            ;    name  table address;
d43 =k-d0,    <:bsfilename:> ; name of discfile, taken from the requestline
 
;  messages:
 
d2  = k-d0   , 3<12+0       ;    input message;
d3  = k-d0   , 0            ;      first,
d4  = k-d0   , 0            ;      last of buffer;
 
d5  = k-d0   , 3<12+4       ;    empty  reader  message;
d6  = k-d0   , 0            ;      first,
d7  = k-d0   , 0            ;      last  of buffer;
 
;  operations:
 
d10 = k-d0   , 0, 4<12      ;    release reader operation;
d11 = k-d0   , 0            ;      answer semaphore;
d42 = k-d0   , 0            ;    reader device no
 
;  semaphores and virtuel adresses:
 
d12 = k-d0   , 0            ;    boss super buffer, first virt;
d13 = k-d0   , 0            ;           -           top virt;
d14 = k-d0   , 0            ;           -           free sem;
d15 = k-d0   , 0            ;           -           full sem;
d16 = k-d0   , 0            ;    job  super buffer, first virt;
d17 = k-d0   , 0            ;           -           top virt;
d18 = k-d0   , 0            ;           -           free  sem;
d19 = k-d0   , 0            ;           -           full sem;
d20 = k-d0   , 0            ;    page count;

d25 = k-d0   , 0            ;    reader operation semaphore;
\f


; lkn 76.10.20                               read   ...3...


 
;  counters:
 
d31 = k-d0   , 0            ;    buffer count;
d32 = k-d0   , 0            ;    rest buffer;
 
;  booleans:
 
d35 = k-d0   , 0            ;    boss or job controlled or special device  (0=boss controlled
                            ;                                               1=job  -
                            ;                                               2=speceial);
d36 = d35+1                 ;    buffer reservation (0=not reserved);
d37 = k-d0   , 0            ;    std  or rb reader (0=std);
 
;    work variables:
 
d40 = k-d0   , 0            ;    work;
d41 = k-d0   , 0            ;    rel answer on buffer page;
 
f1  = k-d0                  ;    length of page 1 (=variable page);
 
 
;  variables for  initialization:
 
; f0                   ;    length of page 0;
; f1                   ;    length of page 1 (variable page);
  f2:     12           ;    reserve  virt;
  f3:     13           ;    move to  virt;
  f4:     14           ;    simulate lock;
  f5:     15           ;    end init;
  f6:  i41<9           ;    job  buffer length in  bytes;
  f7:  i42<9           ;    boss buffer length  in  bytes;
; f8                   ;    rel entry on page 0;
h.f9: 0<3+e86, f8 w.   ;    test mode, rel entry;
  f10:     0           ;    base of externals;
  f11:     0           ;    sense message;
  f12: 0,r.8           ;    answer area;
  f13: 0,r.5           ;    first of corune descr;
; f14                  ;    std reader operation sem;
  f16:     0           ;    corunocount
h.f17: e12*(:e52+e53:),18 w.;addr of coruno descr;
; f18                  ;    reserve area;
  f19: <:readername:>,0;    process name;
  f20:     0           ;    work;
h.f21: (:e13*5+2:)*(:e52+e53:),19 w.; reservation  of semaphores;
  f33:   -1            ;    boolean device 0 = reader (-1 = no    0 = yes);
h.f34:     0 , r.e52 w.;    std reader table (from options);
  
f30: am        (66)    ;
     dl  w1    +74     ;    catalog  base:=
     al. w3     f11.   ;    maxbase(boss);
     jd         1<11+72;
 
     al. w1     f34.   ;    w1:=start of reader  table;
a1:  bl  w2  x1        ;    w2:=device no;
     sn  w2     0      ;    if device no = 0 then
     rs. w2     f33.   ;    device 0 = reader;
\f


; lkn 76.10.20                              read   ...4...

 
     ls  w2     1      ;
     wa  w2     74     ;    w2:=name  table address  of reader;
     rl  w2  x2        ;    w2:=process descr address;
     rs. w1     f20.   ;    save  w1 in work;
     dl  w1  x2+4      ;    move  reader name;
     ds. w1     f19.+2 ;  
     dl  w1  x2+8      ;
     ds. w1     f19.+6 ;
 
     rl. w1     f20.   ;
     al  w1  x1+1      ;    w1:=address of next  reader;
     se. w1     f34.+e52;   if more readers then
     jl.        a1.    ;    continue;
     rl. w0     f33.   ;
     se  w0     0      ;    if device 0 <> reader then
c.-1, o65, z.        ;    (boss fault xref);
     jd        -65     ;    boss fault 65;
 
;  reserve  and move page 0 to virt:
 
     al  w0     i43    ;    w0:=reserve  on disc;
     al  w1     f0     ;    w1:=length of page 0;
     jl. w3    (f2.)   ;    reserve virt;
     rs. w2     f13.+6 ;    page 0:=w2;
     al. w0     b0.    ;    w0:=first  of page  0;
     al  w1     f0     ;    w1:=length of page 0;
     jl. w3    (f3.)   ;    move page 0 to virt;
  
;   set externals:
 
     jl. w3    (2)     ;    set externals;
f22:            40     ;
 
f14: (:2*e13:)<12+19,56;    local reader operation sem;
             0 , -1000 ;    end of externals;
 
;  set and initialize externals on  variable  page:
 
f31: rl. w2     f21.   ;    w2:=current semaphore address;
     rs. w2     d0.+d14;    set  boss reader  free address;
     al  w0     i42    ;
     rs  w0  x2        ;    initialize boss reader  free;
     al  w2  x2+e13    ;
     rs. w2     d0.+d15;    set  boss reader full address;
     al  w2  x2+e13    ;
     rs. w2     d0.+d18;    set job reader free
     al  w0     i41    ;    
     rs  w0  x2        ;    initialize job reader free sem
     al  w2  x2+e13    ;
     rs. w2     d0.+d19;    set job reader full sem
     al  w2  x2+e13    ;
     rs. w2     d0.+d11;    set release reader answer semaphore;
     al  w2  x2+e13    ;
     rs. w2     d0.+d20;    set  page count;
     al  w2  x2+2      ;
     rs. w2     f21.   ;    set  current sem  address;
     rl. w1     f16.   ;    w1:=coruno tÆller;
     rl. w2     f14.   ;    w2:=local reader  operation  sem;
     sl  w1     e52    ;    if  rb reader then
     am         e13    ;    w1 <> 0 else
     al  w1     0      ;
     hs. w1     d0.+d37;    set  boolean (local or rb  reader);
     wa  w2     2      ;    w2:=reader  operation  sem;
     rs. w2     d0.+d25;    set operation sem on variable page;
\f


; lkn 76.10.20                             read   ...5...

 
;  reserve boss contr buffer  and set  virt addresses:
 
     al  w0     i40    ;    w0:=reserve  on  disc;
     al  w1     512    ;    w1:=page  size;
     al  w2     i42    ;    w2:=number of pages;
     jl. w3     f18.   ;    reserve area;
     al  w2  x2+513    ;    w2:=top virt + writing;
     rs. w2     d0.+d13;    set  top virt;
     ws. w2     f7.    ;    w2:=top  virt - length in bytes;
     rs. w2     d0.+d12;    set  first virt;

;  reserve job controlled buffer and set virt addresses

     al  w0     i39    ;    w0:=reserve on disc
     al  w1     512    ;    w1:=length of page
     al  w2     i41    ;    w2:=number of pages
     jl. w3     f18.   ;    reserve area;
     al  w2  x2+513    ;    w2:=top virt + writing
     rs. w2     d0.+d17;    set top virt
     ws. w2     f6.    ;    w2:=top virt-length in bytes
     rs. w2     d0.+d16;    set first virt
 
;  reserve and move variable page to virt;
 
     al  w0     i43    ;    w0:=reserve  on disc;
     al  w1     f1     ;    w1:=length of variable page;
     jl. w3    (f2.)   ;    reserve  virt;
     al  w2  x2+1      ;    w2:=virt  addr + writing;
     rs. w2     f13.+8 ;    page 1 := w2;
     al. w0     d0.    ;    w0:=first of page 1;
     al  w1     f1     ;    w1:=length of page  1;
     jl. w3     (f3.)  ;    move page 1 to virt;
     al  w0     450    ;    w0:=first coroutine number;
     wa. w0     f16.   ;    w0:=actual coroutine number;
     ls  w0     15     ;
     lo. w0     f9.    ;
     rs. w0     f13.+4 ;    set test mode, rel entry in coruno descr;
 
     rl. w2     f17.   ;    w2:=address  of coruno  descr;
     dl. w1     f13.+2 ;    move  coruno  descr;
     ds  w1  x2+2      ;
     dl. w1     f13.+6 ;
     ds  w1  x2+6      ;
     rl. w0     f13.+8 ;
     rs  w0  x2+8      ;
     al  w1  x2        ;    w1:=coruno descr address;
     al  w2  x2+e12    ;    w2;=next coruno  descr;
     rs. w2     f17.   ;    save  next coruno  descr addr;
\f


; lkn 76.10.20                              read   ...6...

 
;  simulate  lock and goto init next or exit init;
 
     rl. w2     d0.+d25;
     jl. w3     (f4.)  ;    simulate lock;
 
     rl. w1     f16.   ;    w1:=coruno tÆller
     al  w1  x1+1      ;        +1;
     rs. w1     f16.   ;    coruno tÆller := w1;
     se  w1     e52+e53;    if coruno tÆller<number of readers 
     jl.        f31.   ;    then continue
     jl. w3    (f5.)   ;    else exit init;
 
;  reserve area
;  w0 = reserve  on  disc
;  w1 = page length
;  w2 = no  of  pages
;  on exit w2 = virt address of last page
 
b. a0, j1, w.
 
f18: rs. w3     j1.    ;    save  return;
     hs. w2     j0.    ;    rest:=no of pages;
a0:  sn  w1  x1+0      ; return: if rest=0  then
     jl.       (j1.)   ;    return;
     bz. w3     j0.    ;
     al  w3  x3-1      ;    rest:=rest-1;
     hs. w3     j0.    ;
     al. w3     a0.    ;    w3:=return;
     jl.       (f2.)   ;    reserve  virt;
j0=a0+1                ;    define rest  address;
j1:             0      ;    saved return;
e.

;  move reader table:

b. a2 w.

a1:  al. w1     e51.+f25-4;   w1:=first of reader table (in options);
     al. w2     f34.   ;    w2:=first of reader table (in init code);
a2:  bl  w0  x1        ;    move byte from table to table;
     hs  w0  x2        ;
     al  w1  x1+1      ;
     al  w2  x2+1      ;
     se. w2     f34.+e52;   if top of table then
     jl.        a2.    ;
     al  w0     0      ;
     al  w2     0      ;    return to slang;
     jl      x3        ;
     jl.        a1.    ;
j.
e.
\f


; lkn 76.10.20                              read   ...7...


  
  
;  start of reader page:
;
;  definition  of b-names:
 
 
b0:             0      ;    page  0:     code and constants
b1:             0      ;    page  1:     variables
                0      ;    page  2:     unused
                0      ;    page  3:     request line or free
                0      ;    page  4:     input buffer or free
         60<12 +0      ;    pageident: tape reader;
 
;  cl entries:
 
b2:             1      ;    send and wait;
b3:             3      ;    lock simple;
b4:             4      ;    open simple;
b5:             5      ;    lock chained;
b6:             6      ;    open  chained;
b9:             9      ;    send and wait slow;
b14:           26      ;    current coroutine;
b37:            7      ;    get pages;
 
;  semaphores:
 
b29:           67      ;    banker queue;
b36:           51      ;    request queue;
 
;  messages:
 
b17:      0<12 +2      ;    sense ready message;
     0,0,0,0,0,0,0                ;    input mode and bsfilename in sense ready message;
b18:            0      ;    timer message
                5      ;    seconds to wait
 
b40:       9<12+1      ;    output  of request line in operator mode;
                0      ;      first,
b41:            0      ;      last of line;
b42:            0      ;    process description address
b43: <:host:>,0,0,0    ;    name of host-process
b44: <:clock:>,0,0,0   ;    name of clock process
 
;  constants:

b20: -1-1<23-1<22-1<17-1<16-1<13-1<12-1<1 ; error bits, give up bits, not normal answer bits
                                   ;    answer
     128<16+25<8                   ;-6  tro
      25<16                        ;-4  tre
       0<16+25<8                   ;-2  trn
b21:  25<16                        ;    end medium character;
b22:            1<21   ;    mask for timer status
b34:            0      ;    zero for set catalog base;
\f


; lkn 76.10.20                              read   ...8...

 
 
;  start  of  reader coroutine:
;
;  wait for operation:
  
b. a10  w.
c0:  al  w0     0      ;
     hs  w0  x3+d36    ;    buffer  reserved:=false;
     rl. w2    (b14.)  ;
     rs  w0  x2+14     ;    page 4 descr:=unused;
     am        (66)    ;
     dl  w1    +74     ;    set cat base (=boss max base);
     al. w3     b34.   ;
     jd         1<11+72;
 
     rl. w3     b0.+2  ;
     bl  w0  x3+d37    ;    w0:=boolean (std  or rb reader);
     al  w3  x3+d1     ;    w3:=process name;
     se  w0     0      ;    if std reader then
     jl.        a10.   ;
     jd         1<11+10;    release process
     jl.        a9.    ;    else
a10: jd         1<11+64;    remove process
a9:
     rl. w3     b0.+2  ;    w3:=abs  page 1;
     rl  w2  x3+d25    ;    w2:=reader op sem;
     jl. w3    (b5.)   ;    lock chained(w2);
f8=k-b0
     rs  w1  x3+d40    ;    save abs ref operation;
     rl  w2  x1+14     ;
     rs  w2  x3+d42    ;    save reader device number
     ls  w2     1      ;
     wa  w2     74     ;    w2:=name table addr of  reader;
     rs  w3  x3+d1+8   ;    destroy nta;
     rl  w2  x2        ;    w2:=process descr address;
     dl  w1  x2+4      ;    move  reader  name;
     ds  w1  x3+d1+2   ;
     dl  w1  x2+8      ;
     ds  w1  x3+d1+6   ;
     al. w3     b34.   ;    w3:=abs ref zero
     am        (66)    ;
     dl  w1    +74     ;    w01:=max base (boss)
     jd         1<11+72;    set cat base
     rl. w3     b1.    ;    w3:=abs page 1
     al  w3  x3+d1     ;
     jd         1<11+8 ;    reserve reader
     al  w3  x3-d1     ;
     rl  w1  x3+d40    ;    w1:=abs ref operation;
b10=k+1
     al  w2  x1+173    ;    w2:=abs reader table (on job descr page);
     rl  w0  x3+d20    ;    move reader  table to  job descr  page of psjob
     rs  w0  x2+2      ;
     bz  w0  x1+3      ;    w0:=boolean boss- or jobcontrolled
     se  w0     1      ;    if w0<>1 then move job controlled references 
     al  w3  x3+8      ;    else boss controlled references
     dl  w1  x3+d13    ;
     ds  w1  x2+8      ;
     dl  w1  x3+d15    ;
     ds  w1  x2+12     ;
     rl. w3     b1.    ;    w3:=abs ref page 1
 
     rl  w1  x3+d40    ;    w1:=abs ref  operation;
     bl  w0  x1+7      ;    insert mode in
     hs  w0  x3+d2+1   ;      input operation;
     rl  w0  x1+12     ;
     rl. w2    (b14.)  ;
     rs  w0  x2+12     ;    page 3:=virt request line;
     bz  w2  x1+3      ;
     al  w2  x2-1      ;
     hs  w2  x3+d35    ;    set boolean (boss or job controlled);
     sn  w2     0      ;    if job controlled then
     jl.        a5.    ;    begin
     al  w0     i41    ;
     rs  w0 (x3+d14)   ;      free superbufs := max (=i41)
     al  w0     0      ;
     rs  w0 (x3+d15)   ;      full bufs := 0
     am         d17-d13;      w2:=top virt job contr
a5:                    ;    end else
     rl  w2  x3+d13    ;    w2:=top virt boss controlled
     al  w0  x2-512    ;    w0:=start of virt buffer;
     rl. w3    (b14.)  ;
     rs  w0  x3+14     ;    page 4:=first of virt buffer;
     rl  w2  x1+4      ;    w2:=address of answer sem;
     jl. w3    (b4.)   ;    open(w2);
     jl. w3    (b37.)  ;    get pages;
     rl. w2     b0.+6  ;
     dl  w1  x3+d1+2   ;    move reader process name to request line
     ds  w1  x2+20     ;
     dl  w1  x3+d1+6   ;
     al  w1  x1+32     ;    insert a space as the last character
     ds  w1  x2+24     ;
     bl  w1  x3+d35    ;    if special device
     sn  w1     2      ;    then
     jl.        a2.    ;    skip <empty reader>

     am        (66)    ;
     dl  w1    +74     ;    set cat base (max base)
     al. w3     b34.   ;    w3:=ref zero
     jd         1<11+72;
     rl. w3     b1.    ;    w3:=ref page 1
\f


; lkn 76.10.20                              read   ...9...

  
 
a1:  al  w1  x3+d5     ; empty reader:  w1:=input message;
     rl. w2     b0.+8  ;      first,
     rs  w2  x3+d6     ;      first,
     al  w2  x2+510    ;
     rs  w2  x3+d7     ;      last of buffer;
     al  w2  x3+d1     ;    w2:=reader name;
     jl. w3    (b9.)   ;    send and wait (w1,w2);
 
     sz. w0    (b20.)  ;    if normal answer
     jl.        4      ;    not end of medium  then
     jl.        a1.    ;    goto empty reader;
 
     bl  w0  x3+d37    ;    if rb reader then 
     sn  w0     0      ;    begin
     jl.        a2.    ;
     rl. w1     b0.+6  ;      w1:=request line address;
     al  w2  x3            ;    w2=x3(page1)
     dl  w0  x1+48         ;
     ds  w0  x2+d43+2      ;    move bsfilename
     dl  w0  x1+52         ;    from requesline to readerpage
     ds  w0  x2+d43+6      ;
     al  w3  x2            ;    w3=x2 (page1)
     al  w1  x1+6      ;      w1:=first  of line;
     al  w2  x1        ;      w2:=first  of line+new line
     wa  w2  x1-2      ;      + length of line;
     ds. w2     b41.   ;      saved first, last in message;
     al  w3  x3+d1     ;    w3:=process name
     jd         1<11+4 ;    get process description address
     rs. w0     b42.   ;    set process description address in operator output message
     al. w1     b40.   ;      w1:=ref message;
     al. w2     b43.   ;    w2:=address(<:host:>)
     jl. w3    (b9.)   ;      send and wait slow;
a2:                    ;    end;
     rl. w1     b0.+6  ; send <load reader>: w1:=request line
     rl. w2     b36.   ;    w2:=request queue
     jl. w3    (b6.)   ;    open chained(w1,w2);

     al  w0     0      ;    release page  3;
     rl. w1    (b14.)  ;
     rs  w0  x1+12     ;
     am        (66)    ;    cat  base:=max interval;
     dl  w1    +74     ;
     al. w3     b34.   ;
     jd         1<11+72;
     rl. w3     b0.+2  ;
     al  w3  x3+d1     ;    initialize reader;
     jd         1<11+6 ;
     al  w3  x3-d1     ;    reestablish w3 (=page 1);
     jl.        c7.    ;
e.
 
 
;  wait for paper tape
;
;  a sense ready message is sent and waited for
;  exit is  made to the init sequenses
 
b .  a0  w.
c1:  al. w2     b44.   ;    w2:=name of process
     al. w1     b18.   ;    w1:=timer message
     jl. w3    (b2.)   ;    send and wait

c7:  dl  w1  x3+d43+2      ;
     ds. w1     b17.+6     ;    move bsfilename
     dl  w1  x3+d43+6      ;    from readerpage to sense message
     ds. w1     b17.+10    ;
 
     al. w1     b17.   ;    w1:=sense ready  message;
     bl  w2  x3+d2+1   ;    w2:=input mode;
     hs  w2  x1+3      ;    set input mode in sense ready message;
     al  w2  x3+d1     ;    w2:=reader name;
     jl. w3    (b2.)   ;    send and wait (w1,w2);
     sz. w0    (b22.)  ;    if timer status then
     jl.        c1.    ;    goto wait for papertape
     bl  w1  x3+d35    ;
     se  w1     0      ;    if job contr input then
     jl.        c4.    ;    goto init job controlled;
e.
\f


; lkn 76.10.20                              read   ...10...

 
;  init boss controlled input
;  check tape in reader,  init buffer
 
     al  w1  x3+d40    ;    w1:=
     al  w2  x1        ;    w2:=addr of work;
     ds  w2  x3+d4     ;    save buffer  limits;
     al  w1  x3+d2     ;    w1:=addr  of input message;
     al  w2  x3+d1     ;    w2:=addr of name;
     jl. w3    (b9.)   ;    send and wait slow (w1,w2);
 
     rl  w2  x1+2      ;
     sz  w0     1<1    ;    if normal answer
     se  w2     0      ;    and no of bytes = 0 then
     jl.        4      ;
     jl.        c1.    ;    goto wait for papertape;
     al  w2     510    ;    rest buffer;
     so  w0     1<1    ;    if not normal answer then
     al  w2     512    ;    rest buffer:=512;
     rs  w2  x3+d32    ;
     al  w0     1      ;    
     rs  w0  x3+d31    ;    buffer count:=1;
     al  w0    -1      ;    
     rs  w0 (x3+d20)   ;    page count:=-1;
 
     rl  w0  x3+d12    ;
     rl. w2    (b14.)  ;
     rs  w0  x2+14     ;    page 4 descr:=first of buffer;
     rl  w2  x3+d14    ;    w2:=reader free;
     jl. w3    (b3.)   ;    lock(w2);
 
     rl  w0  x3+d40    ;
     rl. w2     b0.+8  ;
     rs  w0  x2        ;    buffer(0):=work;
     rl  w0  x3+d32    ;
     sn  w0     512    ;    if rest buffer=512 (=not normal answer) then
     jl.        c3.    ;    then goto end boss controlled;
 
 
;  read boss controlled
;
;  cycle: read  rest of buffer
;         get new buffer and  repeat
 
b. a0 w.
 
c2:  rl. w2     b0.+8  ;  
     al  w2  x2+510    ;    w2:=last of buffer;
     al  w1  x2+2      ;    w1:=top of buffer
     ws  w1  x3+d32    ;    - rest buffer;
     ds  w2  x3+d4     ;    save buffer  limits;
     al  w1  x3+d2     ;    w1:=input message  address;
     al  w2  x3+d1     ;    w2:=reader name address;
     jl. w3    (b9.)   ;    send and wait slow;
     rl  w2  x1+2      ;    w2:=no of bytes;
     so  w0     1<1    ;    if not normal answer then
     al  w2     0      ;    w2:=0;
     rs  w2  x3+d40    ;    work:=w0;
     rl  w1  x3+d32    ;    rest  buffer:=
     ws  w1     4      ;    rest buffer-
     rs  w1  x3+d32    ;    no of bytes;
     sn  w1     0      ;    if rest buffer=0 then
     jl.        a0.    ;    goto get next;
     se  w2     0      ;    if bytes transferred <> 0 then
     jl.        c2.    ;    continue
     sz. w0    (b20.)  ;    if end medium or abnormal answer then
     jl.        c3.    ;    goto end boss controlled 
     jl.        c2.    ;    goto read boss controlled;
     jl.        c3.    ;    else goto end boss controlled
\f


; lkn 76.10.20                              read   ...11...

 
a0:  rl  w2  x3+d15    ; get next: w2:=reader full sem addr;
     jl. w3    (b4.)   ;    open(w2);
     rl  w2  x3+d31    ;
     al  w2  x2+1      ;    buffer count:=buffer count+1;
     rs  w2  x3+d31    ;
     rl. w2    (b14.)  ;
     rl  w1  x2+14     ;    w1:=virt addr of buffer
     al  w1  x1+512    ;    + 512;
     sl  w1 (x3+d13)   ;    if w1>=top virt then
     rl  w1  x3+d12    ;    w1:=first virt;
     rs  w1  x2+14     ;    page 4 descr:=w1;
     al  w0     512    ;
     rs  w0  x3+d32    ;    rest buffer := 512;
     rl  w2  x3+d14    ;    w2:=reader free sem;
     jl. w3    (b3.)   ;    lock(w2);
     rl  w0  x3+d40    ;    w0:=no of bytes;
     se  w0     0      ;    if w0<>0 then
     jl.        c2.    ;    goto read  boss controlled;
e.
  
;  end boss controlled
;
;  insert end medium character as last part  of the  buffer
;  releaser the buffer and goto start readercoroutine
 
c3:  rl. w2     b0.+8  ;
     al  w2  x2+512    ;    w2:=top of buffer
     ws  w2  x3+d32    ;    - rest buffer;
     bl  w1  x3+d2+1   ;    w1:=mode(input message);
     sl  w1     7      ;    if  mode not std then
     al  w1     6      ;      mode:=trf (i.e. em=25);
     rl. w0  x1+b21.-6 ;
     rs  w0  x2        ;    word(x2):=endword(mode);
     rl  w0  x3+d31    ;    page count:=
     rs  w0 (x3+d20)   ;    buffer count;
     rl  w2  x3+d15    ;    w2:=reader full sem addr;
     jl. w3    (b4.)   ;    open(w2);
     jl.        c0.    ;    goto start  reader;
\f


; lkn 76.10.20                              read   ...12...


; sense ready
;
; job controlled input stream has become empty, so wait for next portion of data by
; repeatedly sending sense ready until status = ok

c8:  al. w1     b17.   ;  sense ready: w1:=message address;
     bl  w2  x3+d2+1   ;
     hs  w2  x1+3      ;    set input mode in sense ready message
     al  w2  x3+d1     ;    w2:=device name
     jl. w3    (b2.)   ;    send and wait
     sz. w0    (b22.)  ;    if timer status then
     jl.        c8.    ;    goto sense ready


;  init job controlled input
;
;  reserve buffer, read  tape
;  if  not present then goto wait for paper tape
;  goto read boss controlled
 
b. a0  w.
 
c4:  bz  w1  x3+d36    ;
     se  w1     0      ;    if buffer reserved then
     jl.        a0.    ;    goto input;
     al  w0     1      ;    
     hs  w0  x3+d36    ;    buffer  reserved:=true;
     rl  w2  x3+d16    ;    w2:=virt first of job contr buffer;
     rl. w1    (b14.)  ;
     rs  w2  x1+14     ;    page  4:=w2;
     rl  w2  x3+d18    ;    w2:=reader  free sem;
     jl. w3     (b3.)  ;     lock(w2);
 
a0:  rl. w1     b0.+8  ; input:
     al  w2  x1+508    ;    w2:=last of buffer;
     al  w1  x1+6      ;    w1:=first of buffer;
     ds  w2  x3+d4     ;    save  buffer limits;
     al  w1  x3+d2     ;    w1:=input message;
     al  w2  x3+d1     ;    w2:=reader name;
     jl. w3    (b9.)   ;    send and  wait slow(w1,w2);
 
     dl  w2  x1+4      ;    w1,w2:=no of bytes,characters;
     so  w0     1<1    ;    if not normal answer then
     ld  w2    -100    ;    w1,w2:=0,0;
     sz  w0     1<1    ;    if normal answer
     se  w1     0      ;    and no of bytes=0 then
     jl.        4      ;
     jl.        c8.    ;    goto sense ready;
     am.       (b0.+8) ;
     ds  w2    +4      ;    save w1,w2 in buffer;
     rl. w2     b0.+8  ;
     rs  w0  x2        ;    save status;
     ac  w1  x1-504    ;
     rs  w1  x3+d32    ;    rest  buffer:=504-no of bytes;
     al  w1     0      ;
     rs  w1  x3+d41    ;    rel:=0;
e.
\f


; lkn 76.10.20                              read   ...12a...

 
 
;  read job  controlled
;
;  cycle: check input operation - maybe repeat reading
;         prepare new buffer and read
;  entry with: w0 = logical status, w2 = page  4, w3 = page 1
 
b.  a1  w.
  
a1:  sz. w0    (b20.)  ;    if end document or result<>1 then
     jl.        c6.    ;    goto end job  controlled;
     rl  w1  x3+d32    ;    w1:=rest buffer;
     sl  w1     40     ;    if rest  buffer>39 then
     jl.        a0.    ;    goto read;
     al  w0    -1      ;
     ws  w2     2      ;    w2:=top of buffer-rest buffer -2;
     rs  w0  x2+510    ;    word(x2):=-1;
     rl  w2  x3+d19    ;    w2:=reader full  sem;
     jl. w3    (b4.)   ;    open(w2);
 
c5:  rl. w2    (b14.)  ;    start job controlled;
     rl  w1  x2+14     ;    w1:=virt page 4
     al  w1  x1+512    ;    + 512;
     se  w1     512    ;
     sl  w1 (x3+d17)   ;    if w1>=top or page  4 is unused
     rl  w1  x3+d16    ;    then w1:=first virt;
     rs  w1  x2+14     ;    page 4:=w1;
     al  w0     510    ;
     rs  w0  x3+d32    ;    rest buffer:=510;
     rl  w2  x3+d18    ;    w2:=reader free sem addr;
     jl. w3    (b3.)   ;    lock(w2);
                       ; input:
a0:  rl. w2     b0.+8  ;
     al  w2  x2+508    ;    w2:=last of buffer;
     al  w1  x2+8      ;    w1:=w2+8
     ws  w1  x3+d32    ;    - rest buffer;
     ds  w2  x3+d4     ;    save  buffer  limits;
     al  w1  x1-6      ;    rel:=first-6
     ws. w1     b0.+8  ;    - page  4 addr;
     rs  w1  x3+d41    ;
     al  w1  x3+d2     ;    w1:=input message addr;
     al  w2  x3+d1     ;    w2:=reader name addr;
     jl. w3    (b9.)   ;    send and  wait slow(w1,w2);
     dl  w2  x1+4      ;    w1,w2:=number of bytes,characters;
     sz. w0    (b20.)  ;    if normal answer and
     jl.        a2.    ;    status = 0
     se  w1     0      ;    bytes transferred=0 then
     jl.        a3.    ;
     al  w0    -2      ; change buffer:
     rl  w1  x3+d32    ;    w1:=rest buffer
     rl. w2     b0.+8  ;    w2:=page 4 address
     ws  w2     2      ;    w2:=top buffer - rest buffer - 2
     rs  w0  x2+510    ;    word(x2):=-1;
     rl  w2  x3+d19    ;    w2:=reader full sem
     jl. w3    (b4.)   ;    open(w2)
     rl. w2    (b14.)  ;    w2:=current coruno
     rl  w1  x2+14     ;    w1:=virt page 4
     al  w1  x1+512    ;    + 512
     se  w1     512    ;
     sl  w1 (x3+d17)   ;    if w1>=top or page 4 is unused
     rl  w1  x3+d16    ;    then w1:=first virt
     rs  w1  x2+14     ;    page 4 :=w1
     al  w0     510    ;    rest buffer := 510
     rl  w2  x3+d18    ;    w2:=reader free sem
     jl. w3    (b3.)   ;    lock (reader free sem)
     jl.        c8.    ;    goto sense ready
\f


; lkn 76.10.20                              read   ...12b...
a2:  so  w0     1<1    ;    if not normal answer then


     ld  w2    -100    ;    bytes,characters := 0,0
a3:  rl  w3  x3+d41    ;
     wa. w3     b0.+8  ;    w3:=saved answer addr;
     ds  w2  x3+4      ;    save answer;
     rs  w0  x3        ;    save logical status;
     rl. w3     b0.+2  ;
     ac  w1  x1+6      ;    w1:=-no of bytes-6
     wa  w1  x3+d32    ;    + rest buffer;
     rs  w1  x3+d32    ;    set rest buffer
     rl. w2     b0.+8  ;    w2:=page 4 addr;
     jl.        a1.    ;    goto read  job controlled;
e.
  
;  end job  controlled  input
; 
;  release buffer and reader
;  goto start reader
 
c6:  al  w0    -1      ;
     ws  w2     2      ;    w2:=top of buffer - rest buffer  -  2;
     rs  w0  x2+510    ;    word(x2):=-1;
     rl  w2  x3+d19    ;    w2:=reader full sem addr;
     jl. w3    (b4.)   ;    open(w2);
     al  w1  x3+d10    ;    w1:=release reader  op addr;
     rl. w2     b29.   ;    w2:=banker queue sem;
     jl. w3    (b6.)   ;    open chained(w1,w2);
     rl  w2  x3+d11    ;    w2:=answer sem addr;
     jl. w3    (b3.)   ;    lock(w2);
     jl.        c0.    ;    goto start  reader;
 
f0 = k-b0              ;    define length of page  0;
h1 = h0.               ;    define link for initialization;
i.
 
e.
\f



; rc 02.07.71          card reader          read   ...13...

; general description
; *******************
;
; the card reader coroutine transfers card pictures from the card
; reader to some super buffer in the following cycle:
;
;       rep:  lock (cards free)
;             fill segment with card pictures
;             open (cards full)
;             goto rep
;
; the cards to be read must be structured in job decks in the following
; way:
;    <job deck>     ::= <job file> <datafiles> <end of job card>
;    <job file>     ::= <ebcdic cards defining the job>
;    <data files>   ::= <empty> ! <data file> <data files>
;    <data file>    ::= <end of file card> <data cards>
;
; the end cards must contain the following text (terminated by
; blanks) in the first 21 coloumns:
;
;    ---file
;    ---job
;
; when an end of job card is read, and the cardreader is not emptied,
; a new pseudo job will be activated.  this pseudo job will then acti-
; vate the card reader once for each file untill the end of job is met.
; in each activation, the card reader will get information about
; reading mode and packing mode.
;
; if the packing mode specifies boss controlled input, each segment
; in the super buffer will be filled up with cards and terminated by
; null characters.
;
; if the packing mode specifies job controlled input, each segment
; will be structured in blocks, each one headed by 4 words containing
; the first part of the answer on the input message.
; usually a block will fill a whole segment (but allways an integral
; number of cards) but in case of reading error, end of deck etc  a
; segment may contain several blocks.
;
; the end of file and end of job information is transferred to the
; pseudo job in two different ways depending on the packing mode.
;
; in job controlled input the status (first word of each block)
; contains status bits defining the end conditions.
;
; in boss controlled input two counters will signal end in the
; following way:
; the pseudo job has two local counters, counting segments in the 
; super buffer and files in the job.  when the value of such a
; counter matches a corresponding global counter, the end condition
; is fullfilled

\f


; rc 02.07.71          card reader          read   ...14...

; use of logical status bits
; **********************************
;
; bit
;  no  from monitor       in boss         to pseudo job
;
;   0  local              local           --0--
;   1  conversion error   --0--           conversion error
;   2  timer              timer           --0--
;
;   3  data overrun       data overrun    --0--
;   4  --0--              --0--           --0--
;   5  end of deck        end of deck     end boss file/job
;
;   6  tray full          tray full       --0--
;   7  end card read      end card read   end card read
;   8  --0--/eoj from rb  eoj             --0--
;
;   9  --0--              --0--           --0--
;  10  reading error      --0--           reading error
;  11  card rejected      --0--           card rejected
;
;  12  --0--              --0--           --0--
;  13  --0--              --0--           --0--
;  14  --0--              --0--           --0--
;
;  15  --0--              --0--           --0--
;  16  --0--              --0--           --0--
;  17  --0--              --0--           --0--
;
;  18  --0--              unknown         --0--
;  19  --0--              malfunction     --0--
;  20  --0--              unintelligible  --0--
;
;  21  --0--              rejected        end boss job
;  22  --0--              normal answer   --0--
;  23  --0--              mode error      --0--
;
; not mentioned bits are allways 0.
; bit 21 will be removed by the pseudo job before the status
; is transferred to the job.
;
;
; internal structure
; ******************
;
; index in most tables is  card type  which contains the
; following bits from reading mode:
;
; bit    contents
;  20    decimal conversion (in hardware)
;  21    51 coloumns cards
;  22    ebcdic conversion (in monitor)
;
; value  conversion  coloumns   bytes/card
;
;   0    binary         80        80
;   2    -not used-     --        --
;   4    binary         51        52
;   6    -not used-     --        --
;   8    decimal        80        54
;  10    ebcdic         80        54
;  12    decimal        51        34
;  14    ebcdic         51        36

\f


; rc 02.07.71          card reader          read   ...15...

; the names are used as follows
;
;   a-names   local labels
;   b-names   global variables
;   c-names   global labels
;   e-names   system lengths
;   f-names   variables in initialization
;   g-names   tables, texts and operations
;   i-names   options
;   j-names   local variables
;
;
; the following options define the coroutine:
;
;   i50  job  controlled input buffer on drum/disc (o/1)
;   i51  boss controlled input buffer on drum/disc (o/1)
;   i52  job  controlled input buffer    no of pages
;   i53  boss controlled input buffer    no of pages
;   i54  coroutine on drum/disc (o/1)

s. b200, c40, d50, f60, g20 w.

;externals on card reader page
b7., b8., b9., b10., b15., b16., b17., b18., b19., b20., b21.
b22., b30., b31., b33.

;externals on start page
b115., b117., b118., b119., b122., b123., b124., b125., b126., b130., b131., b132., b133., b134., b135.
c.i93-1, b150. z., b151.,  b155.,b156.,b157.,b128.,b129.

;externals in initialization
f9., f10., f11., f12., f13., f20., f21., f22.

h2:h3 ; define link for initialization

     jl.         c0.   ;    goto start init

; format of operation:
;  op+ 0 : chain
;    + 2 : controller (1 or 2) (i.e. boss- or job- controlled)
;    + 4 : answer semaphore
;    + 6 : mode 
;    + 8 : not used
;    +10 : virtual global file count (undefined if job-controlled)
;          (global block count follows immediately after global file count)
;    +12 : not used
;    +14 : not used
;
; format of answer:
;  op+ 2 : result: 0 - answer ok
;               <> 0 - mode error
;    + 6 : card length (in bytes)

\f


; btj 20.7.74        card reader variables       read   ...16...


; card variables page. one page for each incarnation

f0:                    ;    start of card page
k=0                    ;
     0,0               ;    (return point, used by call)
d1:  0,r.4             ;    process name (individually for each incar.)
     0                 ; +8   (name table address)
d2:  0,0               ;    local device name for jobfile (zero for std card)
     0                 ; +4 (termination of name)
d3:  0                 ;    std mode for jobfile          (undef -    -   - )
d4:  0,0               ;    current local device name     (  -   -    -   - )
d5:  0                 ;    device number as text
d6:  3<12              ;    input message (+current input mode)
     0,0               ; +2,+4 first,last
d7:  0                 ;    boss status (status of last input)
d8:  0                 ;    bufrel
d9:  0                 ;    controller (0=boss, 8=job)
d10: 0                 ;    actual cardsize (used to see, if
                       ;      there is room enough left in buffer for
                       ;      another card)
d11: 0                 ;    card type (undef for rb card)
d12: 0                 ;    local block count
d13: 0                 ;    local file count
d14: 0                 ;    index in cardreader table
d15: 0                 ;    old bufrel  (used temporarily by >lock whole superbuffer<)
d16: 0                 ;    cardreader type:
                       ;      -1 = old std cardreader (i.e. connected directly tothe rc4000)
                       ;      0 = std cardreader (i.e. connected directly to the front-end)
                       ;      1 = remote cardreader (i.e. connected via a remote batch
                       ;             station which accepts lookup messages)
                       ;      cardreaders of type -1 and 0 are counted in i93
                       ;      cardreaders of type 1 are counted in i200

d20: 0,1,0             ;    remove request line operation
d21: 0                 ; +6    virt request line addr (=0 when released)
d22:  9<12+1           ;    output message (+output mode)
     0,0,0             ; +2,+4,+6 first, last, proc.descr.address

d26: 0                 ;    virt psjob operation addr (=0 when answer send)

d30: 0                 ; banker operation: (chain)
     13<12             ; +2    opcode=cardjob ready
d31: 0                 ; +4    answer sem
d32: 0                 ; +6    rb parent device name table addr (=0 for std card)
d33: 0                 ; +6+2   -   -      -    creation number ( undef for std card)
d34: 0                 ; +10   terminal ident of starting rb terminal
                       ;         (two chars, left justified)
d35: 0                 ; +12   card reader queue
d36: 0                 ; +14   boss super buffer: first virt
d37: 0                 ; +16     -    -      -  : top
d38: 0                 ; +18     -    -      -  : free sem
d39: 0                 ; +20     -    -      -  : full  -
d40: 0                 ; +22   job    -      -  : first virt
d41: 0                 ; +24    -     -      -  : top    -
d42: 0                 ; +26    -     -      -  : free sem
d43: 0                 ; +28    -     -      -  : full  -
d44: 0,0               ; +30,+32 rb printername

d50: 0                 ;    current virt addr of input buffer
f1:                    ;    (length of card variable page
\f


; btj 20.7.74       card reader init              read   ...17...

k=k+f0                 ;

; variables used in initialization

;f0                    ;    start of card variables
;f1                    ;    length -  -       -
;f2                    ;    start of card reader page
;f3                    ;    length -  -     -     -
;f4                    ;    start of start page
;f5                    ;    length -   -    -

f10: 0                 ;    base of externals
f11: 12                ;    reserve virt
f12: 13                ;    move to virt
f13: 24                ;    put in active queue
     h.
f20: (:i93+i200:)*e12,18;    coroutine descriptions
f21: 7*(:i93+i200:)*e13,19;  semafores
                       ;    each incarnation gets:
                       ;       answer semaphore
                       ;       card queue
                       ;       boss buffer free sem
                       ;        -     -    full  -
                       ;       job buffer free   -
                       ;        -     -    full  -
                       ;       wait semaphore
     w.
f30: 0                 ;    virt of card reader page
;f31                   ; rel entry: start std card readers
;f32                   ;  -    -      -   rb    -     -

;f36                   ; rel entry: commandio start command
;f37                   ;  -    -    wait start
;f38                   ;  -    -    release and wait

f40: 0                 ;    incarnation count
f41: 0                 ;    index in cardreader table
f42: 1<15              ;    increment in coroutine ident
f43: 10                ;    decimal radix
     h.
f45: 400<3+e85,f31     ;    ident, testmode, entry for std card reader
f46: (:400+i93:)<3+e98,f32;   -       -        -    -  rb   -      -
     w.

f50: 0                 ;    sense message (and for set catbase)
f51: 0,r.8             ;    answer area/saved return (reserve area)
f52: i53*512           ;    boss buffer length in bytes
f53: i52*512           ;    job    -      -    -    -
f60: h.
     c.i93-1
     0, r.i93          ;    list of std card reader device numbers
     z.
     w.
\f


; btj 20.7.74        card reader  init              read   ...18...


; reserve card reader code page and move to virt
b. a10 w.
c0:
c. i93 + i200 - 1
     al  w0     i54    ;    w0:= card code on disc
     al  w1     f3     ;    w1:= length of card reader page;
     jl. w3    (f11.)  ;    reserve virt(w0,w1,w2);
     rs. w2     f30.   ;    save virt addr;

     al. w0     f2.    ;    w0:= start of card reader page;
     jl. w3    (f12.)  ;    move to virt(w0,w1,w2);
z.

; repeat for each incarnation

a0:  rl. w2     f40.   ; next incarnation:
     al  w2  x2+1      ;
     rs. w2     f40.   ;    increase(incarnation count);
     sl  w2     i93+i200+1;   if incarnation count >= incarnations then
     jl.        a6.    ;      goto reserve start page;

; reserve and initialize std cardreader

     sl  w2     i93+1  ;    if incarnation no <= std card reader then
     jl.        a1.    ;      begin
     am        (66)    ;
     dl  w1    +74     ;      set catbase (boss maxbase)
     al. w3     f50.   ;
     jd         1<11+72;

     al. w3     f0.+d1 ;      w3:= ref dev name;
     bl. w2  x2+f60.-1 ;      w2:=device number;
c.i93-2                ;      if more than one std card reader then include:
     al  w0     0      ;
     al  w1  x2        ;      convert dev no to text;
     wd. w1     f43.   ;
     se  w1     0      ;
     al  w1  x1+48     ;
     ls  w1     8      ;
     wa  w1     0      ;
     al  w1  x1+48     ;
     ls  w1     8      ;
     al  w1  x1+32     ;
     rs. w1     f0.+d5 ;      save in card variables;
z.
     ls  w2     1      ;
     wa  w2     74     ;      w2:=n t a;
     rs  w2  x3+8      ;      save after name
     rl  w2  x2        ;      w2:=ref process description;
     dl  w1  x2+4      ;
     ds  w1  x3+2      ;
     dl  w1  x2+8      ;      move name to card variables;
     ds  w1  x3+6      ;
     jd         1<11+8 ;      reserve process;
     al. w1     f50.   ;
     jd         1<11+16;      send and wait(cardreader,sense)
     al. w1     f51.   ;        in order to set name table addr;
     jd         1<11+18; 

; initialize boss status

     al  w1     1      ;
     ls  w1    (0)     ;      w1:= logical status;
     sn  w1     1<1    ;
     lo. w1     f51.   ;
     la. w1     b55.   ;      extract boss bits;
     lo. w1     b61.   ;      include enddeck, eofcard, end job card
     rs. w1     f0.+d7 ;      set in card variables;
     rl. w1     f0.+d1+8;     w1:=nta of device;
     rl  w0 (x1)       ;      w0:=kind;
;***nb: dangerous constant in case of monitor kind changes
     sn  w0     16     ;      if kind= old std cardreader 
     am        -1      ;        then type := old std
     am         0-1    ;        else type := std
a1:  al  w0     1      ;      end else type := remote;
     rs. w0     f0.+d16;    set type in card variables;
\f


; btj 20.7.74         card reader init          read   ...19...


; initialize semafores on card variable page

     rl. w2     f21.   ;    w2:= current sem addr;
     al. w3     f0.    ;    w3:= card variable page;

     rs  w2  x3+d20+4  ;    remove line answer sem:=
     rs  w2  x3+d31    ;    banker operation answer sem := w2(=answer sem);
     al  w2  x2+e13    ;
     rs  w2  x3+d35    ;    card queue
     al  w2  x2+e13    ;
     rs  w2  x3+d38    ;    boss buffer free
     al  w2  x2+e13    ;
     rs  w2  x3+d39    ;      -    -    full
     al  w2  x2+e13    ;
     rs  w2  x3+d42    ;    job buffer free
     al  w2  x2+e13    ;     -    -    full
     rs  w2  x3+d43    ;
     al  w2  x2+e13    ;

; initialize entry in cardreader table

     rl. w1     f41.   ;    save device table index
     rs  w1  x3+d14    ;      in card variables
     al  w0  x1+b99    ;
     rs. w0     f41.   ;    index:= index + entry length;
     al. w1  x1+b160.  ;    w1:= abs table entry;
     rs  w2  x1+b98    ;    save wait sem in entry
     al  w2  x2+e13    ;
     rs. w2     f21.   ;
     rl. w2     f40.   ;    if std card reader then
     bl. w0  x2+f60.   ;      set dev no in entry;
     sh  w2     i93    ;
     hs  w0  x1+b97    ;
a4:                    ;
\f


; btj  20.7.74        card reader init              read   ...20...


; reserve boss input buffer

     al  w0     i51    ;    w0:= boss buffer on disc;
     al  w1     512    ;    w1:= page size;
     al  w2     i53    ;    w2:= no of pages;
     rs. w2    (f0.+d38);   cards free value:= no of pages;
     jl. w3     a9.    ;    reserve area(w0,w1,w2);
     al  w2  x2+513    ;    w2:= top virt + writing;
     rs. w2     f0.+d37;    save top virt;
     ws. w2     f52.   ;    first virt:= top virt
     rs. w2     f0.+d36;        - buffer length;

; reserve job input buffer

     al  w0     i50    ;    w0:= job buffer on disc;
     al  w1     512    ;    w1:= page size;
     al  w2     i52    ;    w2:= no of pages;
     rs. w2    (f0.+d42);   cards free value:= no of pages;
     jl. w3     a9.    ;    reserve area(w0,w1,w2);
     al  w2  x2+513    ;    w2:= top virt + writing;
     rs. w2     f0.+d41;    save top virt;
     ws. w2     f53.   ;    first virt:= top virt
     rs. w2     f0.+d40;        - buffer length;

; reserve card variables and move to virtual store

     al  w0     i202   ;    w0:= card variables on disc;
     al  w1     f1     ;    w1:= length of card variables;
     jl. w3    (f11.)  ;    reserve virt;
     al  w2  x2+1      ;    insert writing
     al. w0     f0.    ;    w0:= start of card variables;
     jl. w3    (f12.)  ;    move to virt(w0,w1,w2);
; w2 = virt card variable

; initialize coroutine description

     rl. w3     f20.   ;    w3:= current coroutine addr;
     rl. w1     f30.   ;    w1:= virt card reader code page;
     ds  w2  x3+8      ;    init page 0 and page 1;

     rl. w1     f40.   ;
     sh  w1     i93    ;    w1:= addr of
     am         f45-f46;      ident, test, entry word
     al. w1     f46.   ;      for std- or rb card reader;
     rl  w0  x1        ;    move to coroutine description;
     rs  w0  x3+4      ;
     wa. w0     f42.   ;    increase coroutine ident;
     rs  w0  x1        ;
\f


; btj 20.7.74         card reader init             read   ...21...


; put coroutine in activ queue

     al  w1  x3        ;    w1:= coroutine descr addr
     al  w3  x3+e12    ;    increase(current coroutine addr);
     rs. w3     f20.   ;
     jl. w3    (f13.)  ;    put in activ queue (w1);

; repeat for all incarnations

     al  w0     0      ;
     rs. w0     f0.+d1 ;    clear process name
     rs. w0     f0.+d7 ;    clear boss status
     jl.        a0.    ;    goto next incarnation;
a6:                    ;

; reserve start code page and move to virt

     al  w0     i63    ;    w0:= start code page on disc
     al  w1     f5     ;    w1:= length of start page;
     jl. w3    (f11.)  ;    reserve virt(w0,w1,w2);
     al  w2  x2+1      ;    insert writing

     al. w0     f4.    ;    w0:= start of start page;
     jl. w3    (f12.)  ;    move to virt(w0,w1,w2);
; w2 = virt start code page

; initialize externals
     rs. w2     f8.    ;

     jl. w3    (2)     ;    set externals;
f9:             40     ;

f8:      0  ,   365    ;    virt start card;
         f36,   366    ;    rel start card;
f22: e13<12+19,  72    ;    card reader free operations;
         0  ,  -1000   ;    end of externals;


; end initialization

     am.(4,jl.4,h0.)   ;    goto initialize reader;

; reserve area
; w0,w1,w2 = reserve on disc, pagelength, no of pages
; on exit: w2 = virt addr of last page

a9:  rs. w3     f51.   ;    save(return);
     rs. w2     f51.+2 ;    save(no of pages);
a10: rl. w3     f51.+2 ; rep:
     al  w3  x3-1      ;    decrease(no of pages);
     rs. w3     f51.+2 ;
     sh  w3    -1      ;    if all pages reserved then
     jl.       (f51.)  ;      goto saved return;
     jl. w3    (f11.)  ;    reserve virt(w0,w1,w2);
     jl.        a10.   ;    goto rep;

e.
; re 76.08.03          card reader init        read   ...21a...

; j.code to move card reader device numbers into code

b. a10 w.

c. i93-1
a2:  al  w1     0      ;
a3:  am.       (a5.)   ;
a4:  bl. w0  x1        ;
     hs. w0  x1+f60.   ;

     al  w1  x1+1      ;
     se  w1     i93    ;
     jl.        a3.    ;

     al  w0     0      ;    normal exit to slang:
     al  w2     0      ;
     jl      x3        ;

a5: e54-q0-12+10000-a4  ;    options.first card reader
;f60: init code.first card reader
     jl.        a2.
j.
z.
e.
\f


; btj 20.7.74         card reader                  read   ...22...


f2=k ; start of card reader codepage

; page descriptions
b0:  0                 ;    page 0   code
b1:  0                 ;    page 1   own variable page
b2:  0                 ;    page 2
b3:  0                 ;    page 3   input buffer
b4:  0                 ;    page 4   global counters
     61<12+0           ; pageident: cardreader

; semaphores, queues
b7:  52                ;    request free sem
b8:  51                ;    request queue
b9:  67                ;    banker queue
b10: 72                ;    card reader free operations queue

; cl entries
b15: 1                 ;    send and wait
b16: 3                 ;    lock
b17: 4                 ;    open
b18: 5                 ;    lock chained
b19: 6                 ;    open chained
b20: 9                 ;    send and wait slow
b21: 7                 ;    get pages
b22: 25                ;    call

; absolute addresses
b30: 26                ;    current coroutine description address

; virtual addresses
b31: 365               ;    virt,
b32: f37               ;      rel wait start operation
b33: 365               ;    virt,
b34: f38               ;      rel release and wait

; definition of card reader messages
b36: 0<12+4            ;    sense ready message
b39: 14<12+4           ;    set mode message
           0           ; +2    eof word

; program variables
b40: 0                 ;    saved return from move text
b48: 0                 ;    start of last card

; status masks + input mode masks
b54: 8.0130 0001       ;    em+eof+eoj+mode error
b55: 8.5570 0076       ;    boss status bits
b56: 8.2023 0000       ;    job    -     -
b57: 8.0020 0000       ;    eof card/attention
b58: 8.0100 0000       ;    em (end file/end deck)
b59: 8.0400 0000       ;    data overrun
b60: 8.5540 0075       ;    operator status bits
b61: 8.0130 0000       ;    card reader ready mask = em + eof + eoj
b62: 8.1000 0000       ;    timer (=card jam or timeout on sense-ready)
b63: 8.0000 0276       ;    input mode mask
b64: 8.0000 0010       ;    add decimal mode
b65: 8.0000 0016       ;    boss bits in mode
b66: 8.0010 0000       ;    eoj card
b67: 8.0000 0004       ;    end boss file (in job status)

; constants
b70: 25<16             ;    em character
\f


; btj 20.7.74        card reader                  read   ...23...


b80: <:host:>,0,0,0    ;    name of host process


; definition of operator messages

;  requests with bel:

g3: <: attention<0>:>
g5: <: card jam<0>:>
g7: <: data overrun<0>:>

;  requests without bel:

g4: <: ready<0>:>
g6: <: disconnected<0>:>

g8: <:card reader    <0>:>
g16:<: illegal job file mode<0>:>
g17:<:<13><10><127>:>


; define card lengths in bytes

  g0:  80, 0, 52, 0, 54, 54, 34, 36


; define end file pictures

  g1:  g10., 0 ,   g10.   , 0 ,   g11.   ,  g12.  ,   g11.   ,  g12.
;    binary  , - , binary , - , decimal  ,  ebcd  , decimal  ,  ebcd



; define end job pictures

  g2:  g13.  , 0 ,  g13.  , 0 ,   g14.   ,  g15.  ,   g14.   ,  g15.
;     binary , - , binary , - , decimal  ,  ebcd  , decimal  ,  ebcd



; definition of end-card-words
;
;     contents   ; card type

g9: 1024<12 + 1024      ;  0   binary
            0           ;  2   -not used-
    1024<12 + 1024      ;  4   binary
            0           ;  6   -not used-
    32<16 + 32<8 + 32   ;  8   decimal
    <:---:>             ; 10   ebcdic
    32<16 + 32<8 + 32   ; 12   decimal
    <:---:>             ; 14   ebcdic
\f


; btj 20.7.74          cardreader                 read   ...24...


; define binary end of file card

  g10 = k-2,  h.

  1024 , 2056 , 2049 , 1088 , 2064 , 0,r.7
;   -  ,  f  ,   i  ,   l  ,   e
w.



; define decimal end of file card

  g11 = k-2

  70<16+192<8+35, 69<16+0<8+0, 0,r.4
;  f     i    l   e           blanks




; define ebcdic end of file card

  g12 = k-2

         <:file  :>, <:   :>, r.4




; define binary end job card

  g13 = k-2, h.

  1024 , 1280 , 1032 , 2176 ,  0,r.8
;   -  ,  j  ,   o  ,   b  ,  blanks
w.


; define decimal end job card

  g14 = k-2

  33<16+38<8+66,  0,r.5
;  j     o    b    blanks



; define ebcdic end job card

  g15 = k-2

         <:job:>, <:   :>, r.5
\f


; btj 20.7.74         card reader                  read  ...25...


; prepare buffer
;
; ensures that page 3 may contain at least
; one card (and the answer, if job controlled).

b. a10 w.

c11: rl  w0  x3+d8     ;    if bufrel
     wa  w0  x3+d9     ;      + controller
     wa  w0  x3+d10    ;      + cardsize
     sh  w0     512    ;      <= 512 then
     jl      x1        ;      return

; change buffer
;
; rest of buffer is cleared, the buffer is given
; to the psjob, and the next is locked

c14: al  w2     0      ;    bufrel:= 0;
     rx  w2  x3+d8     ;    w2:= old bufrel;
     al  w0     0      ;
a0:  sl  w2     512    ; rep:
     jl.        a1.    ;    if old bufrel < 512 then
     am.       (b3.)   ;      begin page3.old bufrel:= 0;
     rs  w0  x2        ;      increase(old bufrel);
     al  w2  x2+2      ;      goto rep;
     jl.        a0.    ;      end;

a1:  rl  w2  x3+d12    ;    increase(local block count);
     al  w2  x2+1      ;
     rs  w2  x3+d12    ;
     am     (x3+d9)    ;
     rl  w2  x3+d39    ;    open(full (controller));
     jl. w3    (b17.)  ;
     rl. w2    (b30.)  ;
     wa  w3  x3+d9     ;    w3:= page 1 + controller;
     al  w0     512    ;    page 3:= page 3 + 512;
     wa  w0  x2+12     ;
     sn  w0 (x3+d37)   ;    if page 3 = top virt (controller) then
     rl  w0  x3+d36    ;      page 3:= first virt(controller);
     rs  w0  x2+12     ;    page 3:= w0;
     rl  w2  x3+d38    ;
     al  w3  x1        ;    lock(free(controller))
     jl.       (b16.)  ;      and return;

e.
\f


; btj 20.7.74          card reader                 read  ...26...


; read block
;
; a suitable buffer part is found, and a block
; of cards is read into it
; if answer to psjob is not send yet, it will
; be send now, indicating mode error or not.
b. a10 w.
c2:  jl. w1     c11.    ;    prepare buffer;
     rl. w1     b3.     ;
     al  w2  x1+510     ;    last in message:= page 3 + 510;
     wa  w1  x3+d8      ;    first in message:= page 3
     wa  w1  x3+d9      ;      + bufrel + controller;
     ds  w2  x3+d6+4    ;
     al  w1  x3+d6      ;
     al  w2  x3+d1      ;
     jl. w3    (b20.)   ;    send wait slow(cardreader,input);

     rl  w2  x3+d8      ;
     rs  w2  x3+d15     ;    save old bufrel;
     wa  w2  x3+d9      ;    bufrel:= bufrel + controller
     wa  w2  x1+2       ;      + bytes transferred;
     rs  w2  x3+d8      ;
     sz. w0    (b66.)   ;    if eoj status then
     lo. w0     b57.    ;      add eof status;
     la. w0     b55.    ;    extract boss status bit;
     rs  w0  x3+d7      ;    save boss status;

     rl  w2  x3+d9      ;    if job controlled then
     sn  w2     0       ;      begin
     jl.        a2.     ;

     rl  w2  x3+d15     ;      w2:= page 3 + old bufrel;
     wa. w2     b3.     ;
     dl  w0  x1+2       ;      move status extract userbits,
     la. w3     b56.    ;        bytes transferred,
     ds  w0  x2+2       ;        chars transferred,
     dl  w0  x1+6       ;        errorfree chars
     ds  w0  x2+6       ;      to buffer;
     rl. w3     b1.     ;
a2:                     ;      end;
\f


; btj 20.7.74          card reader                 read   ...27...


; special care is taken for the first answer in each file.
; if unintelligible then prepare for <:illegal jobfile mode:> or <:disconnected:>
; send possibly answer to psjob

     al  w0     0       ;    w0:= virt psjob operation;
     rx  w0  x3+d26     ;    virt psjob operation:= 0;
     sn  w0     0       ;    if answer is not send then
     jl.        a3.     ;      begin

     rl. w2    (b30.)   ;
     rs  w0  x2+10      ;      page 2:= psjob operation;
     jl. w3    (b21.)   ;      get pages;
     rl. w1     b2.     ;
     rl  w0  x3+d7      ;      op.2:= if unintelligible
     so  w0     1<3     ;        then <> 0 else
     al  w0     0       ;        0;
     rs  w0  x1+2       ;
     rl  w2  x1+4       ;      open(answer sem);
     jl. w3    (b17.)   ;
     rl  w0  x3+d7      ;
     so  w0     1<3     ;      if unintelligible then
     jl.        a3.     ;        begin
     rl. w0     b57.    ;        status:= end card;
     rl  w1  x3+d13     ;
     sn  w1     0       ;        if filecount=0(i.e. reading jobfile)
     rl. w0     b54.    ;          then status:= em,eof,eoj,modeerror;
     rs  w0  x3+d7      ;
     am     (x3+d9)     ;
     rl  w2  x3+d38     ;        open(free(controller));
     jl. w3    (b17.)   ;        goto test operator message;
     jl.        c5.     ;        end;
a3:                     ;      end;

e.

; test status:
; if status ok then read next block.
;
; if eof status and std cardreader then search the last card
;   read to determine whether it is a normal card
;   (eof bit is cleared), an eof card, or an eoj card
;   (eoj bit is set).

b. a10 w.

     rl  w0  x3+d7     ;    w0:= boss status
     sz  w0     1<1    ;    if not normal answer and
     jl.        a0.    ;      not old std card reader then
     rl  w1  x3+d16    ;
     sl  w1     0      ;      status:= status + em + eof + eoj;
     lo. w0     b61.   ; comment: this will terminate the card
     rs  w0  x3+d7     ;          reading, before giveup;

a0:  sn  w0     1<1    ;    if logical status ok then
     jl.        c2.    ;      goto read block;
\f


; btj 20.7.74           card reader                read   ...28...


; status is not clear
; test for end card, if not: proceed to test operator bits

     so. w0    (b57.)  ;    if not eof card then
     jl.        c5.    ;      goto test operator message;

     rl  w1  x3+d16    ;    if not old std card reader then
     sl  w1     0      ;
     jl.        c4.    ;      goto handle end cards;

; the standard driver for card reader does not recognize
; end-file and end-job cards fully, but only indicates
; that the card can be an end card.

     rl. w1     b3.    ;    start of endcard:=
     wa  w1  x3+d8     ;      page 3
     ws  w1  x3+d10    ;      + bufrel
     rs. w1     b48.   ;      - actual cardsize;

; test for end-file card

     am     (x3+d11)   ;    w2:= abs addr of
     al. w2    +g1.    ;      end-file card picture(card type);
     wa  w2  x2        ;
     jl. w3     c9.    ;    compare(w1,w2);
     jl.        a2.    ; +2 identical: goto eof card;

; test for end-job card

     rl. w1     b48.   ;    w1:= start of endcard;
     rl. w3     b1.    ;    w3 := page 1;
     am     (x3+d11)   ;    w2:= abs addr of
     al. w2    +g2.    ;      end-job card picture (card type);
     wa  w2  x2        ;
     jl. w3     c9.    ;    compare(w1,w2);
     jl.        a1.    ; +2: identical: goto eoj card;

; the endcard status was a fony, it was a normal card

     rl. w3     b1.    ;    w3:= page 1;
     rl  w0  x3+d7     ;
     ws. w0     b57.   ;    remove eof bit from boss status;
     rs  w0  x3+d7     ;
     jl.        c5.    ;    goto test operator message

; end job card found:

a1:  rl. w3     b1.    ;    w3:= page 1;
     rl  w0  x3+d7     ;
     lo. w0     b66.   ;    set eoj bit in boss status;
     rs  w0  x3+d7     ;

; end card found:

a2:  rl. w3     b1.    ;    w3:= page 1;
     rl  w0  x3+d11    ;    w0:= card type;
     rl. w1     b70.   ;
     sz  w0     2      ;    if conversion mode then
     rs. w1    (b48.)  ;      first of card:= em character;

e.
\f


; btj 20.7.74           card reader                read   ...29...


; handle endcards:
; update global counters, or adjust user status
; release buffer

b. a10 w.

c4:  rl  w1  x3+d9     ;    w1:= controller;
     rl  w0  x3+d7     ;    w0:= boss status;
     se  w1     0      ;    if boss controlled then
     jl.        a1.    ;      begin

     rl. w2     b4.    ;      w2:= page 4 (=global counters);
     rl  w1  x3+d13    ;
     al  w1  x1+1      ;      increase(local file count);
     rs  w1  x3+d13    ;
     sz. w0    (b66.)  ;      if eoj status then
     rs  w1  x2        ;        global file count:= local file count;
     rl  w1  x3+d12    ;
     rs  w1  x2+2      ;      global block count:= local block count;
     jl.        a2.    ;      end
a1:                    ;    else
     rl  w2  x3+d15    ;      begin
     wa. w2     b3.    ;      w2:= page 3 + old bufrel (= abs user status);
     rl  w1  x2        ;   
     lo. w1     b58.   ;      set end deck in user status;
     sz. w0    (b66.)  ;      if eoj status then
     lo. w1     b67.   ;        set end boss file in user status;
     rs  w1  x2        ;      end;

a2:  am     (x3+d9)    ;
     rl  w2  x3+d39    ;    open(full (controller));
     jl. w3    (b17.)  ;

e.
\f


; btj 20.7.74            card reader               read   ...30...


; test operator message

b. a10 w.

f31 = k-b0 ; entry std card reader

c5:  rl. w3     b1.    ;    w3:= page 1;
     rl  w0  x3+d7     ;
     sz. w0    (b60.)  ;    if boss status contains
     jl.        4      ;      no operator bits then
     jl.        c7.    ;      goto next action;

; boss status contains one or more of the following logical
; status bits: local
;              timer
;              data overrun
;              end deck
;              tray full
;              unknown
;              disconnected
;              unintelligible
;              rejected
;              mode error

; an operator message is assembled with one of the
; following texts:
;            ready         (=end deck+eof+eoj)
;            attention     (=local, enddeck, tray full)
;            card jam      (=timer)
;            overrun       (=data overrun)
;            disconnected  (=unknown, disconnected, unintelligible, rejected)
;            illegal jobfile mode (=mode error)

; if job controlled reading, and in the middle of a file, then tell the
; psjob to stop the job

     rl  w1  x3+d9     ;    if job controlled
     se  w1     0      ;      and
     sz. w0    (b57.)  ;      not eof status then
     jl.        a1.    ;      begin

     jl. w1     c11.   ;      prepare buffer;
     rl. w1     b3.    ;      w1:= page 3
     wa  w1  x3+d8     ;        + bufrel;
     al  w0    -1      ;      status of answer := -1
     rs  w0  x1        ;        (i.e. stop job);
     jl. w1     c14.   ;      change buffer;
a1:                    ;      end;

e.
\f


; btj 20.7.74             card reader              read  ...31...
b. a10 w.



; get a request line, assemble the text

     rl. w2     b7.    ;
     jl. w3    (b18.)  ;    lock chained (request free);

     rl. w2    (b30.)  ;
     rl  w0  x2+10     ;    save virt request line addr;
     rs  w0  x3+d21    ;

     al. w2     g8.    ;    move <:card reader:> to
     jl. w3     c10.   ;      request line;
     rl  w2  x3+d5     ;
     rs  w2  x1-2+6    ;    move devicenumber to line;
     al  w2  x3+d2     ;    move local devicename
     jl. w3     c10.   ;      to request line;
     rl  w0  x3+d7     ;    w0:= boss status;

     so. w0    (b61.)  ;    text:=
     am         g3-g4  ;      if enddeck+eof+eoj then
     al. w2     g4.    ;      <:ready:> else <:attention:>;

     sz. w0    (b62.)  ;    if timer then
     al. w2     g5.    ;      text:= <:card jam:>;

     so  w0     1<1    ;    if unknown, disconnected, unintelligible or rejected
     al. w2     g6.    ;      then text:= <:disconnected:>;

     sz. w0    (b59.)  ;    if overrun then
     al. w2     g7.    ;      text:= <:data overrun:>;

     sz  w0     1      ;    if modeerror then
     al. w2     g16.   ;      text:= <:illegal jobfile mode:>;

     jl. w3     c10.   ;    move text to request line;
     
     rl. w2     g17.   ;
     rs  w2  x1+6      ;    terminate with newline;

     ws. w1     b2.    ;    w1:= text length excluding newline;
     rl  w0  x3+d16    ;
     sl  w0     1      ;    request line type:=
     jl.        a1.    ;    if rb card reader then goto rb line;
     sl. w2     g4.    ;    if request without bel then
     jl.        a2.    ;    goto insert line
     am         1<3-1<2;    code:= insert line with bel
a1:  am         1<2    ;           rb line
a2:  al  w0     1<1    ;           insert line
     rl. w2     b2.    ;    w2:= request line;
     ds  w1  x2+4      ;    save request line type and text length;
     dl  w1  x3+d32+2  ;    move rb parent description
     ds  w1  x2+e10-2  ;      to last part of request line;

e.
\f


; btj 20.7.74             card reader              read   ...32...


; write the request line:
; if rb card reader then send the text
; in operator mode to the card reader process.

b. a10 w.

     rl. w1     b2.    ;    w1:= abs request line;
     rl. w2     b8.    ;    w2:= request queue;
     jl. w3    (b19.)  ;    open chained(w1,w2);

     rl  w0  x3+d16    ;
     sh  w0     0      ;    if rb card reader then
     jl.        a2.    ;      begin

a1:  rl. w2    (b30.)  ; write request:
     rl  w1  x3+d21    ;
     rs  w1  x2+10     ;      page 2:= virt request line;
     jl. w3    (b21.)  ;      get pages;
     rl. w1     b2.    ;
     al  w1  x1+6      ;      w1:= abs first of line;
     al  w2  x1-2      ;
     wa  w2  x2        ;      w2:= abs last of line including newline;
     al  w2  x2+2      ;
     ds  w2  x3+d22+4  ;      save in operator message;
     al  w1  x3+d22    ;
     al  w3  x3+d1     ;
     jd         1<11+4 ;    get process description address
     rs  w0  x3+d22+6-d1;   set process description address in operator output
     al. w2     b80.   ;    w2:=address(host)
     jl. w3    (b20.)  ;      send and wait slow(cardreader,operator output);

a2:                    ;      end;

e.
\f


; btj 20.7.74             card reader              read   ...33...


; if the status contains any of:
;   unknown, disconnected, unintellibible, rejected, mode error
; or (optionally) if it is a rb card reader and
;   the status contains: enddeck + eof + eoj (i.e. cardreader ready)
; then the card reader is released

b. a10 w.

     rl  w0  x3+d7     ;    w0:= boss status;
c.i201
     rl  w1  x3+d16    ;
     sl  w1     1      ;    if rb card reader and
     so. w0    (b61.)  ;      enddeck + eof + eoj
z.
     sz  w0     8.75   ;    or not normal answer or mode error
     jl.        4      ;    then
     jl.        a3.    ;      begin
     rl  w1  x3+d16    ;    if std card reader then
     sh  w1     0      ;
     jl.        a1.    ;      goto release;
     al  w1  x3+d20    ;      w1:= release request line operation;
     rl. w2     b8.    ;      w2:= request queue; (i.e. it acts as a print line)
     jl. w3    (b19.)  ;      open chained (w1,w2);
     rl  w2  x3+d20+4  ;
     jl. w3    (b16.)  ;      lock (answer sem);

f32 = k-b0 ; entry rb card reader

     al  w0     0      ;      virt request line:= 0;
     rs  w0  x3+d21    ;
     rl. w0     b61.   ;      status := em + eof + eoj;
     rs  w0  x3+d7     ;
a1:  dl. w3     b34.   ;
     jl. w1    (b22.)  ;      call (release and wait);
     jl.        a5.    ;      goto set mode;
a3:                    ;      end;

; if status contains data overrun then
; wait for the operator to type the start command

     so. w0    (b59.)  ;    if data overrun then
     jl.        a4.    ;
     dl. w3     b32.   ;
     jl. w1    (b22.)  ;      call(wait start operation);
a5:  rl  w0  x3+d16    ; set mode:
     sl  w0     0      ;    if old std cardreader then
     jl.        a4.    ;      begin
     rl  w1  x3+d11    ;      w1:=card type;
     rl. w0  x1+g9.    ;      w0:=end card word(card type);
     rs. w0     b39.+2 ;      save in message;
     al. w1     b39.   ;
     al  w2  x3+d1     ;
     jl. w3    (b15.)  ;      send and wait(cardreader, set mode);
                       ;      end;
a4:

; wait until the cardreader becomes ready

     al. w1     b36.   ;
     al  w2  x3+d1     ;    send and wait(cardreader,sense ready);
     jl. w3    (b15.)  ;
     sz. w0    (b62.)  ;    if timeout then
     jl.        a4.    ;       goto wait...;

; if the requestline is still pending then release it

     rl  w0  x3+d21    ;    if virt requestline <> 0 then
     sn  w0     0      ;
     jl.        a2.    ;      begin

     al  w1  x3+d20    ;      w1:= release request line operations;
     rl. w2     b8.    ;      w2:= request queue;
     jl. w3    (b19.)  ;      open chained(w1,w2);
     rl  w2  x3+d20+4  ;
     jl. w3    (b16.)  ;      lock(answer sem);
a2:                    ;      end;
e.
\f


; btj 20.7.74             card reader              read  ...34...


; next action

c7:  rl  w0  x3+d7     ;    w0:= boss status;
     so. w0    (b57.)  ;    if not end card then
     jl.        c2.    ;      goto read block;

     so. w0    (b66.)  ;    if not end job card then
     jl.        c8.    ;      goto wait psjob operation;

     al  w1  x3+d30    ;    w1:= banker operation;
     rl. w2     b9.    ;    w2:= banker queue;
     jl. w3    (b19.)  ;    open chained (cardjob ready);
     rl  w2  x3+d31    ;
     jl. w3    (b16.)  ;    lock(answer sem);

     al  w1  x3+d30    ;    w1:= card reader operation
     rl. w2     b10.   ;    w2:= free queue;
     jl. w3    (b19.)  ;    open chained;

     al  w0     0      ;  
     rs  w0  x3+d13    ;    local file count:= 0;

; wait ps-job operation

b. a10 , j10 w.

c8:  rl  w2  x3+d35    ;    lock chained (card reader queue);
     jl. w3    (b18.)  ;

     rl. w2    (b30.)  ;
     rl  w0  x2+10     ;
     rs  w0  x3+d26    ;    save psjob operation addr;

j2:  al  w0     2      ; note: address part used as constant........
     se  w0 (x1+2)     ;    page 4 := if boss controlled then
     wa  w0  x1+10     ;      global file count
     bs. w0     j2.+1  ;    else
     rs  w0  x2+14     ;      0;

     rl  w0  x1+2      ;    controller:= (oper.controller
     bs. w0     1      ;      - 1)*8;
     ls  w0     3      ;
     rs  w0  x3+d9     ;

     rl  w0  x3+d16    ;    if not old std cardreader then
     sh  w0    -1      ; 
     jl.        a4.    ;      begin
;***until further are all files read in standard mode
     al  w0     10     ;
     hs  w0  x3+d6+1   ;    op.mode:=10
     al  w0     2      ;      operation.card length:= 2;
     rs  w0  x1+6      ;
     al  w0     80     ;      actual cardsize:= 80;
     rs  w0  x3+d10    ;      end
     jl.        a6.    ;    else begin
\f


; btj 20.7.74             card reader               read   ...35...


; test mode from operation (normal card reader)

a4:  rl  w1  x1+6      ;      w1:= mode in operation;
c.-1

;***test for dct2000 cardreader
     rl  w2 (x3+d1+8)  ;      w2:= proc descr addr (cardreader);
     rl  w2  x2+0      ;      w2:= process kind (cardreader);
     sn  w2     48     ;      if cardreader = dct2000 then
     al  w1     10     ;        mode:= decimal;
;***
z.
     la. w1     b63.   ;      mode:= mode and mask;
     sz  w1     2      ;      if ebcdic then
     lo. w1     b64.   ;        add decimal;
     hs  w1  x3+d6+1   ;      save mode in input operation;

     la. w1     b65.   ;
     rs  w1  x3+d11    ;      card type:= mode extract boss bits;

     rl. w0  x1+g0.    ;      actual cardsize:=
     rs  w0  x3+d10    ;        card length(card type);
     rl. w2     b2.    ;      move cardlength to
     rs  w0  x2+6      ;        psjob operation;
     rl. w0  x1+g9.    ;      w0:= end card word(card type);
     rs. w0     b39.+2 ;      save in message;
     al. w1     b39.   ;
     al  w2  x3+d1     ;
     jl. w3    (b15.)  ;      send and wait(cardreader, set mode);
a6:                    ;      end;

     al  w0     1      ;    local block count := 1;
     rs  w0  x3+d12    ;
     al  w0     0      ;
     rs  w0  x3+d8     ;    bufrel:= 0;
     am     (x3+d9)    ;
     rl  w1  x3+d36    ;    page 3:= first virt (controller);
     rl. w2    (b30.)  ;
     rs  w1  x2+12     ;
\f


; btj 20.7.74          card reader          read          ...35a...


; lock whole superbuffer

     al  w1     0      ;    count:= 0;
a0:  am     (x3+d9)    ; rep:
     rl  w2  x3+d38    ;    w2:= free sem addr (controller);
     al  w0     0      ;
     sh  w0 (x2)       ;    if value(sem) >= 0 then
     wa  w1  x2        ;      count:= count + value;

     sh  w0 (x2)       ;    if value(sem) >= 0 then
     rs  w0  x2        ;      value(sem):= 0;

     se  w0 (x3+d9)    ;    if count = bufsize(controller)
     am         i52-i53;
     sn  w1     i53    ;      then goto set value;
     jl.        a1.    ;

     al  w1  x1+1      ;    count:= count + 1;
     rs  w1  x3+d15    ;
     jl. w3    (b16.)  ;    lock(free(controller));
     rl  w1  x3+d15    ;
     jl.        a0.    ;    goto rep;

a1:  rs  w1  x2        ; set value: value(sem):= count;
     am     (x3+d9)    ;    if value(full(controller)) <> 0 then
     rl  w0 (x3+d39)   ;
     se  w0     0      ;
c.-1, o66 , z.         ;  (bossfault xref)
     jd        -66     ;    bossfault(66);
     jl. w3    (b16.)  ;    lock (free(controller));
     rl  w0  x3+d9     ;    if job controlled then
     se  w0     0      ;      goto read block;
     jl.        c2.    ;

     al  w0    -1      ;
     al  w1    -1      ;
     rl. w2     b4.    ;    global file count :=
     ds  w1  x2+2      ;    global block count := -1;
     jl.        c2.    ;    goto read block;

e.
\f


; btj 20.7.74              card reader              read   ...36...


; compare
;
; called with w1 = start of card
;             w2 = start of picture
;             w3 = link
;
; on exit all registers are destroyed
; return to  w3+2 if any difference is found

b. a0, j1
w.

c9:  al  w0  x2+14      ;
     rs. w0     j0.     ;   j0 := top of picture;
a0:  aa. w2     j1.     ; rep: increase w1, w2;
     sl. w2    (j0.)    ;   if w2 >= top then
     jl     x3+0        ;   return to link+0;
     rl  w0  x2         ;   if picture(x2) <>
     se  w0 (x1)        ;      card   (x1) then
     jl      x3+2       ;   return to link + 2;
     jl.        a0.     ;   goto rep;
j0:              0      ;   saved top of picture;
                 2      ;   increment to w1;
j1:              2      ;   increment to w2;
e.

; move text (until NULL character)
;
;   entry: w1 = to addr - 6, w2 = from addr, w3 = return
;   exit:  w1 = next to - 6, w2 = top from , w3 = page 1
b. a10 w.
c10: rs. w3     b40.   ;    save return
a0:  rl  w3  x2        ;
     rs  w3  x1+6      ;    move word
     se  w3     0      ;
     al  w1  x1+2      ;    update pointers
     al  w2  x2+2      ;
     sz  w3     255    ;    if not end text then
     jl.        a0.    ;      goto move more;
     rl. w3     b1.    ;    w3:= page 1;
     jl.       (b40.)  ;    return;
e.

f3=k-f2 ; length of card reader code page
\f


; btj 20.7.74            start card                 read   ...37...
f4=k ; start of start card codepage

; this page is used both by commandio and card reader
b. h10, j20 w.
; page descriptions
b100:      0           ;    page 0    code
b101:      0           ;    page 1    job file page/card variables
b102:      0           ;    page 2
b103:      0           ;    page 3    not used/current virt buf
b104:      0           ;    page 4    job descr page/global counters
     62<12+0           ; pageident: start card

; cl entries
b115:      1           ;    send and wait
b117:      4           ;    open
b118:      5           ;    lock chained
b119:      6           ;    open chained
b122:     25           ;    call
b123:      8           ;    page jump

; virtual addresses
b130:    162           ;    virt,
b131:    204           ;      rel alarm print
b132:    140           ;  virt,
b133:    142           ;    rel. lookup device;
b155:    141           ;    rel. lookup and reserve device;
b134:    202           ;    virt,
b135:    203           ;      rel after action

; constants
b127:    <:std:>
b140:      0           ;    for set catbase
b141:     10           ;    decimal radix
b142:   1<16           ;    attention status
b143:    255           ;    mask

; device table.
; contains an entry for each std card reader
;   and each rb card reader
;
; each entry contains:
     h0 = 0            ;   byte ;    wait bits
     h1 = 1, b97 = h1  ;   byte ;    devicenumber
     h2 = 2, b98 = h2  ;   word ;    wait sem
     h10= 4, b99 = h10 ;        ;    size of entry


b160:
c. i93+i200-1
     4095,r.h10*(:i93+i200:) ;    start of table
z.
b161:                        ;    top table

; waitbits:     1<0==card reader is waiting for start operation
;               1<1==start operation is send from commandio
; devicenumber: -1==entry not in use, else devicenumber
; waitsem:      chained semafor, used in common by card reader and commandio.
b162:  -1    -1<0        ;    card reader waiting:= false
b163:         1<0        ;    card reader waiting:= true;
b164:  -1-1<1            ;    operation send:= false
b165:     1<1            ;    operation send:= true
\f


; btj 20.7.74                start card           read   ...38...

; variables on job file page

j1=6                   ;    rel first param = <:card:>
j2=14                  ;    rel second  -   = <local devname> or the like
j3=22                  ;    rel third   -   = <rb printer name> or empty

j5=j3+6                ;    index in device table
j6=j5+2                ;    rel return from lookup device
;***** j5 must not be changed before the lookup procedures are generalized *****

; start card operation

j10=j6+2  ; word       ;    chain
j11=j10+2 ; word       ;    device number / result
j12=j11+2 ; dbword     ;    local devicename (first of dbword)
j13=j12+4 ; word       ;    std input mode
j14=j13+2 ; word       ;    operator mode
j18=j14+2 ; dbword     ;    rbprintername (first of dbword)
j15=j18+6 ; dbword     ; dw. last
j17=j15+2 ; word       ;+8  local terminal ident of starting rb terminal
c. j17-i46
m.*** i46 too small
z.

; commandio actions for <start card> command
;
;   start card                : mainconsole only, first std cardreader
;
;   start card <devicenumber> :     -         - , specified cardreader
;
;   start card <local name> <rbprintername>  : rb terminal only, specified cardreader, 
;   primout on rbprintername if present

b. a10 w.
f36=k-b100 ;    entry start card command

     dl  w1  x3+j2     ;    w0w1:= param2;
     sl  w0     1      ;    if empty or integer then
     jl.        a0.    ;      begin
c.i93-2
     se  w0     0      ;    if more than one std cardreader
     jl.        c30.   ;    and empty then alarm(forbidden)
z.

c. i93-1
b150=k+1
     rl  w2  x3+134    ;      if no std cardreaders or
     so  w2     1      ;        not operator rights then
z.
     jl.        c30.   ;        alarm(<:forbidden:>);

     al  w2    -1      ;
     rx  w2  x3+j3-2   ;      if param 3 not empty then
     se  w0    -1      ;
     sn  w2    -1      ;        alarm(<:param:>);
     jl.        4      ;
     jl.        c37.   ;

     se  w0     0      ;      if empty param then
     bl. w1     b160.+h1;       param:= devno(first entry);

     jl. w3     c21.   ;      search card reader table;
     jl.        c31.   ;+2    if not found: alarm(<:device not cardreader:>);
     jl. w1     c26.   ;      set rb params
     jl.        c20.   ;      goto send operation;
a0:                    ;      end;
\f


; btj 20.7.74         start card             read     ...39...


; test for rb terminal

     am.       (b104.) ;    job descr page
b151=k+1
     rl  w2    +423    ;    w2:= parent rb device name table addr;
     sn  w2     0      ;    if not rb terminal then
     jl.        c30.   ;      alarm(<:forbidden:>);

     ds  w1  x3+j12+2  ;    save local devicename in operation
     jl. w1     c26.   ;    set rb params;
     jl. w1     c24.   ;    lookup device; w1:= devno;

     sn  w1     0      ;    if deviceno undefined then
     jl.        a1.    ;      goto get entry;

; a process exists in rc4000 with that local devicename
; search the cardreadertable to see if it is already connected
     
     jl. w3     c21.   ;    search whole cardreadertable;
     jl.        4      ;+2  if device found in table then
     jl.        c20.   ;      goto send operation;

; before using the process: test the devno and reserver

     jl. w2     c25.   ;    check process descriptions;

; the devicenumber seems to be ok
; find an available entry in cardreadertable

a1:  al  w1    -1      ; get entry: w1:= free entry;
     jl. w3     c21.   ;    search whole cardreader table;
     jl.        c32.   ;+2  if not found: alarm(<:no more cardreaders:>);

; reserve the cardreader at remote batch terminal station

     rl. w3     b101.  ;    w3:=job file page;
     jl. w1     c23.   ;    lookup and reserve device; w1:= devno;
     sn  w1     0      ;    if deviceno undefined then
     jl.        c31.   ;      alarm(<:device not cardreader:>);

; search the cardreadertable again to ensure that the
; same cardreader will not be used twice

     jl. w3     c21.   ;    search whole cardreadertable;
     jl.        4      ;+2  if device found in table then
     jl.        c33.   ;      alarm(<:cardreader busy:>);

; check the devicenumber etc and find (and initialize)
; the available cardreadertable entry
     al  w1    -1      ;    w1:= free entry;
     jl. w3     c21.   ;    search whole cardreadertable;
     jl.        c32.   ;+2  if table full: alarm(<:no more cardreaders:>);
     rl. w3     b101.  ;    w3:=job file page;
     rl  w1  x3+j11    ;
     hs. w1  x2+b160.+h1;   cardreadertable.devno(index):= devicenumber;
e.
\f


; btj 20.7.74              start card            read   ...40...


; send operation to cardreader
;   entry: w2=rel entry in cardreader table
; if cardreader not waiting for start: alarm (busy).
; initialize operation
; send operation and wait answer.
; check result

c20: rl. w3     b101.  ;    w3:= job file page;
     rs  w2  x3+j5     ;    save index;

     bl. w0  x2+b160.+h0;
     sz. w0    (b163.) ;    if cardreader not waiting
     sz. w0    (b165.) ;      or operation send already then
     jl.        c33.   ;      alarm(<:cardreader busy:>);

     lo. w0     b165.  ;
     hs. w0  x2+b160.+h0;   operation send:= true;

     al  w1  x3+j10    ;    w1:= start operation addr;
     
     rl. w2  x2+b160.+h2;   w2:= wait sem(index);
     jl. w3    (b119.) ;    open chained(w1,w2);

     rl  w2  x3+j5     ;
     rl. w2  x2+b160.+h2;   w2:= wait sem(index);
     jl. w3    (b118.) ;    lock chained(wait sem);

     rl  w2  x3+j5     ;    w2:= index;
     bl. w0  x2+b160.+h0;
     la. w0     b164.  ;    operation send:= false;
     hs. w0  x2+b160.+h0;

     rl  w0  x3+j11    ;    w0:= result(operation);
     se  w0     0      ;    if result <> ok then
     jl.        c34.   ;      alarm(<:not same mode:>);
     dl. w3     b135.  ;
     jl.       (b123.) ;    page jump (after action);

; search cardreader table
;
; entry: w1 = deviceno, w3 = return
; exit : w0 undef, w2 = rel entry in device table
;        if not in table: return to x3+0
;                   else: return to x3+2

b. a10 w.
c21: al  w2   (:i93+i200:)*h10;    search cardreadertable:
                       ;    w2:= top tablepart;
a0:  al  w2  x2-h10    ; rep: rel:= rel - 4;
     sh  w2    -1      ;    if rel < 0 then
     jl      x3        ;      error return;
     bl. w0  x2+b160.+h1;   if devicenumber(rel)
     sn  w0  x1        ;      = deviceno then
     jl      x3+2      ;      ok return;
     jl.        a0.    ;    goto rep;

e.
\f


; btj 20.7.74                  start card     read   ...41...
b. a10 w.
 
c23: am         1      ;    lookup and reserve:
c24: al  w2     0      ;    lookup device:
     ws. w1     b100.  ;    w1:=rel return;
     rs  w1  x3+j6     ;    save return;
     dl  w1  x3+j12+2  ;    set device name;
     ds  w1  x3+r1+2   ;  
     ld  w1    -100    ;  
     ds  w1  x3+r1+6   ;
     am.       (b104.) ;
b156=k+1
     dl  w1    +529    ;    set catalog base
     ds  w1  x3+r6+2   ;
b128=k+1
     rl  w0  x3+178    ;
     rs  w0  x3+r0     ;    set abs ref message area
     am.       (b104.) ;    set host ident;
b126=k+1
     dl  w1    +424    ;
     ds  w1  x3+r2+2     ;
     al  w0     16     ;    set mode, kind;
     al  w1     0      ;    set timeout;
     ds  w1  x3+r5+r4-r4;
     se  w2     1      ;
     am         b133-b155;  lookup device
     rl. w3     b155.  ;    lookup and reserve device
     rl. w2     b132.  ;
     jl. w1    (b122.) ;    call (rb procedure);
 
     jl.        a1.    ;+2  
     rl  w0  x3+r104   ;+4 
     se  w0     16     ;    if device not cardreader then
     jl.        c31.   ;    alarm;
     rl  w0  x3+r103   ;
     rs  w0  x3+j13    ;    set std input mode in operation;
     rs  w1  x3+j14    ;    set operator mode in operation;
     rl  w1  x3+r102   ;
     rs  w1  x3+j11    ;    set device no;
     rl  w2  x3+r101   ;    w2:=nta of device;
     sn  w2     0      ;    if lookup and reserve then
     jl.        a2.    ;    begin
     rl  w2  x2        ;      w2:=process description address;
     dl  w1  x2+4      ;      move process name;
     ds  w1  x3+d1+2   ;      
     dl  w1  x2+8      ;
     ds  w1  x3+d1+6   ;    end;
a2:
     rl  w1  x3+j11    ;    w1:=device number
     am     (x3+j6)    ;
     jl.        b100.  ;    goto saved return;
 
a1:  rl  w0  x3+r100   ;    w0:=result;
     sn  w0     6      ;    if attention status then
     jl.        c36.   ;    alarm (last input lione skipped);
 
     se  w0     3      ;    if no resources or
     sn  w0     4      ;    time exceeded then
     jl.        c35.   ;    alarm (wait);
     se  w0     1      ;    if unknown or
     sn  w0     5      ;    disconnected then
     jl.        c31.   ;    alarm (device not card reader);
     jl.        c33.   ;    else alarm (busy);
e.
\f


; btj 20.7.74         start card             read   ...42...

; check process description
; entry: w1 = device number, w2 = return
; exit : w0w1 = undef, w2w3 unchanged

c25: ls  w1     1      ;
     wa  w1     74     ;    w1:= name table addr (devno);
     sl  w1    (76)    ;    if devno too large then
     jl.        c31.   ;      alarm(<:device not cardreader:>);

     rl  w1  x1        ;    w1:= process description address;
     rl  w0  x1+12     ;    w0:= reserver(process);
     se  w0     0      ;    if process already reserved then
     jl.        c33.   ;      alarm(<:cardreader busy:>);
     jl      x2        ;    return;

; procedure set rb params
;   from job descr page of >start< console:
;      parent rb device name table addr
;        -    -    -    creation number
;      rb term ident
;   rb printername is cleared in case of std card reader
;   otherwise it is looked up and the parameter is set accordingly

c26: rl. w3     b101.  ;    w3:=job file page;
     ws. w1     b100.  ;    w1:=rel return;
     ds  w2  x3+j6     ;    save rel return, reader index;
 
b. a10 w.
     ld  w1    -100    ;
     ds  w1  x3+j18+2  ;    default printer:=0;
 
     rl. w2     b104.  ;
b124=k+1
     dl  w1  x2+424    ;    w0w1:=host ident;
     ds  w1  x3+j15+2  ;    set host ident in operation;
     se  w0     0      ;    if local terminal then 
     jl.        a1.    ;
                       ;    begin
     dl  w1  x3+j3     ;
     sl  w0     1      ;      if param3=text then
     jl.        a5.    ;      alarm (param);
     jl.        a7.    ;   end else ok
 
a1:  dl  w1  x3+j3     ;
     sh  w0     0      ;    if param3 not text then
     al  w0     1      ;    printername:=1  (= some rbprinter);
     sn. w0    (b127.) ;    if param3=<:std:> then
     se. w1     0      ;   
     jl.        4      ;
     jl.        a7.    ;    ok;
     ds  w1  x3+r1+2   ;    set printername;
     ds  w1  x3+j18+2  ;
     ld  w1    -100    ;
     ds  w1  x3+r1+6   ;
b125=k+1
     dl  w1  x2+424    ;    w0w1:=host description
     ds  w1  x3+r2+2   ;    set device host description
b157=k+1
     dl  w1  x2+529    ;
     ds  w1  x3+r6+2   ;    set catalog base
b129=k+1
     rl  w1  x3+178    ;
     rs  w1  x3+r0     ;    set abs ref message area
     al  w1     14     ;
     rs  w1  x3+r4     ;    set mode, kind
 
     dl. w3     b133.  ;
     jl. w1    (b122.) ;    call(lookup device);
 
     jl.        a2.    ;+2  error return;
     rl  w0  x3+r104   ;+4  w0:=rc kind;
     se  w0     14     ;    if device not printer then
     jl.        a4.    ;    alarm
     jl.        a7.    ;
 
a2:  rl  w0  x3+r100   ;    w0:=result;
     sn  w0     6      ;    if attention status then
     jl.        a3.    ;    alarm;
     sh  w0     6      ;    if result>6 or
     so  w0     1<0    ;    result <> 1,3 or 5 then
     jl.        a7.    ;    ok else
     dl  w1  x3+j3     ;    if param3 set then
     se  w0    -1      ;    
     jl.        a6.    ;    device unknown else
     ld  w1    -100    ;
     ds  w1  x3+j18+2  ;    set printername=0;
     jl.        a7.    ;
a6:  am         30-43  ;    device unknown;
a3:  am         43-27  ;    last input line skipped;
a4:  am         27-5   ;    device not printer;
a5:  al  w0     5      ;    param;
     jl.        c29.   ;    goto alarm;
 
a7:

     dl  w2  x3+j6     ;    restore rel return, reader index;
     jl.     x1+b100.  ;    return;
e.

\f


; btj 20.7.74         start card            read   ...43...


; alarms for commandio start card action

c38: am         30-5   ;    device unknown
c37: am         5-43   ;    param
c36: am         43-49  ;    last input line skipped
c35: am         49-48  ;    wait
c34: am         48-47  ;    not same mode
c33: am         47-46  ;    card reader busy
c32: am         46-45  ;    no more card readers
c31: am         45-1   ;    device not card reader
c30: al  w0     1      ;    forbidden

; set param for alarm print

c29: rl. w3     b101.  ;
     rs  w0  x3+4      ;    save alarm index;
     dl. w3     b131.  ;
     jl.       (b123.) ;    page jump(alarm print);

; release card reader
;
; page 1 = card variables, page 3 and 4 = irrell

f38=k-b100

     al  w0     0      ;    clear std mode name;
     rs  w0  x3+d2     ;

     al. w1     b160.  ;    w1:= cardreadertable
     wa  w1  x3+d14    ;      + index;
     al  w0    -1      ;
     sh. w1 b160.+i93*h10-1;   if std cardreader then
     jl.        c28.   ;    goto wait for start operation;
     hs  w0  x1+h1     ;      devicenumber(index):= free;

     am        (66)    ;    set catbase(boss maxbase);
     dl  w1    +74     ;
     al. w3     b140.  ;
     jd         1<11+72;
     rl. w3     b101.  ;
     al  w3  x3+d1     ;    remove process(cardreader);
     jd         1<11+64;
\f


; btj 20.7.74         start card             read  ...44...

; wait start operation
;
;   page 1 = card variables, page 3 = inputbuf, page 4 = global counts

b. a10 w.

f37=k-b100

c28: rl. w3     b101.  ; wait for start operation:
     al. w1     b160.  ;    w1:= devicetable
     wa  w1  x3+d14    ;      + index;
     bl  w0  x1+h0     ;
     lo. w0     b163.  ;    set waiting bit(index);
     hs  w0  x1+h0     ;
     rl  w2  x1+h2     ;
     jl. w3    (b118.) ;    lock chained(wait sem(index));
     al  w2  x1-j10    ;    w2:= operation addr - start (i.e. first of jobfile);
     rl  w0  x3+d14    ;    if std card reader then
     sh  w0     i93*h10-1;
     jl.        a3.    ;      goto reserve cardreader

     dl  w1  x3+d2+2   ;    if rb cardreader not released then
     sn  w0     0      ;      begin
     jl.        a1.    ;

     sn  w0 (x2+j12)   ;      local devicename
                       ;        and
     se  w1 (x2+j12+2) ;
     jl.        a7.    ;      input mode
    
     bz  w0  x3+d6+1   ;        must match:
     se  w0 (x2+j13)   ;
     jl.        a7.    ;      if error then goto not same mode;
     jl.        a4.    ;      goto init parent words;

a1:                    ;      end;

     dl  w1  x2+j12+2  ;    move local device name;
     ds  w1  x3+d2+2   ;

     dl  w1  x2+j14    ;    move std input mode
     hs  w0  x3+d6+1   ;    operator mode (odd);

     rl  w1  x2+j11    ;    convert devno to text;
     al  w0     0      ;
     wd. w1     b141.  ;
     se  w1     0      ;    (layout=<<dd >)
     al  w1  x1+48     ;
     ls  w1     8      ;
     wa  w1     0      ;
     al  w1  x1+48     ;
     ls  w1     8      ;
     al  w1  x1+32     ;
     rs  w1  x3+d5     ;    save in card variables;
\f


; btj 20.7.74          start card             read   ...45...


     rl  w2  x2+j11    ;    name tab addr:= devno
     ls  w2     1      ;      *2
     wa  w2     74     ;      + first device in name table;
     rs  w2  x3+d1+8   ;
     rl  w2  x2        ;    w2:= proc descr addr;
     dl  w1  x2+4      ;
     ds  w1  x3+d1+2   ;    move process name
     dl  w1  x2+8      ;
     ds  w1  x3+d1+6   ;
; reserve cardreader
a3:                    ;
     am        (66)    ;    set catbase(boss maxbase);
     dl  w1    +74     ;
     al. w3     b140.  ;
     jd         1<11+72;
     rl. w3     b101.  ;
     al  w3  x3+d1     ;    reserve process(cardreader);
     jd         1<11+8 ;
; initialize parent descriptions
a4:  rl. w3     b101.  ;    move
     rl. w2     b102.  ;
     al  w2  x2-j10    ;
     dl  w1  x2+j18+2  ;
     ds  w1  x3+d44+2  ;    rb printername
     dl  w1  x2+j15+2  ;    parent rb device name table addr
     ds  w1  x3+d32+2  ;      -    -     -   creation number
     rl  w1  x2+j17    ;    local term ident
     rs  w1  x3+d34    ;

     jl.        a8.    ;    goto answer ok;

; send answer to commandio

a7:  am         1-0    ;    result:= not original mode
a8:  al  w0     0      ;    result.commio operation:= ok
     rl. w1     b102.  ;
     rs  w0  x1+j11-j10;
     al. w2     b160.  ;
     wa  w2  x3+d14    ;
     rl  w2  x2+h2     ;    w2:= wait semaphore(index)
     jl. w3    (b119.) ;    open chained;

     al. w1     b160.  ;
     wa  w1  x3+d14    ;    w1:= cardreadertable + index;
     bl  w0  x1+h0     ;
     la. w0     b162.  ;    remove waiting bit (index);
     hs  w0  x1+h0     ;

; return to card reader code:

     dl  w3  x3+2      ;
     jl.       (b123.) ;    page jump to return;

e.
i.
e.   ; end start page

f5=k-f4 ;    length of start card codepage
h3=h2.  ;    define link for initialization

i.
e. ;    end b,c,d,f,g names for cardreader
\f

\f



; btj 28.10.71          psjob tape input          read    ...46...


; the reader is controlled by the psjob by means of a state-logic.
;
; state:   meaning:
;
;   -6     online reservation not checked yet.
;          ( the first message checks the reservation, and sets
;          the state -4, if ok)
;
;   -4     reservation checked.
;          the reader is ready for load message, which sets the
;          state -2. the load message from the job causes banker-
;          reserving of the reader and sending of a load-reader-
;          line to the request display. input and sense are re-
;          turned with normal answer and end medium status.
;
;   -2     load message received.
;          the input mode is checked, and the reader corutine is
;          started. the first input-buffer page is locked, and the
;          request line is released. ( the state is set to 0).
;          ( continue with state >= 0)
;
;    0     input-buffer page not reserved.
;          the next buffer page is locked. (continue with state>= 0)
;
;  >=0     input transfer in progress.
;          the ...state... is a relative address in the input buf-
;          fer page, pointing at the answer, currently used.
;          ( when the input buffer page is emptied, the state is
;          set to 0, unless it is the end of the tape, in which
;          case the state is set to -4)


\f


; btj 15.10.71          initialize pstape          read    ...47...

s. b100, c25, f100, g5  w.;
; external list:

b5.,  b6.,  b7.,  b8.,  b9.,   b13.
b17., b20., b21., b22.,  b86., b87., 
f0.,  f1.,  f2.,  f4.,  f5.,  f6.,  f7.,  f8.,  f9.,  f10.
f11., f12., f13., f14., f15., f18., f19., f20.
f21., f22., f23., f26., f27., f28., f29.
f31., f32., f33., f34., f35., f36., f37., f38., f39., f40.
f41., 
f42., f43., f44., f45., f46., f47., f48., f49., f50.
f51., f52., f53., f54., f55., f56., f57., f58., f59., f60.
f61., f62., f63., f64., f65., f67., f68., f69., f70.
f71., f72., f73., f74., f75., f76., f77., f78., f79., f80.
f81., f82., f83., f84.
c.-314, f91., f92., z. ;    *** cf. page 54
h4: h5  ; define link for initialization


; initialize page:

     al  w0     i94    ;    ...psjobtape on disc...
     al  w1     g1     ;    ...length...
     jl. w3    (f1.)   ;    reserve virtual;

     al. w0     b0.    ;    ...start address...
     jl. w3    (f2.)   ;    move to virtual;
     rs. w2     f30.   ;

     jl. w3    (2)     ;    set externals;
f15:            40     ;

f30:     0  ,   442    ;    virt tape input;
         g2 ,   443    ;    rel tape input;
         0  ,  -1000   ;    end of externals;

     am.       (4)     ;   goto initialize card reader;
     jl.       +4      ;
     h2.               ;

; variables used in initialization:
f0:       0            ;    base of externals
f1:       12           ;    reserve virt
f2:       13           ;    move to virt
\f


; btj 15.10.71          pstape, externals and variables          read    ...48...


; definition of b-names
;
; pages and cl-entries

b0:       0            ;    page 0 code and variables
b1:       0            ;    page 1 job file page
b2:       0            ;    page 2 (not used)
b3:       0            ;    page 3 input buffer  or  job descr page
b4:       0            ;    page 4 message
          63<12+0      ; pageident:  pstape

b5:       3            ;    lock simple
b6:       4            ;    open simple
b7:       6            ;    open chained
b8:       8            ;    page jump
b9:       7            ;    get pages
;b10:      5            ;    lock chained


; semaphores
b13:      56           ;    tape reader que

;b85:      52           ;    request line free
b86:      51           ;    request que
b87:      67           ;    banker que


; virtual addresses

f27:      320          ;    addr of return point in psjob i/o
b17:      321          ;   

b21:      473          ;    addr of banker kill
b22:      364          ;


; absolute addresses

b20:      26           ;    current corutine descr


; answer definitions

b30:      0            ;    answer: status
b31:      0            ;            no of bytes
b32:      0            ;            no of chars
\f


; btj 15.10.71          pstape, variables          read    ...49...

; constants:

b40:      1<18         ;    end of medium in status
;b43:      -1-1<2       ;    mask for clearing unwanted card-status bits
;b44:      1<1          ;    card reader included (in online bits)
;b99:      10           ;    divisor constant
;b100: <:load  :>,<:      :>; text constant


; variables:

; abs addresses

b45:      0            ;    current answer(in buffer)
b46:      0            ;    start of current buffer part

; other

b50:      0            ;    length of current buffer.answer;


; relative addresses on page 1, job file page

b60=      176          ;    job sem addr
b62=      446          ;    state, and answer rel in tape reader buffer
b63=      447          ;    start rel. of current buffer.answer
b64=      449          ;    status of tape reader
b65=      448          ;    current virt addr of tape reader buffer

b66=      429          ;    next store in job input area

b67=      198          ;    state, and answer rel in card reader buffer
b68=      450          ;    start rel of current buffer.answer
b69=      200          ;    status of cardreader
b70=      199          ;    current virt addr of card reader buffer
b71=      201          ;    card length

b72=      179          ;    online bits
b73=      177          ;    job descr page
b10=      148          ;    reader device number on job descr page
                       ;    (leftmost byte = boss contr reader
                       ;     rightmost byte = job contr reader)

b11=      518          ;    reader free sem (and temporarily at load - reader device number)
b12=      519          ;    reader full sem
b15=      520          ;    first virt reader buffer
b16=      521          ;    top virt reader buffer

; relative addresses on page 3, job descr page

b80=      149          ;    rel reader table

b74=      329          ;    job name 1
b75=      330          ;    job name 2
b76=      332          ;    psjob operation: chain
b77=      334          ;    +4             : psjob buf
b78=      348          ;    banker operation + 2
b79=      325          ;    dump area descr
\f


; btj 15.10.71          pstape, entry point and central return          read    ...50...


; a message to the tape reader is received
g2=k-b0
     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:=message buffer address;
     rl  w0  x2+10     ;
f71=k+1
     rs  w0  x3+b66    ;    next store:=first store;
     bl  w0  x2+8      ;    w0:= operation of message;
     sn  w0     3      ;    if operation = input then
     jl.        c4.    ;    goto input message;
     sz  w0    -1-2    ;    if operation <> (sense or sense ready) then
     jl.        c2.    ;    goto unintelligible;

; sense message received:
c7:  ld  w1    -100    ;  init status:
     ds. w1     b32.   ;    no of chars:=no of bytes:=0;
     al  w1     1<1    ;    w1:=normal answer;
     lo. w1     b40.   ;      and end of medium;
f4=k+1
     bl  w0  x3+b62    ;    if state < 0 then
     sh  w0    -1      ;
f5=k+1
     rs  w1  x3+b64    ;    logical status of tape reader:=w1;
c1:                    ;  normal answer:
f6=k+1
     rl  w1  x3+b64    ;    w1:=logical status;
     al  w0    -1<6    ;
     la  w0     2      ;    w0:=status.answer
     rs. w0     b30.   ;      :=logical status-result
     ws  w1     0      ;    w1:=1<result;
jd-1
     ci  w1    -1-3    ;    w1:=result-3;
jd-1
     bl  w1     3      ;
     am      x1        ;
c2:  al  w0     3      ;  unintelligible:  w0:=result;
jd-1

c0:  al. w1     b30.   ; send answer    w1:= answer address;
     am.       (b4.)   ;
     rl  w2    +4      ;    w2:= message buffer address;
     jd         1<11+22;    send answer(w0, w1, w2);

c11: ld  w2     65     ; exit:
     am.       (b4.)   ;    mess buf addr:= 0;
     rs  w1    +4      ;

     rl. w3    (b20.)  ;    release page 3 and 4;
     ds  w2  x3+14     ;
     dl. w3     b17.   ;    page jump to psjob i/o;
     jl.       (b8.)   ;

; input message received:
c4:  bl  w1  x3+b62    ;    w1:= state;
f7=c4+1
jd-1
     sl  w1     1      ;    if state > 0 then
     jl.        c10.   ;    goto prepare transfer;
     jl.     x1+c5.    ;    goto action (state);

     jl.        c6.    ; -6:   goto check online reservation;
     jl.        c7.    ; -4:   goto init status;
     jl.        c8.    ; -2:   goto check mode;
c5:  jl.        c9.    ;  0:   goto reserve input;
\f


; btj 15.10.71          pstape, check reservation and inputmode          read    ...51...

; state -6. check online reservation
;   continue with rejected answer or init status
c6:

     al  w0    -4      ;    state := -4;
f35=k+1
     hs  w0  x3+b62    ;
     jl.        c7.    ;    goto init status;


; state -2. check mode:
;   check mode

c8:  rl. w2    (b20.)  ;    w2:= curr corutine...
f40=k+1
     rl  w0  x3+b73    ;    page 3 descr:=
     rs  w0  x2+12     ;    job descr page;
     jl. w3    (b9.)   ;    get pages;

     am.       (b4.)   ;    ...operation address...
     am       (+4)     ;    ...message buffer address...
     bz  w0    +9      ;    w0:= mode of message;
     sz  w0    -1<3+1  ;    if mode is not 0, 2, 4 or 6 then
     jl.        c2.    ;    goto unintelligible;
f41=k+1
     hs  w0  x3+b63    ;    save mode on job file page;
\f



; btj 11.2.72          pstape, prepare first input          read    ...52...


;   stop job

     am.       (b3.)   ;    ...job descr address...
f42=k+1
     al  w1    +b78    ;    w1:= banker operation address;
     al  w1  x1-2      ;
  
     al  w0     17     ;    optype:= <stop job>;
     hs  w0  x1+2      ;

     rl. w2     b87.   ;    w2:= banker que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);
     am.       (b3.)   ;
f43=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
     jl. w3    (b5.)   ;    lock(w2);

;   get the tape reader from the banker

     am.       (b3.)   ;
f67=k+1
     al  w1    +b78    ;    w1:= operation address;
     al  w1  x1-2      ;
     al  w0     3      ;    operation:= <reserve reader>;
     hs  w0  x1+2      ;
     al  w0     0      ;    w0:= host ident;
     rs  w0  x1+4      ;    set host ident in reserve reader operation;
f63=k+1
     rl  w0  x3+b11    ;    w0:=reader device number (computed from loadmessage)
     sh  w0    -1      ;    if exclusive device (dev.no < 0)
     ac  w0    (0)     ;    then change sign
     am.       (b3.)   ;    - job descr page -
     am         1      ;
f64=k+1
     hs  w0    +b10    ;    set reader device no on job descr page
     rs  w0  x1+6      ;    set reader device no in reserve reader operation
     rl. w2     b87.   ;    w2:= banker que;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;
f68=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
     jl. w3    (b5.)   ;    lock(w2);

     am.       (b3.)   ;    w1:= result;
f69=k+1
     bz  w1    +b78    ;
     se  w1     0      ;    if killed then
     jl.        c14.   ;    begin
     al  w1    -6      ;      regret the load, i.e.
f70=k+1
     hs  w1  x3+b62    ;      state:= -6;

     rl. w2    (b20.)  ;
     al  w1     0      ;
     rs  w1  x2+8      ;      page 1:= 0;
     rx  w1  x2+12     ;      page 3:= 0;
     rs  w1  x2+14     ;      page 4:= job descr;
     dl. w3     b22.   ;
     jl.       (b8.)   ;      page jump(banker kill);
                       ;    end;
\f


; re 11.10.73               pstape, prepare first input             read   ...53...


c14: am.       (b3.)   ;    w1:= psjob operation address;
f44=k+1
     al  w1    +b76    ;

f45=k+1
     bz  w0  x3+b63    ;    w0:= mode of operation;
     rs  w0  x1+6      ;    save mode in operation;
f65=k+1
     rl  w0  x3+b11    ;    w0:=device no (with sign)
     sh  w0    -1      ;    if exclusive device (dev.no < 0)
     am         1      ;    then operation:=3 (=special job contr) else
     al  w0     2      ;    optype:= job controlled;
     rs  w0  x1+2      ;
     am.       (b3.)   ;
f79=k+1
     al  w2    +b78    ;
     rl  w0  x2+4      ;    w0:=device number of reader;
     rs  w0  x1+14     ;    set device number in operation;

f54=k+1
     rl  w0  x3+b65    ;    move virtual request line address
     rs  w0  x1+12     ;      to operation...

     rl. w2     b13.   ;    w2:= tape reader que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;
f46=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
     jl. w3    (b5.)   ;    lock(w2);

;   reserve input
;   release request line

     rl. w2     b3.    ;    w2:=job descr page
f28=k+1
     al  w2  x2+b80    ;    w2:=start of reader table
     rl  w0  x2+10     ;    move:
f29=k+1
     rs  w0  x3+b11    ;      reader free sem
     rl  w0  x2+12     ;
f62=k+1
     rs  w0  x3+b12    ;      reader full sem
     rl  w0  x2+6      ;
f31=k+1
     rs  w0  x3+b15    ;      virt first buffer
     rl  w0  x2+8      ;   
f32=k+1
     rs  w0  x3+b16    ;       virt top buffer
f33=k+1
     rl  w2  x3+b12    ;    w2:=tape reader full sem
     jl. w3    (b5.)   ;    lock(w2);

     am.       (b3.)   ;    ...job descr page...
f47=k+1
     al  w1    +b76    ;    w1:= psjob operation addr;
f48=k+1
     rl  w0  x3+b65    ;    move virt request line addr
     rs  w0  x1+6      ;    to operation;
     al  w0     1      ;    optype:= <remove line>;
     rs  w0  x1+2      ;

     rl. w2     b86.   ;    w2:= request que sem;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;    w2:= psjob buf;
f49=k+1
     rl  w2    +b77    ;
     jl. w3    (b5.)   ;    lock(w2);

\f



; btj 11.2.72          pstape, prepare input          read    ...54...


;   start job

     am.       (b3.)   ;    w1:= banker operation address;
f50=k+1
     al  w1    +b78    ; 
     al  w1  x1-2      ;
     al  w0     16     ;    optype:= <start job>;
     hs  w0  x1+2      ;
     rl. w2    (b20.)  ;
     rl  w2  x2+12     ;    w2:= virt of job descr page;
f53=k+1
     al  w2  x2+b79    ;    w2:= virt of dump area descr;
     rs  w2  x1+4      ;    save wirt in operation;
     rl. w2     b87.   ;    w2:= banker que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;    w2:= psjob buf;
f51=k+1
     rl  w2    +b77    ;
     jl. w3    (b5.)   ;    lock(w2);

;   initialize state, startrel and curr virt
;   continue with prepare transfer

     al  w0     0      ;
f9=k+1
     hs  w0  x3+b63    ;    start rel:= 0;
f36=k+1
     rl  w0  x3+b15    ;    current virt:=first virt
f52=k+1
     rs  w0  x3+b65    ;

     jl.        c12.   ;    goto prepare transfer;


; state 0. reserve input:
;   reserve input
;   continue in prepare transfer
f37=k+1
c9:  rl  w2  x3+b12    ;    w2:=tape reader full sem
     rl  w0  x2        ;
     se  w0     0      ;    if more input ready then
     jl.        c15.   ;    continue

;  if no more input
;  and status ok 
;  then
;  set priority of job to 0 and wait for input

     rl. w2    (b20.)  ;    w2:=current coroutine descr
f55=k+1
     rl  w0  x3+b73    ;    w0:=virt job descr page
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;    get pages

     al  w0     0      ;    priority:=0
     jl. w2     c16.   ;    set priority and update arrival
c.-314 ; *** cf. p. 47 ;    if the moon is made of green cheese then
     rl. w1     b3.    ;    begin
c91=k+1
     al  w1  x1+b78    ;      w1:=banker operation address;
     al  w1  x1-2      ;
     al  w0     17     ;      operation:= <stop job>;
     hs  w0  x1+2      ;
     rl. w2     b87.   ;      w2:=banker queue;
     jl. w3    (b7.)   ;      open chained(w1,w2);
     rl. w2     b3.    ;
f92=k+1
     al  w2  x2+b77    ;
     jl. w3    (b5.)   ;      lock(psjob buf);
z.                     ;    end;
f61=k+1
     rl  w2  x3+b12    ;    w2:=reader full sem
     jl. w3    (b5.)   ;    lock(w2)
     rl. w3     b3.    ;    w3:=job descr page
f80=k+1
     al  w1  x3+b78    ;
     al  w1  x1-2      ;    w1:=banker operation
     al  w0     15     ;
     hs  w0  x1+2      ;    operation:=set timer
     al  w2    -100    ;
     rs  w2  x1+4      ;
     rl. w2     b87.   ;    w2:=banker queue
     jl. w3    (b7.)   ;    opench(w2)
     rl. w3     b3.    ;    w3:=job descr page
f81=k+1
     rl  w2  x3+b77    ;    w2:=psjob buf
     jl. w3    (b5.)   ;    lock(w2)
     rl. w3     b3.    ;    w3:=job descr page
f82=k+1
     al  w1  x3+b78    ;
     al  w1  x1-2      ;    w1:=banker operation
     al  w0     22     ;
     hs  w0  x1+2      ;    operation:=update run left
f83=k+1
     rl  w2  x3+525    ;    w2:=total net time
     ws  w2  x1+4      ;      - net run left
     al  w3  x2        ;
     ds  w3  x1+6      ;    set time increments
     rl. w2     b87.   ;    w2:=banker queue
     jl. w3    (b7.)   ;    opench(w2)
     rl. w3     b3.    ;    w3:=job descr page
f84=k+1
     rl  w2  x3+b77    ;    w2:=psjob buf
     jl. w3    (b5.)   ;    lock(w2)
     am.       (b3.)   ;    - job descr page -
f56=k+1
     bz  w0    +524    ;    w0:=priority
     jl. w2     c16.   ;    set priority and update arrival

     jl.        c12.   ;
c15:
     jl. w3    (b5.)   ;    lock(w2);

c12: al  w0     1      ;    state := 1;
f8=k+1
     hs  w0  x3+b62    ;

; state > 0. prepare transfer:
;   get the buffer segment into core
;   lock job in core

c10: rl. w2    (b20.)  ;    page 3 descr:= curr virt
f10=k+1
     rl  w0  x3+b65    ;      of input buffer;
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;    get pages
     rl. w0    (b3.)   ;    w0:=status,result of first answer on segment
     se  w0    -1      ;    if w0 = -1  (end segment) or
     sn  w0    -2      ;       w0 = -2  (stream empty) then
     jl.        c17.   ;    goto update current virtual address
f11=k+1
     rl  w2  x3+b60    ;    lock job in core;
     jl. w3    (b5.)   ;\f


; btj 15.10.71          pstape, transfer from buffer to job          read    ...55...

; transfer characters from input buffer to job input area.

; get addresses of buffer answer and job message

     rl. w1     b3.    ;    w1:= start of input buffer;
f12=k+1
     ba  w1  x3+b62    ;    + answer rel;
     rs. w1     b45.   ;
     al  w0  x1+6      ;    w0:= start of answer
f13=k+1
     ba  w0  x3+b63    ;    + start rel;
     rs. w0     b46.   ;

     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:= message buffer address;

     rl  w1  x1+2      ;    w1:= input length:= no of bytes
f14=k+1
     bs  w1  x3+b63    ;    - start rel;
     rs. w1     b50.   ; 
     rl  w2  x2+12     ;
f72=k+1
     ws  w2  x3+b66    ;    w2:=job input area length;
     al  w2  x2+2      ;

; now w1 and w2 contains the length of the job input area
; and the rest of the super buffer part.

; if the job input area is big enough to contain all the
; input left in the superbuffer part then this is done
; otherwise only that part of the super buffer part which
; fits into the job input area is transferred and a normal status
; is generated.

     sh  w2  x1        ;    w1:=min(w1,w2);
     al  w1  x2        ;
     rs. w1     b31.   ;    no of bytes moved:=w1;

f73=k+1
     rl  w2  x3+b66    ;    w2:=next store;
     al  w3  x1        ;    w3:=no of bytes;
     rl. w1     b45.   ;    w0:= if startrel=0 then
     rl  w0  x1        ;        status from current answer
     al  w1  x1+6      ;
     se. w1    (b46.)  ;
     al  w0     0      ;        else o;   (for testoutput)
     rl. w1     b46.   ;    w1:=start abs;
\f


; btj 15.10.71          pstape, compute status          read    ...56...


b. a3  w.              ;
jd-1

a1:  al  w3  x3-2      ; move:
     sh  w3    -1      ;
     jl.        a0.    ;
     rl  w0  x1        ;
     rs  w0  x2        ;    move(no of bytes/2) words
     al  w1  x1+2      ;    from super buffer to job area;
     al  w2  x2+2      ;
     jl.        a1.    ;
                       ;....notice: at exit w1 points at the next from-word
                       ;    i.e. the status of next answer....

; the appropriate amount of characters have been transferred to
; the job input area.

; if the super buffer is emptied, answer rel and start rel are
; updated. if all the segment is emptied, the virtual buffer address
; is updated too, and the segment is free'ed.

a0:  rl. w3     b1.    ;    (w3 := start of page 1, job file page;)
f74=k+1
     rs  w2  x3+b66    ;    update next store;

     rl. w0    (b45.)  ;    w0:=status of current answer;
     rl. w2     b31.   ;
     se. w2    (b50.)  ;    status:=if buffer part is emptied then
     al  w0     1<1    ;               status from buffer
     rs. w0     b30.   ;            else  normal status;

f75=k+1
     bl  w0  x3+b63    ;
     wa. w0     b31.   ;    if buffer part is not emptied then
     se. w2    (b50.)  ;      goto update start rel;
     jl.        a3.    ;

     al  w0  x1        ;    w0:= answer rel:= addr of next from-word
     ws. w0     b3.    ;    - start of buffer;

     rl  w2  x1        ;    if next word contains 
     sh  w2    -1      ;      -1 (=end segment) or
     sh  w2    -3      ;      -2 (=stream empty) then
     jl.        a2.    ;    begin
     rs. w2     b31.   ;    save abs ref next status

c17: al  w0     512    ;      virt:= curr virt + 512;
f19=k+1
     wa  w0  x3+b65    ;
f38=k+1
     sn  w0 (x3+b16)   ;    if virt=top then
f39=k+1
     rl  w0  x3+b15    ;    virt:=first virt
f20=k+1
     rs  w0  x3+b65    ;      current virt:= virt;
f34=k+1
     rl  w2  x3+b11    ;    open(reader free)
     jl. w3    (b6.)   ;
     al  w0     0      ;      w0:= answer rel:= 0;
f21=k+1
a2:  hs  w0  x3+b62    ;    end;
     rl. w0    (b3.)   ;    w0:=status,result of first answer on segment
     se  w0    -1      ;    if w0 = -1 (= end segment) or
     sn  w0    -2      ;       w0 = -2 (= stream empty) then
     jl.        c9.    ;    goto await next input buffer
     al  w0     0      ;    w0 := 0;

a3:  hs  w0  x3+b63    ; update start rel: start rel := w0;
f18=a3+1
e.                     ;
\f


; btj 15.10.71          pstape, compute status          read    ...57...

c13: rl  w2  x3+b60    ;    open job in core;
f22=c13+1
     jl. w3    (b6.)   ;

; check whether there is more to be moved or not

     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:=message buffer address;
     rl  w0  x2+12     ;
f76=k+1
     ws  w0  x3+b66    ;

     rl. w1     b30.   ;
     rx. w0     b31.   ;    w0:=next status
     sn  w0    -2      ;    if buffer empty and no more input then
     jl.        f77.   ;    goto prepare answer
     rx. w0     b31.   ;    else reestablish w0

     sl  w0     0      ;    if (last store - next store) >= 0
     se  w1     1<1    ;       and  status = 0  then
     jl.        4      ;       goto input received
     jl.        c4.    ;       (i.e. move some more)

; prepare the answer

f77=k+1
     rs  w1  x3+b64    ;    save status on job file page;
     
f78=k+1
     rl  w0  x3+b66    ;    w0:=total no of bytes moved;
     ws  w0  x2+10     ;
     rs. w0     b31.   ;    no of bytes := w0;
     ls  w0    -1      ;
     wa. w0     b31.   ;
     rs. w0     b32.   ;    no of chars := no of bytes / 2 * 3;

; check end document status:   possibly set state := -4
f23=k+1
     rl  w0  x3+b64    ;    w0:= tape reader status;
     al  w1    -4      ;
     sz  w0     1<1    ;    if not normal answer or
     sz. w0    (b40.)  ;    if end document then
f26=k+1
     hs  w1  x3+b62    ;      state := -4;
     jl.        c1.    ;    goto normal answer;

; procedure set priority and update arrival, run left
;
; call                    return
;
; w0  priority            destroyed
; w1  irrelevant          destroyed
; w2  return              destroyed
; w3  page 1              page 1
;
b. a10 w.
c16: ws. w2     b0.    ;    w2:=rel return
     rl. w3     b3.    ;    w3:=abs job descr page
     rs  w2  x3+a0     ;    save relative return
f58=k+1
     al  w1  x3+b78    ;   
     al  w1  x1-2      ;    w1:=banker operation
     rs  w0  x1+6      ;    set priority factor
     al  w0     28     ;    
     hs  w0  x1+2      ;    optype:=priority and start
     rl. w2    (b20.)  ;    
     rl  w2  x2+12     ;    w2:=virt job descr page
f59=k+1
     al  w2  x2+b79    ;    w2:=virt dump area descr
     rs  w2  x1+4      ;
f57=k+1
     rl  w0  x3+525    ;    w0:=total net time
     rs  w0  x1+8      ;    set net run left
     dl  w3     110    ;    w2w3:=clock
     ad  w3     11     ;    w3:=now
     ws. w2     a1.    ;      - offset
     rs  w2  x1+10     ;    set arrival time
     rl. w2     b87.   ;    w2:=banker queue
     jl. w3    (b7.)   ;    opench(w2)
     rl. w3     b3.    ;    w3:=abs job descr page
f60=k+1
     rl  w2  x3+b77    ;    w2:=psjob buf
     rl  w3  x3+a0     ;    w3:=rel return
     wa. w3     b0.    ;       +abs page 0
     jl.       (b5.)   ;    lock(w2) and return

a0=4
a1:  i193              ;    arrival time offset

e.



g1=k-b0                ; length of page
h5=h4.  ; define link for initialization



i.e.                   ; end b, c, f and g-names
\f



; btj 28.10.71          psjob card input          read    ...58...


; the reader is controlled by the psjob by means of a state-logic.
;
; state:   meaning:
;
;   -8     after end job card:   as -4, but load not allowed
;   -6     online reservation not checked yet.
;          ( the first message checks the reservation, and sets
;          the state -4, if ok)
;
;   -4     reservation checked.
;          the reader is ready for load message, which sets the
;          state -2. the load message from the job causes banker-
;          reserving of the reader and sending of a load-reader-
;          line to the request display. input and sense are re-
;          turned with normal answer and end medium status.
;
;   -2     load message received.
;          the input mode is checked, and the reader corutine is
;          started. the first input-buffer page is locked, and the
;          request line is released. ( the state is set to 0).
;          ( continue with state >= 0)
;
;    0     input-buffer page not reserved.
;          the next buffer page is locked. (continue with state>= 0)
;
;  >=0     input transfer in progress.
;          the ...state... is a relative address in the input buf-
;          fer page, pointing at the answer, currently used.
;          ( when the input buffer page is emptied, the state is
;          set to 0, unless it is the end of the tape, in which
;          case the state is set to -4)


\f


; btj 15.10.71          pscard, initialization          read    ...59...

s. b100, c25, f100, g5  w.;
; external list:

b5.,  b6.,  b7.,  b8.,  b9.,  
b17., b20., b87.
f0.,  f1.,  f2.,  f4.,  f5.,  f6.,  f7.,  f8.,  f9.,  f10.
f11., f12., f13., f14., f15., f16., f18., f19., f20.
f21., f22., f23., f24., f25., f26., f27., 
f32., f33., f35.,  f40., f42., f43., f44., f46., f47., f48., f49., f50., f52., f53., f54.
f55., f56., f57., f58., f59., f60., f61., f62., f63., f64.
f65., f66., f67., f68., f71.
f72., f73., f74., f75., f76., f77., f78.

h6: h7  ; define link for initialization


; initialize page:

     al  w0     i95    ;    ...psjob card on disc...
     al  w1     g1     ;    ...length...
     jl. w3    (f1.)   ;    reserve virtual;

     al. w0     b0.    ;    ...start address...
     jl. w3    (f2.)   ;    move to virtual;
     rs. w2     f17.   ;

     jl. w3    (2)     ;    set externals;
f16:            40     ;

f17:     0  ,   444    ;    virt card input;
         g2 ,   445    ;    rel card input;
         0  ,  -1000   ;    end of externals;

     am.       (4)     ;   goto initialize tpstape
     jl.       +4      ;
     h4.               ;

; variables used in initialization:
f0:       0            ;    base of externals
f1:       12           ;    reserve virt
f2:       13           ;    move to virt
\f


; btj 15.10.71          pscard, externals and variables          read    ...60...


; definition of b-names
;
; pages and cl-entries

b0:       0            ;    page 0 code and variables
b1:       0            ;    page 1 job file page
b2:       0            ;    page 2 (not used)
b3:       0            ;    page 3 input buffer  or  job descr page
b4:       0            ;    page 4 message
           64<12+0     ; pageident:  pscard

b5:       3            ;    lock simple
b6:       4            ;    open simple
b7:       6            ;    open chained
b8:       8            ;    page jump
b9:       7            ;    get pages
;b10:      5            ;    lock chained


; semafores

;b11:      65           ;    tape reader free   job
;b12:      66           ;    tape reader full   job
;b13:      56           ;    tape reader que

;b85:      52           ;    request line free
;b86:      51           ;    request que
b87:      67           ;    banker que


; virtual addresses

;b15:      166          ;    first virt of tape reader buffer
;b16:      167          ;    top virt of tape reader buffer

f27:      320          ;    addr of return point in psjob i/o
b17:      321          ;   


; absolute addresses

b20:      26           ;    current corutine descr


; answer definitions

b30:      0            ;    answer: status
b31:      0            ;            no of bytes
b32:      0            ;            no of chars
          0            ;            no of error free chars  (temp: no of erroneous chars)
\f


; btj 15.10.71          pscard, variables          read    ...61...

; constants:

b40:      1<18         ;    end of medium in status
b43:      -1-1<2       ;    mask for clearing unwanted card-status bits
;b44:      1<0          ;    card reader included (in online bits)
;b99:      10           ;    divisor constant


; variables:

; abs addresses

b45:      0            ;    current answer(in buffer)
b46:      0            ;    start of current buffer part

; other

b50:      0            ;    length of current buffer.answer;


; relative addresses on page 1, job file page

b60=      176          ;    job sem addr
b62=      446          ;    state, and answer rel in tape reader buffer
b63=      447          ;    start rel. of current buffer.answer
b64=      449          ;    status of tape reader
b65=      448          ;    current virt addr of tape reader buffer

b66=      429          ;    next store in job input area

b67=      198          ;    state, and answer rel in card reader buffer
b68=      450          ;    start rel of current buffer.answer
b69=      200          ;    status of cardreader
b70=      199          ;    current virt addr of card reader buffer
b71=      201          ;    card length

b72=      179          ;    online bits
b73=      177          ;    job descr page
b80=      367          ;    card reader free job
b81=      368          ;     -     -    full  -
b90=      369          ;    first virt of buffer
b91=      370          ;    top    -   -    -

; relative addresses on page 3, job descr page

b74=      329          ;    job name 1
b75=      330          ;    job name 2
b76=      332          ;    psjob operation: chain
b77=      334          ;    +4             : psjob buf
b78=      348          ;    banker operation + 2
b79=      325          ;    dump area descr
b82=      371          ;    card reader queue

\f


; btj 15.10.71          pscard, entry point and central return          read    ...62...


; a message to the card reader is received
g2=k-b0
     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:=message buffer address;
     rl  w0  x2+10     ;
f71=k+1
     rs  w0  x3+b66    ;    next store := first store;
     bl  w0  x2+8      ;    w0:= operation of message;
     sn  w0     3      ;    if operation = input then
     jl.        c4.    ;    goto input message;
     se  w0     0      ;    if operation <> sense then
     jl.        c2.    ;    goto unintelligible;

; sense message received:
c7:  al  w0     0      ; init status:
     rs. w0     b31.   ;    no of chars := no of bytes := 0;
     rs. w0     b32.   ;
     rs. w0     b32.+2 ;    no of error free chars := 0;
f4=k+1
     bl  w0  x3+b67    ;    w0:= state;
     sl  w0     0      ;    if state < 0 then
     jl.        c1.    ;

     rl. w0     b40.   ;
f5=k+1
     rs  w0  x3+b69    ;    status of card reader:= end medium;

c1:  am        -2      ; normal answer:
c2:  am         1      ; unintelligible:
c3:  al  w0     2      ; rejected:   result:= 1 or 3 or 2;
f6=k+1
     rl  w1  x3+b69    ;    status.answer := status in job file descr;
     rs. w1     b30.   ;
jd-1

c0:  al. w1     b30.   ; send answer    w1:= answer address;
     am.       (b4.)   ;
     rl  w2    +4      ;    w2:= message buffer address;
     jd         1<11+22;    send answer(w0, w1, w2);

c11: ld  w2    -100    ; exit:
     am.       (b4.)   ;    mess buf addr:= 0;
     rs  w1    +4      ;

     rl. w3    (b20.)  ;    release page 3 and 4;
     ds  w2  x3+14     ;
     dl. w3     b17.   ;    page jump to psjob i/o;
     jl.       (b8.)   ;

; input message received:
c4:  bl  w1  x3+b67    ;    w1:= state;
f7=c4+1
jd-1
     sl  w1     1      ;    if state > 0 then
     jl.        c10.   ;    goto prepare transfer;
     jl.     x1+c5.    ;    goto action (state);

     jl.        c7.    ; -8:   goto init status;
     jl.        c6.    ; -6:   goto check online reservation;
     jl.        c7.    ; -4:   goto init status;
     jl.        c8.    ; -2:   goto check mode;
c5:  jl.        c9.    ;  0:   goto reserve input;
\f


; btj 15.10.71          pscard, check reservation and inputmode          read    ...63...

; state -6. check online reservation
;   continue with rejected answer or init status
c6:

     al  w0    -4      ;    state := -4;
f35=k+1
     hs  w0  x3+b67    ;
     jl.        c7.    ;    goto init status;


; state -2. check mode:
;   check mode

c8:  rl. w2    (b20.)  ;    page 3 := job descr page;
f53=k+1
     rl  w1  x3+b73    ;
     rs  w1  x2+12     ;
     jl. w3    (b9.)   ;    get pages;

     am.       (b4.)   ;    ...operation address...
     am       (+4)     ;    ...message buffer address...
     bz  w0    +9      ;    w0:= mode of message;
     sz  w0     2      ;    if ebcdic
     sz  w0     8      ;    and not decimal 
     sz  w0  (:-1:)<8+1<6+1;    or pure mark sense mode or illegal then
     jl.        c2.    ;    goto unintelligible;

     am.       (b3.)   ;    w1:= psjob operation address;
f44=k+1
     al  w1    +b76    ;
     rs  w0  x1+6      ;    save mode in operation;
     al  w0     2      ;    optype:= job controlled;
     rs  w0  x1+2      ;
     am.       (b3.)   ;
f50=k+1
     rl  w2     +b82   ;    w2:= card reader que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;
f46=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
     jl. w3    (b5.)   ;    lock(w2);

     rl. w2     b3.    ;    w2 := job descr page;
f47=k+1
     al  w1  x2+b76    ;    w1 := psjob operation address
     rl  w0  x1+2      ;
     se  w0     0      ;    if illegal mode then
     jl.        c2.    ;      goto unintelligible;
     rl  w0  x1+6      ;
f40=k+1
     hs  w0  x3+b71    ;    save card length on job file;
\f


; rc 21.6.72          pscard, prepare input          read   ...64...


;   initialize state, startrel and curr virt
;   continue with prepare transfer

     al  w0     0      ;
f9=k+1
     hs  w0  x3+b68    ;    start rel:= 0;
f48=k+1
     rl  w0  x3+b90    ;    current virt:= first virt;
f52=k+1
     rs  w0  x3+b70    ;


; state 0. reserve input:
;   reserve input
;   continue in prepare transfer

f49=k+1
c9:  rl  w2  x3+b81    ;    w2:= card reader full sem addr;
     jl. w3    (b5.)   ;    lock(w2);
     al  w0     1      ;    state := 1;
f8=k+1
     hs  w0  x3+b67    ;

; state > 0. prepare transfer:
;   get the buffer segment into core
;   lock job in core

c10: rl. w2    (b20.)  ;    page 3 descr:= curr virt
jd-1
f10=k+1
     rl  w0  x3+b70    ;      of input buffer;
     rs  w0  x2+12     ;
     
     rl. w1     b3.    ;
f61=k+1
     ba  w1  x3+b67    ;    if status of current answer = -1 then
     al  w2    -1      ;
     se  w2 (x1)       ;
     jl.        c15.   ;      begin

     rl. w2    (b20.)  ;      w2:=current coroutine;
f62=k+1
     rl  w0  x3+b73    ;      page 3 descr:= job descr page;
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;      get pages;

; stop job

     am.       (b3.)   ;      ...job descr address...
f42=k+1
     al  w1    +b78    ;
     al  w1  x1-2      ;      w1:=banker operation address;

     al  w0     17     ;      optype:=< stop job >;
     hs  w0  x1+2      ;

     rl. w2     b87.   ;      w2:=banker que sem addr;
     jl. w3    (b7.)   ;      open chained(w1, w2);

     am.       (b3.)   ;
f43=k+1
     rl  w2    +b77    ;      w2:=psjob buf;
     jl. w3    (b5.)   ;      lock(w2);
\f


; re  22.10.73         pscard, prepare input             read    ...65...


; lock ( card reader full ) ;

f72=k+1
     rl  w2  x3+b81    ;      w2:=card reader full sem addr;
     jl. w3    (b5.)   ;      lock(w2);
     al  w0     1      ;
f63=k+1
     hs  w0  x3+b67    ;      state:=1;

; start job

     rl. w2     b3.    ;      w2:=job descr page;
f64=k+1
     al  w1  x2+b78    ;
     al  w1  x1-2      ;      w1:=banker operation address;

     al  w0     16     ;      optype:=< start job >;
     hs  w0  x1+2      ;

f65=k+1
     al  w2  x2+b79    ;      w2:=virt of dump area descr;
     rs  w2  x1+4      ;      save virt in operation;

     rl. w2     b87.   ;      w2:=banker que sem addr;
     jl. w3    (b7.)   ;      open chained(w1, w2);

     am.       (b3.)   ;      w2:=psjob buf;
f66=k+1
     rl  w2    +b77    ;
     jl. w3    (b5.)   ;      lock(w2);
     al  w0     512    ;
f67=k+1
     wa  w0  x3+b70    ;      virt:=curr virt+512;
f73=k+1
     sn  w0 (x3+b91)   ;      if virt=top then
f74=k+1
     rl  w0  x3+b90    ;        virt:=first virt;
f68=k+1
     rs  w0  x3+b70    ;      current virt:=virt;
f75=k+1
     rl  w2  x3+b80    ;
     jl. w3    (b6.)   ;      open(card free);

     jl.        c10.   ;      check next answer;
                       ;      end;
c15:                   ;
f11=k+1
     rl  w2  x3+b60    ;    lock job in core;
     jl. w3    (b5.)   ;\f


; btj 15.10.71          pscard, transfer from buffer to job          read    ...66...

; transfer characters from input buffer to job input area.

b. a1  w.              ;

; get addresses of buffer answer and job message

     rl. w1     b3.    ;    w1:= start of input buffer;
f12=k+1
     ba  w1  x3+b67    ;    + answer rel;
     rs. w1     b45.   ;
     al  w0  x1+8      ;    w0:= start of answer
f13=k+1
     ba  w0  x3+b68    ;    + start rel;
     rs. w0     b46.   ;
jd-1

     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:= message buffer address;

     rl  w1  x1+2      ;    w1:= input length:= no of bytes
f14=k+1
     bs  w1  x3+b68    ;    - start rel;
     rs. w1     b50.   ; 
     rl  w0  x2+12     ;    w0:= area length - 2;
f55=k+1
     ws  w0  x3+b66    ;

; now w0 and w1 contains the length of the job input area
; and the rest of the super buffer part.

; if the job input area is big enough to contain all the
; input then this is done else only that part of the 
; super buffer which fits into the job input area is transferred
; and a normal status is generated.

jd-1

a0:  sl  w0  x1-2      ; rep: if area length < input length then
     jl.        a1.    ;
f33=k+1
     bs  w1  x3+b71    ;      input length := input length - card length
     jl.        a0.    ;      and goto rep;
a1:

     sh  w1    -1      ;    if the area length is less than the
     al  w1     0      ;      card length then input length := 0;
     rs. w1     b31.   ;    no of bytes moved:=w1;

e.                     ;
\f


; btj 15.10.71          pscard, move          read    ...67...


b. a4  w.              ;
     al  w2     0      ;
     rs. w2     b32.+2 ;    clear no of erroneous chars;
f56=k+1
     rl  w2  x3+b66    ;    w2:= addr of first to-word;
     al  w3  x1        ;
     rl. w1     b46.   ;    w1:= addr of first from-word;

jd-1

a1:  al  w3  x3-2      ; move:
     sh  w3    -1      ;
     jl.        a4.    ;
     rl  w0  x1        ;
     rs  w0  x2        ;    move(no of bytes/2) words
     al  w1  x1+2      ;    from super buffer to job area;
     al  w2  x2+2      ;
     jl.        a1.    ;
                       ;....notice: at exit w1 points at the next from-word
                       ;    i.e. the status of next answer....
\f


; rc 21.6.72          pscard, compute status          read   ...68...


; the appropriate amount of characters have been transferred to
; the job input area.

; if the super buffer is emptied, answer rel and start rel are
; updated. if all the segment is emptied, the virtual buffer address
; is updated too, and the segment is free'ed.

a4:  rl. w3     b1.    ;    (w3 := start of page 1, job file page;)
f57=k+1
     rs  w2  x3+b66    ;    update next store;

     rl. w0    (b45.)  ;    w0:=status of current answer;
     rl. w2     b31.   ;    status:=if buffer part is emptied then
     se. w2    (b50.)  ;               status from buffer
     al  w0     0      ;            else
     rs. w0     b30.   ;               normal status;

f15=k+1
     bl  w0  x3+b68    ;    w0 := start rel
     wa. w0     b31.   ;    + no of bytes;
     se. w2    (b50.)  ;    if buffer part is not emptied then
                       ;      goto update start rel;
     jl.        a3.    ;

     rl. w2     b45.   ;    w2 := addr of answer in buffer;
     rl  w0  x2+4      ;    w0:=no of chars
     ws  w0  x2+6      ;       - no of error free chars;
     rs. w0     b32.+2 ;    save in no of erroneous chars;

     ws. w1     b3.    ;    w1 := next answer rel;
     al  w0  x1        ;    w0 := answer rel := w1;
     rl. w2     b30.   ;    if end of medium
     sz. w2    (b40.)  ;
     jl.        a0.    ;     or
f32=k+1
     ba  w1  x3+b71    ;       not room enough for another answer
     sh  w1     512-8  ;      and at least one card then
     jl.        a2.    ;    begin

a0:  al  w0     512    ;      virt:= curr virt + 512;
f19=k+1
     wa  w0  x3+b70    ;
f76=k+1
     sn  w0 (x3+b91)   ;      if virt = top then
f77=k+1
     rl  w0  x3+b90    ;        virt := first virt;
f20=k+1
     rs  w0  x3+b70    ;      current virt:= virt;
f78=k+1
     rl  w2  x3+b80    ;      open(card free);
     jl. w3    (b6.)   ;
     al  w0     0      ;      w0:= answer rel:= 0;
a2:  hs  w0  x3+b67    ;    end;
f21=a2+1
     al  w0     0      ;    w0 := 0;

a3:  hs  w0  x3+b68    ; update start rel: start rel := w0;
f18=a3+1
jd-1
e.                     ;
\f


; btj 15.10.71          pscard, compute status          read    ...69...

c13: rl  w2  x3+b60    ;    open job in core;
f22=c13+1
     jl. w3    (b6.)   ;

; check whether there is more to be moved or not

     am.       (b4.)   ;    ...operation address...
     rl  w2    +4      ;    w2:=message buffer address;
     rl  w1  x2+12     ;    w1:=top store;
     al  w1  x1+2      ;
f58=k+1
     ws  w1  x3+b66    ;
     rl. w0     b30.   ;
f54=k+1
     bs  w1  x3+b71    ;    if (top store - next store) >= card length
     sl  w1     0      ;
     se  w0     0      ;       and status = 0 then
     jl.        4      ;       goto input receiced
     jl.        c4.    ;       (i.e. move some more)

; generate the answer

f59=k+1
     rs  w0  x3+b69    ;    save status on job file page;
f60=k+1
     rl  w0  x3+b66    ;
     ws  w0  x2+10     ;    w0:=total no of bytes moved;
     rs. w0     b31.   ;    no of bytes := w0;
     ls  w0    -1      ;
     wa. w0     b31.   ;
     rs. w0     b32.   ;    no of chars:= no of bytes / 2 * 3
     ws. w0     b32.+2 ;
     rs. w0     b32.+2 ;    no of error free chars:= no of chars
                       ;       - no of erroneous chars;

; check the card reader status:
;   if end of job status then
;     state := -8
;   else
;   if end of file status then
;     state := -4
; continue with normal answer

f23=k+1
     rl  w0  x3+b69    ;    w0 := card reader status;
     sz  w0     1<2    ;    if end of job then
     jl.        c12.   ;      goto end job;

     al  w1    -4      ;
     sz. w0    (b40.)  ;    if end of file then
f24=k+1
     hs  w1  x3+b67    ;      state := -4;
     jl.        c1.    ;    goto normal answer;

c12: la. w0     b43.   ; end job:
f25=k+1
     rs  w0  x3+b69    ;    clear unwanted status bits;
     al  w0    -8      ;
f26=k+1
     hs  w0  x3+b67    ;    state := -8;
     jl.        c1.    ;    goto normal answer;


g1=k-b0                ; length of page
h7=h6.  ; define link for initialization



i.e.                   ; end b, c, f and g-names
\f



; btj 28.10.71          psjob load          read    ...70...


; the reader is controlled by the psjob by means of a state-logic.
;
; state:   meaning:
;
;   -6     online reservation not checked yet.
;          ( the first message checks the reservation, and sets
;          the state -4, if ok)
;
;   -4     reservation checked.
;          the reader is ready for load message, which sets the
;          state -2. the load message from the job causes banker-
;          reserving of the reader and sending of a load-reader-
;          line to the request display. input and sense are re-
;          turned with normal answer and end medium status.
;
;   -2     load message received.
;          the input mode is checked, and the reader corutine is
;          started. the first input-buffer page is locked, and the
;          request line is released. ( the state is set to 0).
;          ( continue with state >= 0)
;
;    0     input-buffer page not reserved.
;          the next buffer page is locked. (continue with state>= 0)
;
;  >=0     input transfer in progress.
;          the ...state... is a relative address in the input buf-
;          fer page, pointing at the answer, currently used.
;          ( when the input buffer page is emptied, the state is
;          set to 0, unless it is the end of the tape, in which
;          case the state is set to -4)


\f


; btj 15.10.71          psload, initialization          read    ...71...

s. b100, c25, f100, g5  w.;
; external list:

b5.,  b6.,  b7.,  b8.,  b9.,  b10., b13.
b17., b20., b85., b86., b87.
b21., b22.
f0.,  f1.,  f2.,  f5.,  f6.,  f7.,  f8.,  f9.,  f10.
f11., f12., f13., f14., f15., f16., f17., f18., f19., f20.
f21., f22., f23., f24., f25., f26., f27., f28., f29.
f30., f31., f32., f33., f34., f35., f36., f37., f38., f39., f40.
f41., f42., f43., f44., f45., f46., f47., f48., f49., f50.
f51., f52., f53., f54., f55., f56., f57., f58., f59., f60.
f61., f62., f63., f64., f65., f66., f67., f68., f69., f70.
f71., f72., f73., f74.,       f76., f77., f78., f79. 
f80., f81., f82., f83., f84., f85.
0                      ;

; initialize page:

     al  w0     i96    ;    ...psload on disc...
     al  w1     g1     ;    ...length...
     jl. w3    (f1.)   ;    reserve virtual;

     al. w0     b0.    ;    ...start address...
     jl. w3    (f2.)   ;    move to virtual;
     rs. w2     f75.   ;

     jl. w3    (2)     ;    set externals;
f74:            40     ;

f75:     0  ,   440    ;    virt entry load;
         g3 ,   441    ;    rel entry load;
         g2 ,   437    ;    rel entry for empty files;
         0  ,  -1000   ;    end of externals;

     am.       (4)     ;   goto initialize tpscard
     jl.       +4      ;
     h6.               ;

; variables used in initialization:
f0:       0            ;    base of externals
f1:       12           ;    reserve virt
f2:       13           ;    move to virt
\f


; btj 15.10.71          psload, externals and variables          read    ...72...


; definition of b-names
;
; pages and cl-entries

b0:       0            ;    page 0 code and variables
b1:       0            ;    page 1 job file page
b2:       0            ;    page 2 (not used)
b3:       0            ;    page 3 input buffer or job descr page
b4:       0            ;    page 4 message
          65<12+0      ; pageident:  psload

b5:       3            ;    lock simple
b6:       4            ;    open simple
b7:       6            ;    open chained
b8:       8            ;    page jump
b9:       7            ;    get pages
b10:      5            ;    lock chained


; semafores
b13:      56           ;    tape reader que

b85:      52           ;    request line free
b86:      51           ;    request que
b87:      67           ;    banker que


; virtual addresses

f27:      320          ;    addr of return point in psjob i/o
b17:      321          ;   

b21:      473           ;   addr of banker kill...
b22:      364           ;


; absolute addresses

b20:      26           ;    current corutine descr


; answer definitions

b30:      0            ;    answer: status
b31:      0            ;            no of bytes
b32:      0            ;            no of chars
\f


; rc 21.6.72          psload, variables          read   ...73...



; reader operation

; constants:

b40:      1<18         ;    end of medium in status
b41:      <:car:>      ;    text constant
;b43:      -1-1<2       ;    mask for clearing unwanted card-status bits
b44:      1<0          ;    card reader included (in online bits)
b98:      32           ;    space
b99:      10           ;    divisor constant
b100: <:load :>,<:      :>; text constant
      <:  exceeded:>   ;


; variables:

; abs addresses

;b45:      0            ;    current answer(in buffer)
;b46:      0            ;    start of current buffer part

; other

;b50:      0            ;    length of current buffer.answer;
\f


; lkn 76.10.20                              read   ...73a...



; relative addresses on page 1, job file page

b60=      176          ;    job sem addr
b62=      446          ;    state, and answer rel in tape reader buffer
b63=      447          ;    start rel. of current buffer.answer
b64=      449          ;    status of tape reader
b65=      448          ;    current virt addr of tape reader buffer

b66=      429          ;    next store in job input area

b67=      198          ;    state, and answer rel in card reader buffer
b68=      450          ;    start rel of current buffer.answer
b69=      200          ;    status of cardreader
b70=      199          ;    current virt addr of card reader buffer
b71=      201          ;    card length

b72=      179          ;    online bits
b73=      177          ;    job descr page
b80=      367          ;    card reader free job
b81=      368          ;     -     -    full  -
b90=      369          ;    first virt card buffer
b91=      370          ;    top    -    -     -
b11=      518          ;    reader free sem
b12=      519          ;    reader full sem
b15=      520          ;    first virt sem
b16=      521          ;    top virt buf

; relative addresses on page 3, job descr page

b74=      329          ;    job name 1
b75=      330          ;    job name 2
b76=      332          ;    psjob operation: chain
b77=      334          ;    +4             : psjob buf
b78=      348          ;    banker operation + 2
b79=      325          ;    dump area descr
b82=      371          ;    card reader queue
b83=      148          ;    reader device no
b94=      438          ;    tape counter
b95=      439          ;    tapes

\f



; btj 22.10.71          psload, entry point          read    ...74...


; entry finis files:
;   the tape reader is emptied
;   and the card reader is emptied, i.e. until an end job card is read.
; at entry: page 1 = job descr, page 3 = job file, page 4= job descr

g2=k-b0

     rl. w2    (b20.)  ;    exchange page 1 and page 3:
     rl  w1  x2+12     ;
     rx  w1  x2+8      ;
     rs  w1  x2+12     ;
     rl. w3     b1.    ;
     rx. w3     b3.    ;
     rs. w3     b1.    ;

     al  w0    -1      ;    finis files:= true;
f53=k+1
     hs  w0  x3+b63    ;
     jl.        c1.    ;    goto empty tape reader;

; a load message is received
; find out to which device...

g3=k-b0
     am.       (b4.)   ;    ...operation address...
     am       (+4)     ;    ...message buffer address...
     rl  w0    +16     ;    w0:= first part of device name;
     se. w0    (b41.)  ;    if w0 <> <:car:> then
     jl.        c1.    ;    goto tape reader;


b. a10  w.              ;

; load card reader
; depending on the card reader state, take different actions:

c0:  rl. w3     b1.    ;
f5=k+1
     bl  w1  x3+b67    ;    if state > 0 then
jd-1
     sl  w1     1      ;    state:= 0;
     al  w1     0      ;

     jl.     x1+a1.    ;    goto action(state);
     jl.        c12.   ; state -8
     jl.        a2.    ; state -6
     jl.        a3.    ; state -4
     jl.        a4.    ; state -2
a1:  jl.        a5.    ; state  0
\f


; btj 20.8.74         psload, card reader, check reservation     read    ...75...


; state -6:
;   check reservation
;   continue with state -4
a2:  rl  w0  x3+b72    ;    w0:= online bits;
f6=a2+1
     so. w0    (b44.)  ;    if card reader not included then
     jl.        c12.   ;    goto error exit;

; state -4:
;   set buffer address, state:= -2
;   goto normal answer

f16=k+1
a3:  rl  w0  x3+b90    ;    current virt:= first virt;
f7=k+1
     rs  w0  x3+b70    ;
     al  w0    -2      ;
f8=k+1
     hs  w0  x3+b67    ;    state:= -2;
     jl.        c10.   ;    goto normal answer;

; state -2:
;   skip non-initialized file, state:= 0
;   continue with state 0

a4:  al  w0     0      ;
f9=k+1
     hs  w0  x3+b67    ;    state := 0;
     am.       (b3.)   ;
f21=k+1
     al  w1    +b76    ;    w1 := psjob operation address;
     al  w0     i118   ;
     rs  w0  x1+6      ;    mode := std mode;
     al  w0     2      ;
     rs  w0  x1+2      ;    optype := job controlled;
     am.       (b3.)   ;
f22=k+1
     rl  w2    +b82    ;    w2 := card reader queue;
     jl. w3    (b7.)   ;    open chained;

     am.       (b3.)   ;
f23=k+1
     rl  w2    +b77    ;    w2 := psjob buf;
     jl. w3    (b5.)   ;    lock(w2);

     rl. w2     b3.    ;    w2 := job descr page;
f24=k+1
     al  w1  x2+b76    ;    w1 := psjob operation;
     rl  w0  x1+2      ;
     se  w0     0      ;    if mode error then
     jl.        a10.   ;      goto end boss file;
     rl  w0  x1+6      ;
f54=k+1
     hs  w0  x3+b71    ;    card length := operation(2);
\f


; btj 22.10.71          psload, empty card file          read    ...76...


; state  0:
;   empty card file, state:= -2
;   continue with check status

a5:  rl  w0  x3+b70    ;    page 3 descr:= curr virt;
f10=a5+1
     rl. w2    (b20.)  ;
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;    get pages;
f11=k+1
     bl  w1  x3+b67    ;    w1:= relative of answer;
     se  w1     0      ;    if w1 <> 0 then
     jl.        a7.    ;    goto rep;

f25=k+1
a6:  rl  w2  x3+b81    ; get next segment:
     jl. w3    (b5.)   ;    lock(segments full);
     al  w1     0      ;    relative:= 0;

a7:  al  w2     512-8  ;    w2:= last:= 512 - length of head
f12=k+1
     bs  w2  x3+b71    ;    - card length;
a8:  wa. w1     b3.    ; rep:   w1:= addr of answer;
     rl  w0  x1        ;    w0:= status;
     sn  w0    -1      ;    if status = operator intervention then
     jl.        a0.    ;      goto next segment;
     sz. w0    (b40.)  ;    if end of document then
     jl.        a9.    ;    goto exit;

     wa  w1  x1+2      ;    w1:= relative of next answer:=
     al  w1  x1+8      ;    w1 + no of bytes + length of head
     ws. w1     b3.    ;    - start of buffer;
     sh  w1  x2        ;    if w1 <= last then
     jl.        a8.    ;    goto rep;

a0:  am         2      ;    relative:= 0 else
a9:  al  w1     -2     ; exit:   state:= -2;
f13=k+1
     hs  w1  x3+b67    ;
f14=k+1
     rs  w0  x3+b69    ;    save status in job file descr;

     rl. w2    (b20.)  ; deliver segment:
     rl  w1  x2+12     ;    curr virt:= curr virt + 512;
     al  w1  x1+512    ;
f26=k+1
     sn  w1 (x3+b91)   ;    if curr virt = top virt then
f28=k+1
     rl  w1  x3+b90    ;      curr virt := first virt;
     rs  w1  x2+12     ;
f29=k+1
     rl  w2  x3+b80    ;    w2:= segments free sem;
     jl. w3    (b6.)   ;    open(w2);
f15=k+1
     bl  w1  x3+b67    ;    w1:= relative;
     sn  w1     0      ;    if w1 = 0 then
     jl.        a6.    ;    goto get next segment;
\f


; btj 22.10.71          psload,  reservation  etc.               read    ...77...

     rl. w2    (b20.)  ;
f73=k+1
     rl  w1  x3+b73    ;
     rs  w1  x2+12     ;    page 3 := job descr page;
     jl. w3    (b9.)   ;    get pages;


; check status:

f17=k+1
     rl  w0  x3+b69    ;    w0:= card status;
     so  w0     1<2    ;    if not end of job then
     jl.        c10.   ;    goto normal answer;
     am        -2      ;    state:=-8;

a10: al  w0    -6      ; end boss file:    state:= -6;
f18=k+1
     hs  w0  x3+b67    ;

f19=k+1
     rl  w0  x3+b72    ;    w0:= online bits;
     lx. w0     b44.   ;    clear reservation;
f20=k+1
     rs  w0  x3+b72    ;

     jl.        c10.   ;    goto normal answer;

e.                     ;


b. a9  w.              ;

; load tape reader
; depending on the reader state, take different actions

c1:  bl  w1  x3+b62    ;    if state > 0 then
jd-1
f30=c1+1
     sl  w1     1      ;    state:= 0;
     al  w1     0      ;

     jl.     x1+a1.    ;    goto action(state);
     jl.        a2.    ; state -6:
     jl.        a3.    ; state -4:
     jl.        a4.    ; state -2:
a1:  jl.        a5.    ; state  0:

; state -6
;   check online reservation
;   continue with state -4

a2:  rl  w0  x3+b72    ;    w0:= online bits;
f31=a2+1
     so  w0     1<2    ;    if tape reader not online then
     jl.        c11.   ;    goto rejected answer;
\f


; re 75.06.19        psload, empty tape file        read   ...78...

; state -4 
;   state := -2
;   goto load command

a3:  al  w1    -2      ;    state := -2;
f32=k+1
     hs  w1  x3+b62    ;
     jl.        c2.    ;    goto load command;


; state -2
;   skip non-initialized file, state := 0
;   continue with state 0

a4:  jl. w2     c13.   ;    stop job;

;   get the tape reader from the banker

     am.       (b3.)   ;
f43=k+1
     al  w1    +b78    ;    w1:= operation address;
     al  w1  x1-2      ;
     al  w0     3      ;    operation:= <reserve reader>;
     hs  w0  x1+2      ;
     am.       (b3.)   ;    -  job descr page  -
     am         1      ;    rightmost byte
f82=k+1
     bz  w0    +b83    ;    w0:=job contr reader device no
     rs  w0  x1+6      ;
     al  w0     0      ;********* JOB CONTROLLED READING ONLY FROM LOCAL DEVICES
     rs  w0  x1+4      ;    set host ident in operation
     rl. w2     b87.   ;    w2:= banker que;
     jl. w3    (b7.)   ;    open chained(w1, w2);

     am.       (b3.)   ;
f44=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
     jl. w3    (b5.)   ;    lock(w2);
  
     am.       (b3.)   ;    w1:= result;
f69=k+1
     bz  w1    +b78    ;
     se  w1     0      ;    if killed then
     jl.        c4.    ;    begin
     al  w1    -6      ;      regret the load, i.e.
f70=k+1
     hs  w1  x3+b62    ;      state:= -6;

     rl. w2    (b20.)  ;
     al  w1     0      ;
     rs  w1  x2+8      ;      page 1:= 0;
     rx  w1  x2+12     ;      page 3:= 0;
     rs  w1  x2+14     ;      page 4:= job descr;
     dl. w3     b22.   ;
     jl.       (b8.)   ;      page jump(banker kill);
                       ;    end;
\f


; re 11.10.73            psload, empty tape file            read   ...79...

c4:  am.       (b3.)   ;    -  job descr page  -
f83=k+1
     al  w1    +b76    ;    w1:=abs reader operation on job descr page
     al  w0     2      ;
     rs  w0  x1+2      ;    op:=job controlled
     al  w0     4      ;
     rs  w0  x1+6      ;
     am.       (b3.)   ;    -  job descr page  -
     am         1      ;    rightmost byte
f84=k+1
     bz  w0    +b83    ;    w0:=job contr reader device no
     rs  w0  x1+14     ;    in reader operation;
f68=k+1
     rl  w0  x3+b65    ;    move virtual request line address
     rs  w0  x1+12     ;      to operation...
     rl. w2     b13.   ;    w2:= tape reader que addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);
     am.       (b3.)   ;    -  job descr page  -
     am        +4      ;
f85=k+1
     rl  w2    +b76    ;    w2:=answer sem (=reader operation + 4);
     jl. w3    (b5.)   ;    lock(w2);
f76=k+1
     rl  w2  x3+b12    ;    w2:=segments full sem
     jl. w3    (b5.)   ;    lock(w2);

     am.       (b3.)   ;    ...job descr page...
f58=k+1
     al  w1    +b76    ;    w1 := psjob operation address;
     al  w0     1      ;    optype:= <remove line>;
     rs  w0  x1+2      ;
f34=k+1
     hs  w0  x3+b62    ;    state := 1;
f59=k+1
     rl  w0  x3+b65    ;    move virt request line addrress
     rs  w0  x1+6      ;      to operation;

     rl. w2     b86.   ;    w2 := request que sem;
     jl. w3    (b7.)   ;    open chained(w1,w2);

     am.       (b3.)   ;    w2 := psjob buf;
f60=k+1
     rl  w2    +b77    ;
     jl. w3    (b5.)   ;    lock(w2);

     jl. w2     c14.   ;    start job;
f77=k+1
     rl  w0  x3+b15    ;    current virt:=first virt
f33=k+1
     rs  w0  x3+b65    ;
\f


; btj 22.10.71          psload, empty tape file          read    ...80...


; state 0
;   empty tape reader, state:= -2, continue with load command
a5:  jl. w2     c13.   ;    stop job;

f35=k+1
     rl  w0  x3+b65    ;    page 3 descr:= curr virt;
     rl. w2    (b20.)  ;
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;    get pages;

f36=k+1
     bl  w1  x3+b62    ;    w1:= relative of answer;
     se  w1     0      ;    if w1 <> 0 then
     jl.        a7.    ;    goto rep;
f78=k+1
a6:  rl  w2  x3+b12    ; get next segment
     jl. w3    (b5.)   ;    lock(segments full);
     al  w1     0      ;    relative:= 0;

a7:  wa. w1     b3.    ;    w1:= addr of answer;
a8:  rl  w0  x1        ; rep:   w0:= status;
     sz  w0     1<1    ;    if normal answer and
     sz. w0    (b40.)  ;    if end of document or end of segment then
     jl.        a9.    ;    goto exit;
     rl  w0  x1+2      ;    w0:=bytes transferred

     wa  w1  x1+2      ;    w1:= addr of next answer:=
     al  w1  x1+6      ;    w1 + no of bytes + length of head;
     se  w0     0      ;    if more than 0 bytes transferred then
     jl.        a8.    ;    goto rep;
a9:  so  w0    -2      ; exit: if status=-1 or status=-2 then rel:=0
     am        -2      ;    else state:= -2;
     al  w1     0      ;
f37=k+1
     hs  w1  x3+b62    ;
     rl. w2    (b20.)  ; deliver segment:
     rl  w1  x2+12     ;    curr virt:= curr virt + 512;
     al  w1  x1+512    ;
f79=k+1
     sn  w1 (x3+b16)   ;    if current = top virt then
f80=k+1
     rl  w1  x3+b15    ;   curr virt:=first virt
     rs  w1  x2+12     ;
f81=k+1
     rl  w2  x3+b11    ;    w2:=segments free sem
     jl. w3    (b6.)   ;    open(w2);

f39=k+1
     bl  w1  x3+b62    ;    w1:= relative;
     sn  w1     0      ;    if w1 = 0 then
     jl.        a6.    ;    goto get next segment;
     rl. w2    (b20.)  ;    page 3 := job descr page;
f72=k+1
     rl  w0  x3+b73    ;
     rs  w0  x2+12     ;
     jl. w3    (b9.)   ;
     jl. w2     c14.   ;    start job;

e.                     ;
\f


; btj 22.10.71          psload, reserve tape reader          read    ...81...


; load command, continue with send normal answer

c2:  bl  w0  x3+b63    ;    if finis files then
f38=c2+1
     sh  w0    -1      ;    goto empty card file;
     jl.        c0.    ;
\f


; btj  22.10.71          psload, assemble load-command-line          read    ...82...


b.  a10  w.             ;

;   get a request line
;   assemble a line, consisting of:
;      load <job name> <tape number>
;   deliver the line to request que as: <insert line>

c3:  rl. w2    (b20.)  ;   page3 := job descr page;
f71=k+1
     rl  w0  x3+b73    ;
     rs  w0  x2+12     ;
     rl. w2     b85.   ;    w2:= request line free sem;
     jl. w3    (b10.)  ;    lock chained(w1, w2);

     dl. w3     b100.+2;    move <:load:> and spaces
     ds  w3  x1+16     ;    to line ...
     ld  w3    -100    ;    initialize fields with nulls
     ds  w3  x1+8      ;
     ds  w3  x1+12     ;
     ds  w3  x1+28     ;
     ds  w3  x1+32     ;
     lo. w3     b98.   ;    or a space character into last position
     ds  w3  x1+44     ;

     am.       (b3.)   ;    move job name to line ...
f45=k+1
     dl  w3    +b74    ;
     ds  w3  x1+36     ;
     am.       (b3.)   ;
f46=k+1
     dl  w3    +b75    ;
     lo. w3     b98.   ;    or a space into last position
     ds  w3  x1+40     ;

     dl. w3     b100.+10;   move <:  exceeded:> to line ...
     ds  w3  x1+52     ;     ...(i.e. in case of too many tapes)...
     dl. w3     b100.+14;
     ds  w3  x1+56     ;

     al  w0  x1        ;    save operation address...

     rl. w1     b3.    ;    increase (tape counter);
f47=k+1
     bl  w3  x1+b94    ;
     al  w3  x3+1      ;
f48=k+1
     hs  w3  x1+b94    ;
f56=k+1
     bl  w2  x1+b95    ;
     sh  w3  x2        ;    if tape counter > tapes then
     jl.        a1.    ;      begin
     al  w2  x3+5      ;      tapes := tapes + 5;
f57=k+1
     hs  w2  x1+b95    ;      line length := 52
     am         8      ;      end
a1:  al  w2     44     ;    else line length := 44;
     al  w1     2      ;    line code := <insert line>;
     am        (0)     ;
     ds  w2    +4      ;
     rl  w1     0      ;    w1 := operation address;
\f


; rc 21.6.72          psload, assemble load-command-line          read   ...83...


;   convert the tape counter into numbers
a0:  al  w2     0      ; rep:   w2:= w3 mod 10;
     wd. w3     b99.   ;    w3:= w3//10;
     sn  w3     0      ;
     se  w2     0      ;    if w2 and w3 = 0 then
     al  w2  x2+48     ;    number:= 
     sh  w0  x1+2      ;      if second ciffer then space
     lo. w2     b98.   ;      else blank
     rs  w2  x1+48     ;    else number:= w2 + 48;
     al  w1  x1-2      ;    decrease(addr of last ciffer);
     se  w0  x1+8      ;    if addr <> first ciffer addr then
     jl.        a0.    ;    goto rep;

     rl  w1     0      ;    restore operation address;

     rl. w2    (b20.)  ;    w2:= curr corutine...
     rl  w0  x2+10     ;    save virt op.address in
     rl. w3     b1.    ;    current virt, in job file descr;
f49=k+1
     rs  w0  x3+b65    ;
e.                     ;
\f


; btj  22.10.71          psload, central return          read    ...84...


b. a2  w.              ;

; send normal answer and exit:

c10: am        -2      ;    action:= 3;

; send rejected answer and exit:
c11: am        -2      ;    action:= 5;

; card reader error exit:

c12: al  w3     7      ;    action:= 7;
     am.       (b1.)   ;
f52=k+1
     bl  w0    +b63    ;    if finis files then
     sl  w0     0      ;    begin
     jl.        a0.    ;      if card reader is not
     se  w3     7      ;      completely emptied then
     jl.        c0.    ;      goto empty card reader;
     al  w3     1      ;      action:= 1;
     jl.        a1.    ;      goto exit;
a0:  al  w0  x3-2      ;    end; result:= action - 2;
     se  w0     1      ;    if result <> 1 then
     al  w0     2      ;    result:= 2;

     al  w1     0      ;    status of answer:= 0;
     rs. w1     b30.   ;
     al. w1     b30.   ;    w1:= address of answer;
     am.       (b4.)   ;
     rl  w2    +4      ;    w2:= message buffer adess;
     jd         1<11+22;    send answer(w0, w1, w2);


a1:  ld  w1     65     ; exit:
     am.       (b4.)   ;    mess buf addr:= 0;
     rs  w1    +4      ;
 
     rl. w2    (b20.)  ;    release page 3;
     rs  w0  x2+12     ;
     rl  w1  x2+14     ;    w1 := page 4 descr (=job descr page...)

     sn  w3     1      ;    if action <> <empty files> then
     jl.        a2.    ;
     dl. w3     b17.   ;      goto psjob i/o;
     jl.       (b8.)   ;


a2:  rs  w1  x2+8      ;    page 1 := page 3 descr;
     am.       (b4.)   ; return finis files:
     dl  w3    +2      ;
     jl.       (b8.)   ;    return to call point;

e.                     ;

\f


; btj 06.02.72          psload, procedure stop job          read    ...85...

;   stop job

c13: ws. w2     b0.    ; procedure stop job(return in w2);
f61=k+1
     rs  w2  x3+b64    ;    save relative return...

     rl. w2    (b20.)  ;    w2:= current corutine;
f40=k+1
     rl  w0  x3+b73    ;    page 3 descr:=
     rs  w0  x2+12     ;    job descr page;
     jl. w3    (b9.)   ;    get pages;
f65=k+1
     rl  w2  x3+b64    ;
f66=k+1
     bl  w0  x3+b63    ;
     sh  w0    -1      ;
     jl.     x2+b0.    ;

     am.       (b3.)   ;    ...job descr page...
f41=k+1
     al  w1    +b78    ;    w1:= banker operation address;
     al  w1  x1-2      ;

     al  w0     17     ;    optype:= <stop job>;
     hs  w0  x1+2      ;

     rl. w2     b87.   ;    w2:= banker que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);
     am.       (b3.)   ;
f42=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
f62=k+1
     rl  w3  x3+b64    ;    w3 := absolute return address;
     al. w3  x3+b0.    ;
     jl.       (b5.)   ;    lock(w2);
\f


; rc 21.6.72          psload, procedure start job          read   ...86...


;   start job

c14:
f67=k+1
     bl  w0  x3+b63    ;    if finis files then
     sh  w0    -1      ;    return;
     jl      x2        ;

     ws. w2     b0.    ; procedure start job(return in w2);
f63=k+1
     rs  w2  x3+b64    ;    save relative return...

     am.       (b3.)   ;    ...job descr page...
f50=k+1
     al  w1    +b78    ;    w1:= banker operation address;
     al  w1  x1-2      ;

     al  w0     16     ;    optype:= <start job>;
     hs  w0  x1+2      ;
     rl. w2    (b20.)  ;    w2 := virt of job descr page...
     rl  w2  x2+12     ;
f55=k+1
     al  w2  x2+b79    ;    w2 := virt of dump area spec...
     rs  w2  x1+4      ;    save in banker operation...

     rl. w2     b87.   ;    w2:= banker que sem addr;
     jl. w3    (b7.)   ;    open chained(w1, w2);
     am.       (b3.)   ;
f51=k+1
     rl  w2    +b77    ;    w2:= psjob buf;
f64=k+1
     rl  w3  x3+b64    ;    w3 := absolute return address;
     al. w3  x3+b0.    ;
     jl.       (b5.)   ;    lock(w2);


g1=k-b0

i.
e.                     ; end b, c, f, g names
h9=s0,h10=s1  ; copy checksums into global variables
i.
e. ; end initialization block
e.e. ; end options, tread
▶EOF◀