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

⟦12b33292c⟧ TextFile

    Length: 131328 (0x20100)
    Types: TextFile
    Names: »mfpasub     «

Derivation

└─⟦9ccaf6601⟧ Bits:30008165 Bånd med SW8000 kildetekst/release værktøjer
    └─⟦2ba378e4a⟧ 
        └─⟦this⟧ »mfpasub     « 

TextFile

\f


m.                monfpasub - fpa subprocesses drivers 17.0 beta

b.i30 w.
i0=88 03 02, i1=12 00 00

; if newtime (i0,i1) > oldtime (a133,a134) then oldtime:=newtime;
c.i0-a133
  c.i0-a133-1, a133=i0, a134=i1, z.
  c.i1-a134-1,          a134=i1, z.
z.

i10=i0, i20=i1

i15=i10/100000 , i10=i10-i15*100000 , i25=i20/100000 , i20=i20-i25*100000 
i14=i10/10000  , i10=i10-i14*10000  , i24=i20/10000  , i20=i20-i24*10000 
i13=i10/1000   , i10=i10-i13*1000   , i23=i20/1000   , i20=i20-i23*1000
i12=i10/100    , i10=i10-i12*100    , i22=i20/100    , i20=i20-i22*100
i11=i10/10     , i10=i10-i11*10     , i21=i20/10     , i20=i20-i21*10

i2:  <:                              date  :>
     (:i15+48:)<16+(:i14+48:)<8+46
     (:i13+48:)<16+(:i12+48:)<8+46
     (:i11+48:)<16+(:i10+48:)<8+32

     (:i25+48:)<16+(:i24+48:)<8+46
     (:i23+48:)<16+(:i22+48:)<8+46
     (:i21+48:)<16+(:i20+48:)<8+ 0

i3:  al. w0  i2.       ; write date:
     rs  w0  x2+0      ;   first free:=start(text);
     al  w2  0         ;
     jl      x3        ;   return to slang(status ok);

     jl.     i3.       ;
e.
j.

;
; fpa-subproc
;
\f


; fpa-subproc          common procedures
; eli, 7.8.1975

; start of subprocess-code
;*************************
w.

; table of reservations
;
; the following table is used to determine, whether the sender of a
; message has to have reserved the device or just has to be a user
; of the device. 
;
; the table holds one word for each kind of subprocesses. bit(i)=1
; means, that reservation is needed for operation=i, otherwise just user is needed.

a0= 1<23

u0= 0                  ;  first subkind used

u1=k-u0

; subkind 0: general sequential device
     0                 ;

; subkind 2: not used
     0                 ;

; subkind 4: area processes
; note, that areaprocesses are checked at normal entry
     0                 ;

; subkind 6: disc
     a0>5              ; output needs reservation

; subkind 8: typewriter
     0                 ; reservation never needed

; subkind 10: paper tape reader
     -1                ; reservation always needed

; subkind 12: paper tape punch
     -1                ; reservation always needed

; subkind 14: line printer
     -1                ; reservation always needed

; subkind 16: card reader
     -1                ; reservation always needed

; subkind 18: magnetic tape
     -1                ; reservation always needed

; subkind 20: plotter
     -1                ; reservation always needed

; subkind 22: discette
     -1                ; reservation always needed
; subkind 24: character level i/o
     -1                ; reservation always needed
\f

; fpa-subproc          common procedures
; eli, 16.2.1976

;u2:                   ; see after u21.

;u3:                   ;  -    -    -
\f

; fpa-subproc          common procedures
; eli, 4.11.1975

; procedure check and link operation
;
; checks, that the sender of the message is a user or reserver of the
; device as defined by the reservation table of the corresponding
; subkind.
;
; if the subprocess represent a temporary link the calling
; process is inserted as user.
; (i.e. the user bits represents the internal processes who is 
; communicating with the link)
; for messages with operation code 3 or 5 (input or output) the field
; <updated first> in the message is initialized according to <first address> in
; the message and the addresses in the message are checked.
;
; if user or reservation is ok, the message is linked to the queue of
; the subproc.
;
; note: contrary to the standard procedure 'link operation' return is
;       always made, even if other messages exist in the queue.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.

u4:  rs. w3  j0.       ; save return
     rs. w1  j1.       ; save sub
     am      (b18)     ;
     rl  w1  +6        ; check sender :
     rl  w0  x1+a10    ; if kind(sender)= pseudo process then
     sn  w0  64        ; sender:= main (sender)
     rl  w1  x1+a50    ;
     rl. w2   j1.      ;
     rl  w0  x2+a10    ; if subproc.kind = templink then
     se  w0  p113      ; begin
     jl.     i2.      ;
     jl  w3  d126      ; includeuser(internal, subproc);
     rs. w1  j2.      ;   save internal;
     rl  w1  (b6)     ;
     jl  w3  d123     ;   remove user(procfunc, subproc);
     rl. w1  j2.      ;
i2:                   ; end;
                       ;
     rl  w2  b18       ; check operation
     rl. w3  j1.       ;
     zl  w3  x3+p10    ; 
     rl. w0  x3+u1.    ; w0:= reservation mask(subkind)
     zl  w3  x2+8      ; w3:= operation(mess)
     ls  w0  x3        ; if reservation mask(bit(operation))= 1 then
     sh  w0  -1        ; check reserver
     am  g15-g14       ;
     jl  w3  g14       ; else check user;


; access rights ok
;   w1 still holds address of internal process

     bz  w0  x2+8      ;  if operation(mes)= input or output then
     se  w0  3         ;
     sn  w0  5         ;  begin
     jl.     i0.       ;
     jl.     i1.       ;
i0:  dl  w0  x2+12     ;   make first and last address in message even
     la  w0  g50       ;
     la  w3  g50       ;
     sl  w3  (x1+a17)  ;   if first(mes)<first(internal) or
     sl  w0  (x1+a18)  ;      last(mes)>=top(internal) or
     jl      g5        ;
     sh  w0  x3-2      ;      first(mes)>last(mes) then
     jl      g5        ;   goto result 3
     ds  w0  x2+12     ;
     rs  w3  x2+22     ;   updated first(mes):= first(mes)
                       ;  end

; link message to message queue of subproc

i1:  am      (b19)     ;  w1:= addr. of message queue of subproc
     al  w1  +a54      ;
     jl  w3  d6        ;  link(w1=head,w2=elem)

c.p101 b.f1 w.         ;*****test48*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     48                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x2        ;*
     al  w1  x2+22     ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test48*****

; return

     rl  w1  b19       ;  restore subproc address
     jl.     (j0.)     ;

j0:  0                 ; saved return
j1: 0
j2:  0

e.                     ; end of check and link operation
\f

; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure get and deliver result
;
; returns an answer with a result as defined in the result-field of mainproc
; in the following way:
;
;     result4000:= result(mainproc)+1
;     deliver result(result4000)
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.

u5:                    ; get and deliver result:
     am      (x1+a50)  ;  if function(mainproc(subproc))=
     bz  w0  +p81      ;     answer message with data then
     se  w0  v55+(:1<0:); begin
     jl.     i0.       ;   copy answer content to words g20, g21, ...
     rl  w2  b18       ;   w2:= message
     rl  w0  x2+8      ;   copy status
     rs  w0  g20       ;
     dl  w1  x2+12     ;   copy rest of answer
     ds  w1  g22       ;
     dl  w1  x2+16     ;
     ds  w1  g24       ;
     rl  w1  b19       ;  end
i0:  al  w0  1         ;  result4000:= result(mainproc(subproc))+1
     am      (x1+a50)  ;
     ba  w0  +p82      ;
c.p101 b.f1 w.         ;*****test49*****
     rs. w3  f0.       ;
     jl. w3  f4.       ;
     49                ;
f0:  0                 ;
     jl.     f1.       ;
     rl  w1  g20       ;
     ds  w1  x3+2      ;
     dl  w1  g22       ;
     ds  w1  x3+6      ;
     dl  w1  g24       ;
     ds  w1  x3+10     ;
     al  w0  x3        ;
     al  w1  x3+10     ;
     jl. w3  f5.       ;
f1:                    ;
e.z.                   ;*****test49*****
     jl      g19       ;  goto deliver result(result4000)
                       ;  note: link unchanged.

e.                     ; end of get and deliver result
\f

; fpa-subproc          common procedures
; eli, 7.8.1975

; procedure prepare answer
;
; prepares the variables
;   g20  <status>
;   g21  <bytes>
;   g22  <chars>
; for sending of an answer
;
; <status> is taken from the status-field of the mainproc
; <bytes> and <chars> are calculated by the fields <first address> and
; <updated first> in the message buffer and by the field <size> in
; mainproc.
;
; the separate entry, prepare after stop, initially clears the <size> and <status> fields
; of mainproc. it may be used, when the sender is stopped thus returning
; an answer corresponding to the message only.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       undefined
; w3     link          undefined

b. i10, j10
w.

u6:  rl  w1  x1+a50    ; prepare after stop:
     al  w0  0         ;  result(mainproc):= status(mainproc):=
     rs  w0  x1+p83    ;  size(mainproc):= 0
     rs  w0  x1+p84    ;
     rl  w1  b19       ;  restore current subproc
u7:  rs. w3  j0.       ; prepare answer:
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     rl  w0  x3+p83    ;
     ls  w0  12        ;
     rs  w0  g20       ;
     rl  w0  x2+22     ;  chars:= 
     ws  w0  x2+10     ;   (updated first(mess)-first(mess))/2*3
     rl  w2  0         ;
     ls  w2  -1        ;
     wa  w2  0         ;
     wa  w2  x3+p84    ;  chars:= chars+size(main)
     rs  w2  g22       ;  save chars
     al  w1  0         ;
     wd. w2  j1.       ;  bytes:= 
     se  w1  0         ;   if chars mod 3=0 then chars/3*2 else
     al  w2  x2+1      ;                         chars/3*2 +2
     ls  w2  1         ;
     rs  w2  g21       ;  save bytes

; restore w1 to subproc and return

     rl  w1  b19       ;  w1:= current subproc
     jl.     (j0.)     ;

j0:  0                 ;  saved return
j1:  3                 ;  division constant

e.                     ; end of prepare answer
\f


; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure current message address
;
; returns the content of the message address entry corresponding
; to current bufno.
;
;        call          return
; w0     
; w1     subproc       unchanged
; w2                   even entry content 
; w3     link          unchanged

b. i10, j10
w.

u8:  bl  w2  x1+p17    ; current message entry:
     am      x2        ;
     am      x2        ;  w2:= even mes.adr(current fubno*2)
     rl  w2  x1+p19    ;
     la  w2  g50       ;
     jl      x3        ; return

e.                     ; end of current message address
\f

; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure current message entry
;
; returns the absolute address of the message address entry
; corresponding to current bufno.
;
;        call          return
; w0
; w1     subproc       unchanged
; w2                   absolute address of entry
; w3     link          unchanged

b.i10, j10
w.

u9:  bl  w2  x1+p17    ; current message entry:
     am      x2        ;
     am      x2        ;  w2:= entry address(current bufno*2)
     al  w2  x1+p19    ;
     jl      x3        ;  return

e.                     ; end of current message entry
\f

; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure increase message entry
;
; increases the field current bufno to point to the next entry,
; modulo the system constant max number of buffers.
;
;        call          return
; w0                   new bufferno
; w1     subproc       unchanged
; w2                   unchanged
; w3     link          unchanged

b. i10, j10
w.

u10:                    ; increase message entry:
     bl  w0  x1+p17    ;  current bufno(subproc):=
     ba. w0  1         ;   current bufno(subproc) + 1
     sl  w0  v0        ;   modulo max bufferno
     al  w0  0         ;
     hs  w0  x1+p17    ;
     jl      x3        ;  return

e.
\f

; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure clear message entry
;
; the entry in the message address table corresponding to bufno in
; the receiver-field of mainproc is cleared. the field free bufs in
; the subproc is increased by one.
;
;         call          return
; w0                    undefined
; w1      subproc       unchanged
; w2 
; w3      link          undefined

b. i10, j10
w.
u41:  am      p68-p88   ;  clear entry(bufno(trm)):
u11 : al  w0  p88       ;  clear entry(bufno(rec)):
      rs. w3  j0.       ;  save return ;
      wa  w0  x1+a50    ;
      zl  w3 (0)        ;  get cur buffer;
      al  w0  0         ;
      am      x3        ;
      am      x3        ;  message addr.(bufno(mainproc)*2):= 0
      rs  w0  x1+p19    ;
      al  w3  1         ;  free bufs(subproc):=
      ba  w3  x1+p16    ;   free bufs(subproc)+1
      hs  w3  x1+p16    ;
                        ;
      jl.     (j0.)     ;  return

j0:   0                 ; saved link

e.                      ; end of clear message entry
\f

; fpa-subproc          common procedures
; eli, 20.1.1976

; procedure find first message
;
; if <current message> is nonzero, this value is returned.
; otherwise the procedure continues through
; <find first unprocessed message>
;
;         call          return
; w0                    undefined
; w1      subproc       unchanged
; w2                    message or 0
; w3      link          unchanged

b. i10, j10
w.

u12:                   ; find first message:
     rl  w2  x1+p13    ;  if current message(subproc)<>0 then
     se  w2  0         ;  goto check regret
     jl.     i3.       ;

; continue through u22
\f


; fpa-subproc          common procedures
; eli, 12.8.1976

; procedure find first unprocessed message
;
; scans the messagequeue of the calling subproc and returns
; the address of the first unprocessed messagebuffer.
; 0 is returned, if no buffer is found.
;
; if a message selected has been regretted (or the sender removed)
; the message is returned and the queue scanned again.
;
; note: a processed messagebuffer has receiver(mes)<0.
;       the procedure does not change the receiver-field
;       of the message.
;       the monitor-word <current message> is set to the buffer found.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   message or 0
; w3     link          undefined


u22: rs. w3  j0.       ;  save link

; scan message queue

i0:  rl  w2  x1+a54    ; scan:
     jl.     i2.       ;  mes:= first message(subproc)
i1:  rl  w0  x2+4      ;  while receiver(mes)<0
     sl  w0  0         ;    and mes<>last message(subproc) do
     jl.     i4.       ;
     rl  w2  x2+0      ;  mes:= next(mes)
i2:  se  w2  x1+a54    ;
     jl.     i1.       ;

; no message pending in queue

     al  w2  0         ;
     jl.     (j0.)     ;  return

; w2 points to message. check regretted

i3:  rs. w3  j0.       ; check regret:  save link
i4:  rs  w2  b18       ;  current message(monitor):= mes
     rl  w0  x2+6      ;
     sl  w0  0         ;  if sender(mes)>0 then
     jl.     (j0.)     ;  return
     al  w0  0         ;
     sn  w2 (x1+p13)   ;
     rs  w0  x1+p13    ;
     al. w3  i0.       ;  no operation(mes)
     jl      g26       ;  goto scan

j0:  0                 ;

e.                     ; end of find first message
\f

; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure save and reserve message
;
; stores a message buffer address in the message entry described by
; current entry and in the current message field of the subproc.
; the message is reserved by setting the receiver-field negative,
; if it is not already so.
;
;         call          return
; w0     
; w1      subproc       unchanged
; w2      message       unchanged
; w3      link          undefined

b. i10, j10
w.

u13: ds. w3  j1.       ; save and reserve message: save message and link
     jl. w3  u9.       ;  w2:= current entry address
     rx. w2  j0.       ;  save entry:= w2
     rs. w2  (j0.)     ;  mess addr(entry):= message
     rs  w2  x1+p13    ;  current message(subproc):= message
     al  w3  -1        ;  free buffers(subproc):=
     ba  w3  x1+p16    ;    free buffers(subproc)-1
     hs  w3  x1+p16    ;
     ac  w3  (x2+4)    ;  if receiver(mes)>0 then
     sl  w3  0         ;  begin
     jl.     (j1.)     ;
     rs  w3  x2+4      ;   receiver(mes):= -receiver(mes)
     am      (b21)     ;   decrease(buffer claim(driver proc))
     bz  w3  +a19      ;
     al  w3  x3-1      ;
     am      (b21)     ;
     hs  w3  +a19      ;  end
                       ;
     jl.     (j1.)     ;  return

j0:  0                 ;  saved message
j1:  0                 ;  saved link

e.                     ; end of save and reserve message
\f

; fpa-subproc          common procedures
; eli, 8.8.1975

; procedure convert to 8-bit
;
; converts the number in w0, representing a number of 12-bit characters,
; to the corresponding number of 8-bit characters
;
;         call          return
; w0      number in 12-bits
;                       number in 8-bits
; w1   
; w2
; w3      link          undefined

b. i10, j10
w.

u14: rs. w3  j0.       ; convert to 8-bit: save link
     rl  w3  0         ;  size8:=
     ls  w3  -1        ;    size12*3/2
     wa  w0  6         ;
     jl.     (j0.)     ;  return

j0:  0                 ; saved link

e.                     ; end of convert to 8-bit
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure convert to 12-bit
;
; converts the number in w0, representing a number of 8-bit characters,
; to the corresponding number of 12-bit characters.
;
;          call          return
; w0       number in 8-bit
;                        number in 12-bit
; w1    
; w2
; w3     link          undefined

b. i10, j10
w.

u15: rs. w3  j0.       ; convert to 12-bit: save link
     al  w3  0         ;  prepare division
     wd. w0  j1.       ;  size12:= size8/3*2
     se  w3  0         ;  if size8 mod 3<>0 then
     ba. w0  1         ;  size12:= size12+2
     ls  w0  1         ;
     jl.     (j0.)     ;  return

j0:  0                 ;  saved link
j1:  3                 ;  8-bit characters per word

e.                     ; end of convert to 12-bit
\f


; fpa-subproc          common procedures
; eli, 19.8.1975

; procedure prepare addresses
;
; initializes the fields <first addr>, <data size> and <size>
; in the mainproc sender table corresponding to the next part
; of a message to be transmitted.
; if a block of size 0 is encountered, the data-bit in the func-
; tion-field is cleared.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

u16: rs. w3  j0.       ; prepare addresses: save link
     al  w3  2         ;  saved size:=
     wa  w3  x2+12     ;   last addr(mes)-updated first(mes)
     ws  w3  x2+22     ;   +2
     rl  w0  6         ;  size:= saved size

; test for maximum size exceeded

     sl  w0  (x1+p18)  ;  if size>maxsize(subproc) then
     rl  w0  x1+p18    ;     size:= maxsize(subproc)
     sl. w0  (j1.)     ;  if size>maxsize(datanet) then
     rl. w0  j1.       ;     size:= maxsize(datanet)
     se  w0  (6)       ;  if size= saved size then
     jl.     i0.       ;     comment: last block of message
     al  w3  0         ;     current message(subproc):= 0
     rs  w3  x1+p13    ;

; set first, last and size in mainproc

i0:  rl  w1  x1+a50    ;  main:= mainproc(subproc)
     rl  w3  x2+22     ;  first:= first(main):= updated first(mes)
     rs  w3  x1+p65    ;
     se  w0  0         ;  if size=0 then
     jl.     i1.       ;
     bl  w3  x1+p61    ;    databit(function(main)):= 0
     la  w3  g50       ;
     hs  w3  x1+p61    ;
i1:  jl. w3  u14.      ;  header size(main):= data size(main):=
     rs  w0  x1+p64    ;    convert to 8-bit(size)
     rs  w0  x1+p66    ;
     rs  w0  x2+20     ;  expected size(mes):= size(main)

; return

     rl  w1  b19       ;  restore subproc addr
     jl.     (j0.)     ; 

j0:  0                 ; saved link
j1:  v2                ; datanet max buffer size

e.                     ; end of prepare addresses
\f


; fpa-subproc          common procedures
; eli, 17.9.1975

; procedure test and decrease stop count
;
; upon entry w2 holds a number of an entry in the message table.
; if the entry points to a message and the stop count of
; the sender of the corresponding message has been increased (i.e.
; message entry is odd) then the stop count of the sender is decreased
; and the flag in the message table cleared.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     messageno     undefined
; w3     link          undefined

b. i10, j10
w.
v104:
u18:                   ; test and decrease stop count:
     am      x2        ;  mes:= message table(messageno*2)
     am      x2        ;
     al  w2  x1+p19    ;
     rl  w0  x2        ;
     sl  w0  (b8+4)    ;  if not possible messageaddress or
     so  w0  2.1       ;     not stop count increased(mes) then 
     jl      x3        ;  return
     rs. w3  j0.       ;  save return
     la  w0  g50       ;  stop count increased(mes):= false
     rs  w0  x2        ;
     rx  w0  b18       ;  current message(monitor):= mes
     rs. w0  j1.       ;  save old current message(monitor)
     jl  w3  g32       ;  decrease stop count
     rl  w1  b19       ;  restore subproc
     rl. w2  j1.       ;  restore current message(monitor)
     rs  w2  b18       ;

     jl.     (j0.)     ;  return

j0:  0                 ;  saved link
j1:  0                 ;  saved current message(monitor)

e.                     ; end of test and decrease stop count
\f

; fpa-subproc          common procedures
; eli, 17.9.1975

; procedure clear subproc message queue
;
; called from hostproc, when a transmission line error is detected or a
; master clear received.
;
; all messages in the queue of the subproc (processed as well as unprocessed)
; are returned with result=4 (receiver malfunction)
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.
u19:                   ; clear subproc message queue:
v100= u19              ;
     rs. w3  j0.       ;  save link
     rl  w2  b18       ;
     rs. w2  j2.       ;   save curr mess;
     al  w2  0         ;  for w2:= all entries in message table do
c.p101 b.f1 w.         ;******test50*****
     rs. w3  f0.       ;
     jl. w3  f4.       ;
     50                ;
f0:  0                 ;
     jl.     f1.       ;
     al  w0  x1        ;   testrecord:=
     al  w1  x1+p19+16 ;     process description;
     jl. w3  f5.       ;
f1:                    ;
e.z.                   ;*****test50*****
i2:  rs. w2  j1.       ;  
     jl. w3  u18.      ;   test and decrease stopcount(w2)
     rl. w2  j1.       ;
     al  w0  0         ;
     am      x2        ;  if message table(w2)<>0 then
     am      x2        ;  begin
     rx  w0  x1+p19    ;
     sn  w0  0         ;
     jl.     i3.       ;
     al  w3  1         ;   free bufs(subproc):= free bufs(subproc)+1
     ba  w3  x1+p16    ;
     hs  w3  x1+p16    ;
i3:  al  w2  x2+1      ;
     rl  w0  x1+a10    ;   if kind(sub)=hostproc kind then
     sn  w0  p111      ;     max entries:=v3
     am      v3-v0     ;   max entries:=v0;
     se  w2  v0        ;
     jl.     i2.       ;  end
     jl.     i1.       ;

; scan message queue and return answers

i0:  rs  w2  b18       ;  for mes:= first message(subproc)
     al  w0  4         ;      while mes<>last message(subproc) do
     jl  w3  g19       ;
     rl  w1  b19       ;   deliver result(4)
i1:  rl  w2  x1+a54    ;
     se  w2  x1+a54    ;
     jl.     i0.       ;
     zl  w0  x1+p10    ;  if subproc.subkind = terminal then
     se  w0     8      ;  begin
     jl.        i4.    ;     if attention message pending then
     rl  w2  x1+a71    ;     regret message
     se  w2     0      ;  end;
     jl  w3     d75    ;
i4:  al  w0  0         ;  internal state(subproc):= 0
     rs  w0  x1+p12    ;
     rs  w0  x1+p13    ;  current message(subproc):= 0
     hs  w0  x1+p17    ;  current bufno(subproc):= 0
     rl. w2  j2.       ;
     rs  w2  b18       ;   restore curr mess;

     jl.     (j0.)     ;  return

j0:  0                 ;  saved link
j1:  0                 ;  saved messageno
j2:  0                 ;   saved curr mess

e.                     ; end of clear subproc message queue
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure test answer attention
;
; called when the subproc is ready for sending a header.
;
; if the <answer attention> flag is set in the statefield of the subproc,
; mainproc will be initiated to transmit the answer. <bufno> from the
; attention message received has previously been saved in the rightmost 8
; bits of <state>.
; if an attention answer is pending the procedure will return to mainproc.
;
;        call          return
;  w0                  undefined
;  w1    subproc       unchanged
;  w2                  unchanged
;  w3    link          undefined

b. i10, j10
w.

u20:                   ; test answer attention:
     rl  w0  x1+p12    ;  if answer attention(state(subproc))=0 then
     so  w0  v71       ;  return
     jl      x3        ;
                       ;
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
c. p103-1
     al  w0  8         ; addresscode(main):= ' no check '
     hs  w0  x3+p72    ;
z.
     jl. w3  u25.      ;  set linkparams
     al  w0  v59       ;  function(main):= answer attention
     hs  w0  x3+p61    ;
     rl  w0  x1+p12    ;  bufno(main):= rightmost 8 bits
     la  w0  g53       ;   (state(subproc))
     hs  w0  x3+p68    ;
                       ;
     jl      (b101)    ;  goto mainproc return

e.                     ; end of test answer attention
\f

; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure test and increase stop count
;
; increases the stop count of the sender of a message, if it has
; not already been increased. the message must be present in the
; message table and the address in the table must bee odd if stop
; count has been increased.
;
;        call          return
;  w0                  undefined
;  w1    subproc       unchanged
;  w2    message       see below
;  w3    link          undefined
;
; if stop count could not bee increased, because the sender has been
; stopped then return will be made to <link> and the message has
; been returned (w2 is undefined).
;
; otherwise return to <link+2> (w2 is unchanged).

b. i10, j10
w.

u21:                   ; test and increase stop count:
     rs. w3  j0.       ;  save link
     al  w3  x1+p19    ;  search message table for message
     jl.     i1.       ;


i0:  al  w3  x3+2      ;
i1:  rl  w0  x3        ;  w0:= even message(message table) 
     la  w0  g50       ;
     se  w0  x2        ;
     jl.     i0.       ;

; w3 points to entry. w0 holds even message address

     lo  w0  g63       ;  set odd value in message table
     rx  w0  x3        ;
     sz  w0  2.1       ;  if stop count already increased then
     jl.     i2.       ;  goto ok-return

; examine state of sender before increase

     rs. w3  j1.       ;  save entry
     jl  w3  g34       ;  exam sender
     jl.     i3.       ; stopped: goto stop-return
     jl  w3  g31       ; ok: increase stop count

; return to <link+2>

i2:  rl. w3  j0.       ; ok-return:
     jl      x3+2      ;

; stop count could not be increased. deliver answer

i3:  al  w0  0         ;  message entry:= 0
      rs  w0  x1+p12    ;  state(subproc):= ready;
     rs. w0  (j1.)     ;  if mes=current message(subproc) then
     sn  w2  (x1+p13)  ;  current message(subproc):= 0
     rs  w0  x1+p13    ;
     al  w3  1         ;
     ba  w3  x1+p16    ;
     hs  w3  x1+p16    ;  free buffers:= free buffers+1
c.p101 b.f1 w.         ;*****test51*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     51                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x1+p11    ;*
     al  w1  x1+p19+14 ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test51*****
     jl. w3  u6.       ;  prepare answer after stop
     jl  w3  g18       ;  deliver  result(1)
     jl.     (j0.)     ;  goto <link>

j0:  0                 ;  saved link
j1:  0                 ;  saved entry

e.                     ; end of test and increase stop count
\f

; fpa-subproc          common procedures
; eli, 8.6.1977

; procedure set linkparams
;
; copies the fields devhost linkno, jobhost linkno,
; devhost host-id, devhost net-id and devhost
; home-reg to the mainproc parameters.
;
; also copies the bufferno of the link and sets the
; monitor address code to 'no check'.
;
;        call          return
;  w0                  undefined
;  w1    subproc       unchanged
;  w2                  unchanged
;  w3    link          mainproc

b. i10, j10
w.

u25:                   ; set linkparams:
     rs. w3  j0.       ;  save link
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     bz  w0  x1+p11    ;  receiver linkno(main):=
     hs  w0  x3+p69    ;   devhost linkno(subproc)
     bz  w0  x1+p9     ;  sender linkno(main):=
     hs  w0  x3+p78    ;   jobhost linkno(subproc)
     bz  w0  x1+p7     ;  receiver net-id(main):=
     hs  w0  x3+p301   ;   devhost net-id(subproc)
     bz  w0  x1+p6     ;  receiver home-reg(main):=
     hs  w0  x3+p302   ;   devhost home-reg(subproc)
     rl  w0  x1+p5     ;  receiver host-id(main):=
     rs  w0  x3+p303   ;   devhost host-id(subproc)
     bz  w0  x1+p17    ;  bufno(main):= bufno(subproc)
     hs  w0  x3+p68    ;
                       ;
     jl.     (j0.)     ;  goto return

j0:  0                 ; saved link

e.                     ; end of set linkparams
\f

; fpa-subproc          common procedures
; eli, 8.6.1977

; procedure testlink
;
; tests, that the mainproc parameters sender linkno, sender host-id
; and sender net-id are equal to the parameters devhost linkno,
; devhost host-id and devhost net-id in the subproc.
;
; if not equal, return will be made to link+0, otherwise
; to link+2.
;
;        call          return
;  w0                  undefined
;  w1    subproc       unchanged
;  w2                  mainproc
;  w3    link          unchanged

b. i10, j10
w.

u23:                   ; testlink:
     rl  w2  x1+a50    ;  main:= mainproc(subproc)
     bl  w0  x2+p98    ;  if sender linkno(main)<>
     bs  w0  x1+p11    ;     devhost linkno(subproc) then
     se  w0  0         ;  goto link+0
     jl      x3+0      ;
     rl  w0  x2+p323   ;  if sender host-id(main)<>
     se  w0  (x1+p5)   ;     devhost host-id(subproc) then
     jl      x3+0      ;  goto link+0
     bl  w0  x2+p321   ;  if sender net-id(main)<>
     bs  w0  x1+p7     ;     devhost net-id(subproc) then
;    se  w0  0         ;  goto link+0
;    jl      x3+0      ;
     jl      x3+2      ;  goto link+2

e.                     ; end of testlink
\f

; fpa-subproc          common procedures
; eli, 8.6.1977

; procedure reject
;
; sets the internal status of mainproc to 'reject'
; and jumps to testmore
;
;        call          no return
;  w0
;  w1    subproc
;  w2
;  w3

b. i10, j10
w.

u24:                   ; reject:
     al  w0  p163      ;  internal status(mainproc(subproc):=
     am      (x1+a50)  ;  reject
     hs  w0  +p80      ;
     jl.     u2.       ;  goto testmore

e.                     ; end of reject
\f

; fpa-subproc          common procedures
; eli, 7.8.1975

; testmore
;
; entered, when the subproc-state should be tested for more messages to
; process.
;
; if the state of the subproc is free, and more messages to process exist
; the subproc is linked to the mainproc.
;
; return is made through the common return.
;
; upon entry:
;
;  w0    
;  w1
;  w2   
;  w3
;  b19    subproc

b.i10, j10
w.

u2:                    ; testmore:
     rl  w1  b19       ;  get current subproc
c.p101 b.f1 w.         ;*****test52*****
     rs. w3  f0.       ;
     jl. w3  f4.       ;
     52                ;
f0:  0                 ;
     jl.     f1.       ;
     al  w0  x1        ;   testrecord:=  
     al  w1  x1+p19+16 ;     process description;
     jl. w3  f5.       ;
f1:                    ;
e.z.                   ;*****test52*****
     rl  w0  x1+p14    ;  if in mainproc queue then
     se  w0  x1+p14    ;  
     jl      (b101)    ;  return

; test answers to transmit

     rl  w0  x1+p12    ;
c.p101 b.f1 w.         ;*****test53*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     53                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x3        ;*
     al  w1  x3-2      ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test53*****
     sz  w0  v71       ;  if answer att<>0 then
     jl.     i0.       ;  goto link subproc

; test message entry free and number of buffers free

     jl. w3  u8.       ;  if mess.addr.(cur.entry)<>0
     bl  w0  x1+p16    ;
c.p101 b.f1 w.         ;*****test54*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     54                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x3        ;*
     al  w1  x3-2      ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test54*****
     sn  w2  0         ;  or bufs free=0 then
     sn  w0  0         ;
     jl      (b101)    ;  goto return

; test for a current message or more messages to process

     rl  w0  x1+p12    ;
     sz  w0  v70       ;  if blocked(subproc) then
     jl      (b101)    ;  goto mainproc return
     sz  w0  v72       ;  if pending messages(subproc)<>0 then
     jl.     i0.       ;  goto link subproc
     jl. w3  u12.      ;  if next pending=0 then
c.p101 b.f1 w.         ;*****test55*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     55                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x3        ;*
     al  w1  x3-2      ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test55*****
     sn  w2  0         ;
     jl      (b101)    ;  goto return

; a message or answer is pending
; link subproc to the corresponding mainproc
;
; note: the buffer is not reserved for the subproc and the bufferaddress
;       not saved until processing actually starts.

i0:                    ; link subproc:
     al  w2  x1+p14    ;  elem:= queue elem(subproc)
     am      (x1+a50)  ;  head:= queue head(mainproc(subproc))
     al  w1  +p14      ;
     jl  w3  d6        ;  link(head,elem)

; mainproc will later activate the subproc

     jl    (b101)      ;  goto return

e.                     ; end of testmore
\f

; fpa-subproc          common procedures
; eli, 7.8.1975

; procedure no block
;
; signals a 'nothing to do' status to mainproc,
; clears busy and returns to mainproc
;
;        call          no return
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

u3:  al  w0  p164      ; no block:
     am      (x1+a50)  ;  internal state(mainproc):=
     hs  w0  +p60      ;    'nothing to do' (i.e. regretted)
     jl.     u2.       ;  goto testmore

e.                     ; end of no block
\f


; fpa-subproc          stepping stones
; eli, 77.06.14

c. p101

     jl.     f4.       ;
f4=k-2

     jl.     f5.       ;
f5=k-2

     jl.     f6.       ;
f6=k-2

z.

     jl.     u4.       ;
u4=k-2

     jl.     u8.       ;
u8=k-2

     jl.     u12.      ;
u12=k-2

     jl.     u15.      ;
u15=k-2
\f

; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure prepare transfer
;
; saves the message address for the subproc and then
; prepares transmission of a header (and maybe a datablock)
; depending on the operation-field in the message.
; finally the standard parameters in mainproc corresponding to
; the subproc are set.
;
; note, that only the operations <input>, <output> or <message>
;       may be handled.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

u30:                   ; prepare transfer:
     rs. w3  j0.       ;  save link
     jl. w3  u13.      ;  save and reserve message
     al. w3  i0.       ;  link:= after prepare

; switch to procedure, corresponding to operation

     bl  w0  x2+8      ;  op:= operation(mes)
     sn  w0  3         ;  if op=input then
     jl.     u31.      ;     goto prepare input
     sn  w0  5         ;  if op=output then
     jl.     u32.      ;     goto prepare output
     jl.     u33.      ;  goto prepare message

; return is made to here from all subroutine calls.
; set rest of parameters

i0:  rl  w3  x1+a50    ;  main:= mainproc(subproc)
     bz  w0  x1+a56+1  ;  s:= initialize state(subproc)
     se  w0  1         ;  state(main):= if s=1 then s else 0
     al  w0  0         ;
     hs  w0  x3+p62    ;
     al  w0  0         ;  initialize state(subproc):=0
     hs  w0  x1+a56+1  ;
     bz  w0  x2+9      ;  mode(main):= mode(mes)
     rs  w0  x3+p63    ;
     jl. w3  u25.      ;  set linkparams
     rl  w0  x1+p13    ;   if current message(subproc)<>0 then
     sn  w0  0         ;     blocked(subproc):=true;
     jl.     i1.       ;
     al  w0  v70       ;
     lo  w0  x1+p12    ;
     rs  w0  x1+p12    ;
i1:                    ;
c.p101 b.f1 w.         ;*****test56*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     56                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x2        ;*
     al  w1  x2+22     ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test56*****

; return

     jl.     (j0.)     ;

j0:  0                 ;  saved link

e.                     ; end of prepare transfer
\f

; fpa-subproc          common procedures
; eli, 19.8.1975

; procedure prepare input
;
; prepares transmission of a header corresponding to an input-
; message. the <size>-field of the header shows how many characters
; should be input.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.
u31:                   ; prepare input:
     rs. w3  j0.       ;  save link
     jl. w3  u16.      ;  prepare addresses
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     al  w0  v50       ;  function(main):= input
     hs  w0  x3+p61    ;
     al  w0  0         ;  data size(main):= 0
     rs  w0  x3+p66    ;
     jl.     (j0.)     ;  goto link

j0:  0                 ; saved link

e.                     ; end of prepare input
\f

; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure prepare output
;
; prepares the transmission of a header corresponding to an
; output-message. the addresses in the sender table of mainproc
; are initialized corresponding to a datablock, which is to
; be transmitted following the header.
; if the sender of the message is stopped, an answer is 
; generated showing the number of bytes and characters output
; until now.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

u32: rs. w3  j0.       ; prepare output: save link

; examine state of sender

     jl. w3  u21.      ;  test and increase stop count
     jl.     u3.       ; stopped: goto no block

; sender still running
     rl  w3  x1+a50    ; main:= main(subproc)
     al  w0  v52+(:1<0:); function(main):=
     hs  w0  x3+p61    ; output+databit
c. p103-1
     al  w0  0         ; addresscode(main):=
     hs  w0  x3+p72    ; sender area
     rs  w2  x3+p71    ; messagebuf(main):= message;
z.
     jl. w3  u16.      ;  prepare addresses
     jl.     (j0.)     ;  goto link

j0:  0                 ;  saved link

e.                     ; end of prepare output
\f

; fpa-subproc          common procedures
; eli, 19.8.1975

; procedure prepare message
;
; prepares transmission of a header , followed by the content of
; the messagebuffer (only the user part is transmitted).
; the field <current message> in the subproc is cleared.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          mainproc

b. i10, j10
w.

u33: rs. w3  j0.       ; prepare message: save link
     al  w0  0         ;  current message(subproc):= 0
     rs  w0  x1+p13    ;
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     al  w0  x2+8      ;  first(main):= first user addr(mes)
     rs  w0  x3+p65    ;
     al  w0  (:22-8+2:)/2*3; header size(main):= data size(main):=
     rs  w0  x3+p64    ;    size of user part(mes)
     rs  w0  x3+p66    ;
     al  w0  v54+(:1<0:); function(mainproc):= message+databit
     hs  w0  x3+p61    ;
c. p103-1
     al  w0  8         ;
     hs  w0  x3+p72    ;
z.

; return

     jl.     (j0.)     ;  

j0:  0                 ; saved link

e.                     ; end of prepare message
\f

; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure test header and data transmitted
;
; tests the result of transmission of a header and (maybe)
; a datablock.
; if the <stop count increased>-flag is set, the stop count
; of the sender of current message is decreased.
; if a transmission error has occured, the message is returned
; with result=4 (receiver malfunction) and the <current message>-
; field cleared. return will then be made to <link+0>.
;
; if no error has occured, <current bufno> is
; increased and return made to <link+2>.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.

u40:                   ; test header and data transmitted:
     rs. w3  j0.       ;  save link
     rl  w3  x1+a50    ;  if function type(main(subproc))=answer then
     bz  w0  x3+p61    ;
     sz  w0  2.10      ;
     jl.     i1.       ;  goto after answer attention
     jl. w3  u8.       ;  <current buffer>:= w2:=
     rs  w2  b18       ;  message
     bl  w2  x1+p17    ;  get messageno
     sz  w0  2.1       ;  if databit(function)=1 then
     jl. w3  u18.      ;  test and decrease stop count
     rl  w2  b18       ;

; test transmission state

     am      (x1+a50)  ;  if internal state(mainproc(subproc))<>0 then
     bl  w0  +p60      ;  begin
     sn  w0  0         ;
     jl.     i0.       ;  

; transmission trouble

     sl  w2  (b8+4)    ;  if message addr>=first message then
     jl.     +4        ;  begin
     jl.     i2.       ;
                       ;
     se  w0  p161      ;   if state<>1 then
     al  w2  0         ;   mes:= 0
     rs  w2  x1+p13    ;   comment: state=1 after wait;
     bl  w2  x1+p17    ;   get messageno;
     jl. w3  u18.      ;   test and decrease stopcount;
     rl  w2  x1+p13    ;   mes:= current message(subproc);
     al  w0  4         ;   current message(subproc):= mes
     sn  w2  0         ;   if mes=0 then
     jl  w3  g19       ;   deliver result(4)
i2:  al  w0  -1-v70    ;  end
     la  w0  x1+p12    ;  blocked(subproc):= false
     rs  w0  x1+p12    ;
c.p101 b. f1 w.        ;*****test57*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     57                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     rl  w2  b18       ;*
     al  w0  x2        ;*
     al  w1  x2+22     ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test57*****
     al  w0  0         ;
     jl. w3  u9.       ;   message addr(current entry):= 0 
     rs  w0  x2        ;
     al  w0  1         ;   increase(free buffers(subproc))
     ba  w0  x1+p16    ;
     hs  w0  x1+p16    ;
     jl.     (j0.)     ;   goto link+0
                       ;  end

; transmission ok.

i0:                    ;
c.p101 b.f1 w.         ;*****test58*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     58                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     rs  w2  x3        ;*
     rl  w2  x1+p13    ;*
     rs  w2  x3+2      ;*
     al  w0  x3        ;*
     al  w1  x3+2      ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test58*****
     jl. w3  u10.      ;  increase(current entry(subproc))

; return

     jl.     i3.       ;  goto link+2

; answer attention has been transmitted

i1:  bz  w3  x3+p60    ; after answer attention:
c.p101 b.f1 w.         ;*****test59*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     59                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     rs  w0  x3        ;*
     al  w0  x3        ;*
     al  w1  x3        ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test59*****
     al  w0  -1-v71    ;  if internal state(main)=0 then
     la  w0  x1+p12    ;
     sn  w3  0         ;
     rs  w0  x1+p12    ;  answer attention flag(subproc):= false
i3:  rl. w3  j0.       ;  goto link+2
     jl      x3+2      ;

j0:  0                 ;  saved link

e.                     ; end of test header and data transmitted
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure test answer header
;
; called when a header, which is going to be followed by a datablock has
; been received.
; in the current version only answers to previously transmitted messages
; may be handled.
; functions may be <answer input> or <answer message>.
; the bufno in the answer is used to find the message table entry.
;   depending on the value in the entry, the following is performed:
;
; message entry:
;
;   0       the message has been returned due to line errors. a reject
;           status is returned on the communication line. return
;           will be made to testmore.
;   impossible message address: signals a special function for the
;           subproc. return to <link+2>.
;   normal message address: procedure corresponding to function is
;           activated. if the datablock can be received return is
;           made to mainproc. otherwise a skip-status is signalled
;           and return made to <link>.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b.i10, j10
w.

u50:                   ; test header:
     rs. w3  j0.       ;  save link
     jl. w3  u23.      ;  testlink
     jl.     u24.      ; error: goto reject
     rl. w3  j0.       ;  restore link
     al  w0  p160      ;
     hs  w0  x2+p80    ;  skip(main):= false
     bz  w0  x2+p81    ;  func:= function(main)
     bz  w2  x2+p88    ;  mes:= even message table(bufno(main))
     am      x2        ;
     am      x2        ;
     rl  w2  x1+p19    ;
c.p101 b.f1 w.         ;*****test60*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     60                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x2        ;*
     al  w1  x2+22     ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test60*****
     la  w2  g50       ;
     sl  w2  (b8+4)    ;  if mes<first message then
     jl.     i0.       ;  begin
     sn  w2  0         ;  if mes=0 then
     jl.     u24.      ;  goto reject
c.p101 b.f1 w.         ;*****test61*****
     rs. w3  f0.       ;
     jl. w3  f4.       ;*
     61                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x1+p19    ;*
     al  w1  x1+p19+14 ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test61*****
     jl      x3+2      ;   goto <link+2>
                       ;  end
i0:  rs  w2  b18       ;  current message(monitor):= mes
     am      (x1+a50)  ;  if local function(rec)=
     bz  w3  +p99      ;     rejected packet then
     se  w3  3         ;  begin comment: deliver answer malfunction;
     jl.     i1.       ;
     am      (x1+a50)  ;   w2:= bufno(rec)
     bz  w2  +p88      ;
     jl. w3  u18.      ;   test and decrease stopcount
     jl. w3  u11.      ;   clear message entry
     al  w0  4      ;
     jl  w3  g19       ;   deliver result(4)
     al  w0  p162      ;   internal status(main):= skip
     am      (x1+a50)  ;
     hs  w0  +p80      ;
     jl.     u2.       ;   goto testmore
i1:  rl. w3  j0.       ;  end

; switch to action

     sn  w0  v51+(:1<0:);  if function= <answer input with data> then
     jl.     u51.      ;     goto test answer input
     jl.     u53.      ;   goto test answer message

j0:  0                 ; saved link

e.                     ; end of test answer header
\f


; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure test answer input header
;
; called, when a header with function=<answer input with data> has been
; received.
; the state of the receiving process
; is checked.  if it is still running, the mainproc parameters
; are initialized and the procedure returns to mainproc.
;
; if the receiver is stopped an answer is returned and a skip-status signalled
; to mainproc.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       undefined
; w3     link          undefined

b. i10, j10
w.

u51:                   ; test answer input header:
     rs. w3  j0.       ;  save link

; examine state of receiving process

     jl. w3  u21.      ;  test and increase stop count
     jl.     i0.       ; stopped: goto skip 

; sender still running

     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     rl  w0  x2+22     ;  first(main):= updated first(mes)
     rs  w0  x3+p85    ;
     rl  w0  x3+p84    ;  
     rs  w0  x3+p86    ;  data size(main):= header size(main)
c. p103-1
     al  w0  0         ; addres code(main):=
     hs  w0  x3+p92    ; sender area
     rs  w2  x3+p91    ; messagebuf(main):= message
z.

; return to mainproc, which will then receive the datablock

     jl      (b101)    ;  goto mainproc return

; receiver of databuffer stopped

i0:  al  w0  p162      ; skip:  signal skip-status to mainproc
     am      (x1+a50)  ;
     hs  w0  +p80      ;
     al  w0  0         ;
     rs  w0  x1+p12    ;   state(proc):=0;

; return

     jl.     (j0.)     ;

j0:  0                 ;  saved link

e.                     ; end of test answer input header
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure test answer message header
;
; called when a header with function=<answer message with data> has been 
; received.
; the parameters in mainproc are initiated to receive the answer.
; return will always be made to mainproc.
;
; note, that it is not necessary to check the running status
;       of the receiver, as the datablock is received directly
;       in the messagebuffer area in the monitor.
;
;        call          no return
; w0
; w1     subproc
; w2     message
; w3

b. i10, j10
w.

u53:                   ; test answer message header: 
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     al  w0  x2+8      ;  first(main):= first user word(mes)
     rs  w0  x3+p85    ;  
     al  w0  (:22-8+2:)/2*3;  data size(main):=
     rs  w0  x3+p86    ;  size of user part(mes)
     al  w0  8         ;  address code(main):= dirty
     hs  w0  x3+p92    ;
c. p103-1
     al  w0  0         ;
     rs  w0  x3+p91    ;
z.
     jl      (b101)    ;  return to mainproc

e.                     ; end of test answer message header
\f


; fpa-subproc          common procedures
; eli, 11.2.1976

; procedure test answer data received
;
; a header without a datablock, or the datablock following a header has
; been received.
; if stop count has been increased (answer input) it is decreased.
;
; if the function field of the header corresponds to a message received
; (attention) return will be made to <link+2>.
;
; if the message table of the entry corresponding to the bufno in the
; answer does not describe a message (value to small) return will be made
; to <link+4>. in this case w2 will hold the content of the message table entry.
;
; otherwise the procedure, corresponding to the mainproc <function>-
; field is activated and return made to <link>.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined (see above for return to <link+4>
; w3     link          undefined

b. i10, j10
w.

u60:                   ; test answer data received:
     rl  w2  x1+a50    ;  if function(mainproc(subproc))=attention then
     bz  w0  x2+p81    ;
     sn  w0  v58       ;
     jl.     u64.      ;  goto attention received.
                       ;  note: link unchanged. will return to <link+2>
     rs. w3  j0.       ;  save link
     sz  w0  2.1       ;  if no data then
     jl.     i2.       ;  begin
     jl. w3  u23.      ;   testlink
     jl.     u24.      ; error: goto reject
                       ;  end
i2:  bz  w2  x2+p88    ;  mes:= even message addr(bufno(mainproc(subproc)))
     am      x2        ;
     am      x2        ;
     rl  w3  x1+p19    ;
     la  w3  g50       ;
     sn  w3  0         ;  if mes=0 then
     jl.     u24.      ;  goto reject
     rs  w3  b18       ;  current message(monitor):= mes
     jl. w3  u18.      ;  test and decrease stopcount(w2=messageno)
     rl  w2  b18       ;  restore message
     jl. w3  u11.      ;  clear message entry
     al  w0  -1-v70    ;   blocked(subproc):=false;
     la  w0  x1+p12    ;
     rs  w0  x1+p12    ;
     sl  w2  (b8+4)    ;  if mes<first message buffer then
     jl.     i0.       ;
     rl. w3  j0.       ;   goto <link+4>
     jl      x3+4      ;  

; switch to action
i0:  rl  w3  x1+a50    ;
     bz  w0  x3+p99    ;  if local function(rec)=
     se  w0  3         ;     rejected packet then
     jl.     i1.       ;  begin
     al  w0  0         ; if mess=cur mess then
     sn  w2  (x1+p13)  ; cur mess=0
     rs  w0  x1+p13    ;
     al  w0  4         ;
     jl  w3  g19       ;   deliver result(4)
     jl.     u2.       ;   goto testmore
i1:                    ;  end
     bz  w0  x3+p81    ;  w0:= function(mainproc(subproc))
     la  w0  g50       ;  remove databit
     rl. w3  j0.       ;  link:= saved link
     sn  w0  v51       ;  if function=<answer input> then
     jl.     u61.      ;    goto answer input data received 
     sn  w0  v53       ;  if function=<answer output> then
     jl.     u62.      ;    goto test answer output header
     jl.     u63.      ;  goto test answer message data

j0:  0                 ;  saved link

e.                     ; end of test answer data received
\f


; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure answer input data received
;
; called, when the datablock following a header with <function>=
; <answer input (with or without data)> has been received.
;
; if the message is not current message, if a result- or status error
; is detected or if less than wanted is input, an answer with result=1
; is generated. otherwise the next block may be input.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

u61:                   ; answer input data received:
     rs. w3  j0.       ;  save link
     se  w2  (x1+p13)  ;  if mes=current message(subproc) then
     jl.     i1.       ;  begin
     rl  w3  x1+a50    ;   main:= mainproc(subproc)
     rl  w0  x3+p84    ;   
     zl  w3  x3+p82    ;      
     am      (x1+a50)  ;
     wa  w3  +p83      ;
     sn  w3  0         ;   if result(main)=status(main)=0 or
     sn  w0  0         ; size(main) = 0 then
     jl.     i0.       ;   begin
     jl. w3  u15.      ;    updated first(mes):=
     wa  w0  x2+22     ;      updated first(mes)+ convert to 12-bit(header size(main))
     rs  w0  x2+22     ;
     jl.     (j0.)     ;    goto return
                       ;   end result ok

; after some error in current message

i0:  al  w0  0         ;   current message(subproc):= 0
     rs  w0  x1+p13    ;  end current message

; not current message
                       ;  else
i1:  jl. w3  u7.       ;  prepare answer
     rl. w3  j0.       ;  link:= saved link
     jl.     u5.       ;  goto get and deliver result

j0:  0                 ;  saved link

e.                     ; end of answer input data received
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure test answer output 
;
; test the parameters in a header corresponding to function
; =answer output.
; if the following conditions:
;
;   -the corresponding message is <current message>
;   -the result is ok (=0)
;   -the status is ok (=0)
;   -the whole block has been output
; a transfer of next part is prepared.
;
; otherwise an answer is generated
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       undefined
; w3     link          undefined

b. i10,j10
w.
u62:                   ; test answer output header:
     rs. w3  j0.       ;  save link
     se  w2  (x1+p13)  ;  if mes=current message(subproc) then
     jl.     i1.       ;  begin
     rl  w3  x1+a50    ;   main:= mainproc(subproc)
     rl  w0  x3+p84    ;   if size(main)=expected size(mes)
     bl  w3  x3+p82    ;     and
     am      (x1+a50)  ;
     wa  w3  +p83      ;
c.p101 b.f1 w.         ;*****test62*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     62                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     rs  w0  x3        ;*
     rs  w1  x3+2      ;*
     rs  w2  x3+4      ;*
     rl. w0  f0.       ;*
     rs  w0  x3+6      ;*
     al  w0  x3        ;*
     al  w1  x3+6      ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test62*****
     sn  w3  0         ;
     se  w0  (x2+20)   ;      result(main)=status(main)=0 then
     jl.     i0.       ;   begin
     jl. w3  u15.      ;    updated first(mes):=
     wa  w0  x2+22     ;      updated first(mes)+convert to 12-bit(size(main)
     rs  w0  x2+22     ;
     jl.     (j0.)     ;    goto return
                       ;   end result ok

; after an error in current message

i0:  al  w3  0         ;   current message(subproc):= 0
     rs  w3  x1+p13    ;  end current message

; not current message
i1:                    ;
c.p101 b.f1 w.         ;*****test63*****
     rs. w3  f0.       ;*
     jl. w3  f4.       ;*
     63                ;*
f0:  0                 ;*
     jl.     f1.       ;*
     al  w0  x2        ;*
     al  w1  x2+22     ;*
     jl. w3  f5.       ;*
f1:                    ;*
e.z.                   ;*****test63*****

     jl. w3  u7.       ;  prepare answer
     jl. w3  u5.       ;  get and deliver result
     jl.     (j0.)     ;  goto return

j0:  0                 ;  saved link

e.                     ; end of test answer output header
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure answer message data received
;
; the datablock holding the answer of a message has been received.
; 
; the message is returned as an answer, with result and status as
; defined in the preceding header. the other fields in the answer
; are taken from the datablock (if any).
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

u63: am      (x1+a50)  ; answer message data received: status(mess):=
     rl  w0  +p83      ;
     ls  w0  4         ;  status(mon):= status(mes):=
     sz. w0  (j0.)     ;  status(main)<12+
     ba. w0  1         ;  if stopped bit then 1<8
     ls  w0  8         ;
     rs  w0  g20       ;
     rs  w0  x2+8      ;
     al  w0  0         ;
     rs  w0  g21       ;  bytes:= chars:= 0
     rs  w0  g22       ;
     hs  w0  x2+9      ;

; note: link unchanged

     jl.     u5.       ;  goto get and deliver result

j0:  (:1<12:)<4        ;  stopped bit in main status<4

e.                     ; end of answer message data received
\f

; fpa-subproc          common procedures
; eli, 15.1.1976

; procedure attention received
;
; a header with function equal to a message type (i.e. attention) has
; been received.
; the answer attention-flag is set and the bufferno saved in the
; state field of the subproc.
;
; return will be made to <link+2>.
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.

u64:                   ; attention received:
     al  w3  x3+2      ;  save link+2
     rs. w3  j0.       ;
     jl. w3  u23.      ;  testlink
     jl.     u24.      ; error: goto reject
     al  w0  v71       ;  w0:= answer attention flag+bufferno(main)
     bz  w2  x2+p88    ;
     la  w2  g53       ;  keep only last 8 bits of bufno
     lo  w0  4         ;
     lo  w0  x1+p12    ;  save in state(subproc)
     rs  w0  x1+p12    ;
     jl.     (j0.)     ;  goto link+2

j0:  0                 ; saved link+2

e.                     ; end of attention received
  
; stepping stones:
     jl.     u3.   , u3 =k-2
     jl.     u4.   , u4 =k-2
     jl.     u12.  , u12=k-2
     jl.     u20.  , u20=k-2
     jl.      u21.   , u21=k-2
     jl.     u30.  , u30=k-2
     jl.     u50.  , u50=k-2
     jl.     u14.  , u14=k-2
\f


; fpa-subproc          standard types
; eli, 16.12.1975

b. q20, s10
w.

; this code handles standard sequential devices with no special
; actions, such as:
;
;     paper tape reader
;     paper tape punch
;     line printer
;     card reader
; etc.

m.                standard links

; entry point table:
h100:                  ; general sequential device
h110:                  ; paper tape reader
h112:                  ; paper tape punch
h114:                  ; line printer
h116:                  ; card reader
h120:                  ; plotter:

             q0        ;  after send message
             q1        ;  before header transmit
             q2        ;  after header transmit
             q3        ;  after header received
             q4        ;  after data received
             q5        ;  after creation

; no structure of private part of process description required
\f

; fpa-subproc          standard types
; eli, 4.11.1975

; after send message 
;
; a new message has been received. check that user- or reservation
; status is ok and link message to queue of subproc.
; if the subproc is not busy, then link it to mainproc.
; 
; upon entry:
; w0
; w1     subproc
; w2  
; w3     

b. i10, j10
w.
q0:                    ; after send message:
     jl. w3  u4.       ;  check and link operation
     jl.     u2.       ;  goto testmore

e.                     ; end of after send message
\f

; fpa-subproc          standard types
; eli, 21.8.1975

; before header
;
; a header (and maybe a corresponding datablock) is to be transmitted.
; find first non-processed message in queue of subproc and initialize
; transmit-parameters in mainproc.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.
q1:                    ; before header:
     jl. w3  u20.      ;  test answer attention
     jl. w3  u12.      ;  w2:=mes:= first pending message
     sn  w2  0         ;  if mes=0 then
     jl.     u3.       ;   goto no block.

; message found. initiate transfer

     jl. w3  u30.      ;  prepare transfer
     jl      (b101)    ;  goto mainproc return

e.                     ; end of before header
\f

; fpa-subproc          standard types
; eli, 21.8.1975

; after header and data transmitted
;
; entered by mainproc, when a header and a corresponding datablock
; (if any) has been transmitted.
; the result of the transmission is checked and if an error has
; occured, the message is returned with result=4 (receiver
; malfunction).
;
; finally the state of the subproc is checked for transmission of a
; new block.

b. i10, j10
w.

q2:  jl. w3  u40.      ; after header: test header transmitted
     jl.     u2.       ; error: goto testmore
     jl.     u2.       ;  goto testmore

e.                     ; end of header and data transmitted
\f

; fpa-subproc          standard types
; eli, 15.1.1976

; after header received
;
; a header has been received.
; for this kind of subprocs (with no special actions) it can
; only specify the functions <answer input with data> or
; <answer message with data>.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3 

b. i10, j10
w.

q3:  jl. w3  u50.      ; after header received: test answer header
     jl.     u2.       ;  goto testmore

e.                     ; end of after header received
\f

; fpa-subproc          standard types
; eli, 15.1.1976

; after data received
;
; check transmission.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q4:  jl. w3  u60.      ; after data received: test data received
     jl.     u2.       ;  goto testmore

; attention. no special action

     jl.     u2.       ;  goto testmore

e.                     ; end of data received
\f

; fpa-subproc          standard types
; eli, 16.12.1975

; after create
;
; the subproc has just been created.
; no special action
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q5:                    ; after create:
     jl      (b101)    ;  goto return

e.                     ; end of after create

e.                     ; end of standard types
\f

; fpa-subproc          terminals
; eli, 20.1.1976

c.(:a80>12a.1:)-1      ; if terminal bit then include:

b. q20, s20
w.

; this code takes care of special actions (such as <to>, <from>,
; <attention> etc.) needed for terminals connected as subprocesses.

m.                terminal link

; entry point table:

h108:      q0        ; after send message
           q1        ; before header transmit
           q2        ; after header transmit
           q3        ; before data receive
           q4        ; after data receive
           q5        ; after create

; definition of local part of subproc

b. j0
w.

s0=p0                ; start of local area
j0=s0                ; save start

s5= s0               ; <special actions mask> (1 byte)
s6= s0+1, s0=s0+2    ; <special action selected> (1 byte)
s7= a71 , s0=s0+2    ; att buffer adr. (fixed position)
                     ; (used by driverproc when answer arrives)

s1= s0               ; <1st word of user name>
s2= s0+2             ; <2nd   -   -   -    -<
s3= s0+4             ; <3rd   -   -   -    - >
s4= s0+6, s0=s0+8    ; <4th   -   -   -    - >

; test for size of private part not exceeded

c. (:s0-j0-v1-1:)    ; v1= max size allowed for private part
     m.  fpa terminal: private part too long
z.
e.                   ; end of definition of private part

; maskbits in <special actions mask>

s10= 2.0001          ; output <:att:>
s11= 2.0010          ; input name
s12= 2.0100          ; output <:unknown:>
s13= 2.1000          ; output name
s14 =2.10000          ; initial state until first att-mess
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; after send message
;
; a new message has been received.
; check accessrights and (if ok) link the message into the queue
; of pending messages. if subproc is not busy, then link subproc
; in queue of mainproc for later activation.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q0:                    ; after send message:
     jl. w3  u4.       ;  check and link operation
     jl.     u2.       ;  goto testmore

e.                     ; end of after send message
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; before header
;
; the subproc has been activated by mainproc for transmission
; of a header and maybe an associated datablock
;
; first pending special actions such as <answer attention>,
; output of user name etc. will be processed.
;
; then the messagequeue of the subproc is examined for a pending
; message and if none is found return is made to mainproc with a
; <no block>-status
;
; if an input- or output message is found the name of the sending
; process is output first, if it is different from <user name>,
; i.e. the name of the last sending process.
;
; otherwise standard transmission of the message is initiated.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i30, j20
w.

q1:                    ; before header:
     jl. w3  u20.      ;  test answer attention

; no answer attention pending.
; test for pending special actions

     bz  w0  x1+s5     ;  if special actions mask(subproc)<>0 then
     sz  w0  s10+s11+s12+s13;
     jl.     q10.      ;  goto find special action

     jl. w3  u12.      ;  mes:= find first message
     sn  w2  0         ;  if mes=0 then
     jl.     u3.       ;   goto no block

; message found. test for input or output

     bz  w0  x2+8      ;  oper:= operation(mes)
     se  w0  3         ;  if oper=input or output then
     sn  w0  5         ;
     jl.     i1.       ;
     jl.     i4.       ;  begin

; test username

i1:  rs. w0  j0.       ;   save operation
     rl  w2  x2+6      ;   if name(sender(mes))<>user name(subproc) then
     dl  w0  x2+a11+2  ;
     sn  w3  (x1+s1)   ;
     se  w0  (x1+s2)   ;
     jl.     i2.       ;
     dl  w0  x2+a11+6  ;
     sn  w3  (x1+s3)   ;
     se  w0  (x1+s4)   ;
     jl.     i3.       ;
     jl.     i4.       ;   begin
i2:  ds  w0  x1+s2     ;    user name(subproc):= name(sender(mes))
     dl  w0  x2+a11+6  ;
i3:  ds  w0  x1+s4     ;

; the text <:to:> or <:from:> followed by the name of the
; sender should be output before the message itself

     al  w0  s13       ;    special action(subproc):= output name
     hs  w0  x1+s5     ;
     al  w0  v72       ;    special messages(state(subproc)):= true
     lo  w0  x1+p12    ;
     rs  w0  x1+p12    ;
     rl. w0  j0.       ;    goto if saved operation=output then
     se  w0  3         ;         output(FROM) else
     am      i17       ;         output(to)
     jl.     i14.      ;   end name<>user
                       ;  end input or output

; prepare normal message and (maybe) datablock

i4:  rl  w2  b18       ;  mes:= current message(monitor)
     jl. w3  u30.      ;  prepare transfer
     jl      (b101)    ;  goto mainproc return

j0:  0                 ;  saved operation

; the following table is used to select special actions
;
;  - the first byte holds a bit to be tested against the <special
;    actions mask>
;  - the second byte holds the relative address of the action (relative to i10)
;     of the action to be performed if the bit is set
;
; note, that the ordering of the entries is important. it describes
;       (as an example) that the text <:att:> should be otuput
;       before the name is read in

i10: h.
             s12, i16. ; unknown
             s10, i13. ; attention
             s11, i19. ; input name
             s13, i18. ; output name
     w.

q10:                   ; find special action:
     al. w3  i10.      ;  w0 holds special actions mask
     jl.     i12.      ;
i11: al  w3  x3+2      ;  find entry with bit set in special actions mask
i12: bz  w2  x3        ;
     so  w0  x2        ;
     jl.     i11.      ;

; w3 points to entry

     hs  w2  x1+s6     ;  save action selected
     ba  w3  x3+1      ;
     jl      x3+1      ;  goto action

; table of special texts
; first word holds length of following text in 8-bit characters

j16: i20, <:<10>att<32>:>,     i20=(:k-j16-2:)/2*3
j17: i21, <:<10>to<32>:>,      i21=(:k-j17-2:)/2*3
j18: i22, <:<10>from<32>:>,    i22=(:k-j18-2:)/2*3
j19: i23, <:unknown<10>:>,     i23=(:k-j19-2:)/2*3

i13: am      j16-j17   ; text:= att     or
i14: am      j17-j18   ;        to      or
i15: am      j18-j19   ;        from    or
i16: al. w2  j19.      ;        unknown
i17=i15-i14

; w2 points in table above

     rl  w3  x1+a50    ;  main:= mainproc(subproc)
c. p103-1
     al  w0  2         ; addresscode(main):= driver area
     hs  w0  x3+p72    ;
z.
     al  w0  x2+2      ;  first(main):= first(text)
     rs  w0  x3+p65    ;
     rl  w0  x2        ;  data size(main):= header size(main):=
     rs  w0  x3+p66    ;  size(text)
     rs  w0  x3+p64    ;
     al  w0  v52+(:1<0:); function(main):= output+databit
     hs  w0  x3+p61    ;
     la  w0  g50       ;  store even function in messagetable

; set rest
; 
; initiate standard parameters in mainproc
;
; upon entry:
; w0     value to store in message table(subproc, bufno)
; w1     subproc
; w2
; w3

q11: jl. w3  u9.       ; set rest: message table(subproc,bufno):= w0
     rs  w0  x2        ;
     al  w0  -1        ;  decrease(free buffers(subproc))
     ba  w0  x1+p16    ;
     hs  w0  x1+p16    ;
     jl. w3  u25.      ;  set linkparams

     jl      (b101)    ;  goto mainproc return

; initiate output of user name
;
; note: during transmission a newline character (value=10) is
;       inserted as the 12th character in the user name.
;       it is removed again after transmission.

i18: al  w0  10        ;  last character(user name(subproc)):= 10
     lo  w0  x1+s4     ;
     rs  w0  x1+s4     ;
c. p103-1
     rl  w3  x1+a50    ; main:= main(subproc)
     al  w0  8         ; addresscode(main):= dirty
     hs  w0  x3+p72    ;
     al  w0  0         ; messagebuf(main):= 0  (no buf.)
     rs  w0  x3+p71    ;
z.
     al  w0  v52+(:1<0:); function:= output+databit
     jl.     i5.       ;

; initiate input of user name

i19: al  w0  v70       ;  blocked(subproc):= true
     lo  w0  x1+p12    ;
     rs  w0  x1+p12    ;
     al  w0  v50       ;  function:= input
i5:                    ;
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     hs  w0  x3+p61    ;  function(main):= function selected
     al  w2  8/2*3     ;  size:= size of user name
     rs  w2  x3+p64    ;  header size(main):= size
     so  w0  2.1       ;  if even(function) then size:= 0
     al  w2  0         ;
     rs  w2  x3+p66    ;  data size(main):= size
     al  w0  x1+s1     ;  first(main):= first of user name(subproc)
     rs  w0  x3+p65    ;

; store function selected in message table as special flag

     bz  w0  x3+p61    ;  w0:= even function(main)
     la  w0  g50       ;
     jl.     q11.      ;  goto set rest

e.                     ; end of before header
\f

; fpa-subproc          terminals
; eli, 16.1.1976

; after header and data transmitted
;
; a header and maybe a datablock has been transmitted
;
; if the <special action selected>-flag is nonzero it is used
; to clear a bit in the <special actions mask>. if this thereby
; becomes zero the <special messages> flag in the state-field of
; the subproc is cleared
;
; upon entry:
; w0  
; w1     subproc
; w2
; w3

b. i10, j10
w.

q2:                    ; after header:
     jl. w3  u40.      ;  test header and data transmitted
     jl.     u2.       ; error: goto testmore
     al  w3  -1        ;
     bs  w3  x1+s6     ;  if special action selected(subproc)=0 or
     am      (x1+a50)  ;    transmission state(mainproc)<>0 then
     bz  w0  +p60      ;
     se  w3  -1        ;
     se  w0  0         ;
     jl.     u2.       ;  goto testmore
     bz  w0  x1+s5     ;  remove bit in special actions mask(subproc)
     la  w0  6         ;
     hs  w0  x1+s5     ;
     al  w3  0         ;  special action selected(subproc):= 0
     hs  w3  x1+s6     ;
     al  w2  (:-1:)<8  ;  last char(username(subproc)):= 0
     la  w2  x1+s4     ;
     rs  w2  x1+s4     ;
     se  w0  0         ;  if special actions mask(subproc)<>0 then
     jl.     u2.       ;  goto testmore
     al  w0  -1-v72    ;  remove special message flag
     la  w0  x1+p12    ;
     rs  w0  x1+p12    ;
     jl.     u2.       ;  goto testmore

e.                     ; end of after header
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; before data receive
;
; activated, when a header which will be followed by a datablock has been
; received
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q3:                    ; before data receive:
     jl. w3  u50.      ;  test answer header

; return to <link>: normal function
;  return will only be made if the datablock could not be 
;  received (sender stopped etc.)

     jl.     u2.       ;  goto testmore

; return to <link+2>: special function
;  can only be input of attention name
; note: if only a single character has been received and result and
;       status is ok (=0) then a newline character must have been
;       typed alone. in that case the datablock is skipped
;       and the current name used.

     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     al  w0  8         ;  address code(main):= dirty
     hs  w0  x3+p92    ;
c. p103-1
     al  w0  0         ; messagebuf(main):= 0  (no buf)
     rs  w0  x3+p91    ;
z.
     al  w0  x1+s1     ;  first(main):= first of user name(subproc)
     rs  w0  x3+p85    ;
     rl  w0  x3+p84    ;  size8:=
     rs  w0  x3+p86    ;  data size(main):= header size(main)
     bl  w2  x3+p82    ;  if size8<>1 or
     ba  w2  x3+p83+1  ;
     sn  w0  1         ;     result(main)<>0 or status(main,0:11)<>0 then
     se  w2  0         ;  
     jl      (b101)    ;  goto mainproc return
     al  w0  p162      ;  skip(main):= true
     hs  w0  x3+p80    ; 
     jl. w3  u11.      ;  clear message entry
     al  w0  -1-v70    ; 
     la  w0  x1+p12    ;  blocked(subproc):= false
     rs  w0  x1+p12    ;
     jl.     q15.      ;  goto attention name ready

e.                     ; end of before data
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; after data received
;
; activated, when a header without data or a datablock following a
; header has been received
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q4:                    ; after data received:
     jl. w3  u60.      ;  test data received

; return to <link>: normal function

     jl.     u2.       ;  goto testmore

; return to <link+2>: attention

     jl.     q12.      ;  goto attention received

; return to <link+4>: special function received
; a special text (unknown, to, from, att) has been output or
; an attention name has been read in.

     sn  w2  v50       ;  goto if message entry(bufno)=input then
     jl.     q13.      ;    attention name received else
     jl.     u2.       ;    testmore

e.                     ; end of after data received
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; attention received
;
; an attention message has been received.
; check reserverstatus of subproc and, if not reserved initiate
; input of name.
;

b. i10, j10
w.

q12:                   ; attention:
     rl  w0  x1+a52    ;  if reserved(subproc)<>0 then
     sn  w0  0         ;  begin comment: find reserver
     jl.     i2.       ;
     rl  w2  x1+a71    ;
     se  w2     0      ;    if att mess pedling then
     jl.        u2.    ;    return
     rl  w3  b6        ;   entry:= first internal in name table
     jl.     i1.       ;
i0:  al  w3  x3+2      ;   while idbit(proc(entry))<>reserver(subproc) do
i1:  rl  w2  x3        ;   entry:= entry+2
     se  w0  (x2+a14)  ;
     jl.     i0.       ;
     jl.     q14.      ;   goto process found
                       ;  end reserved<>0

; prepare subproc to print text <:att:> and read in name

i2:  al  w0  s10+s11   ;  special actions mask(subproc):= output(att),
     hs  w0  x1+s5     ;    input(name)
     al  w0  v72       ;  special messages(subproc):= true
     lo  w0  x1+p12    ;
     rs  w0  x1+p12    ;
     jl.     u2.       ;  goto testmore

e.                     ; end of attention received
\f

; fpa-subproc          terminals
; eli, 22.1.1976

; attention name received
;
; any error status cause the text <:unknown:> to be output
;
; otherwise the terminating newline is removed and the
; name searched for

b. i10, j10
w.

q13:                   ; attention name:
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     bl  w2  x3+p82    ;
     ba  w2  x3+p83+1  ;
     se  w2  0         ;  if status(main, 0:11)=result(main)=0 then
     jl.     i0.       ;  begin
     rl  w3  x3+p84    ;   if size(main)=0 then
     sn  w3  0         ;   goto testmore
     jl.     u2.       ;   mask of last received character with value=10
     al  w3  x3-1      ;
     wd. w3  j1.       ;   note: w2 already zero
     ls  w3  1         ;   index:= (size-1)//3*2
     ls  w2  3         ;   position:= -((size-1) mod 3*8)
     ac  w2  x2        ;
     rl. w0  j0.       ;   mask:= newline shift position
     as  w0  x2        ;
     am      x3        ;   address:= first of user name(subproc)+index
     al  w3  x1+s1     ;
     la  w0  x3        ;
i1:  rs  w0  x3        ;
     al  w0  0         ;   rest of user name(subproc):= 0
     al  w3  x3+2      ;
     sh  w3  x1+s4     ;
     jl.     i1.       ;

; now a terminating newline has been replaced by a zero
;  search for process

q15:                   ; attention name ready:
     al  w2  x1+s1     ;   search name(user,entry,interval(subproc))
     dl  w1  x1+a49    ;
     jl  w3  d71       ;
     rl  w1  b19       ;
     sn  w3  (b7)      ;   if entry= name table end then goto unknown
     jl.     i0.       ;
     rl  w2  x3        ;   if kind(entry)<>internal or pseudoproc then
     rl  w0  x2+a10    ;   goto unknown
     se  w0  64        ;   goto process found
     sn  w0  0         ;
     jl.     q14.      ;  end

; prepare subproc to output the text <:unknown:>

i0:  al  w0  s12       ;  special actions mask(subproc):= output(unknown)
     hs  w0  x1+s5     ;
     al  w0  v72       ;  special messages(subprocstate):= true
     lo  w0  x1+p12    ;
     rs  w0  x1+p12    ;
; remove procfunc as user of the subprocess. it was included as user when the
; (temp) link was created to prevent removel of a partly created link.
; (If the subproc is perm procfunc has already been removed - but one more 
;   remove  doesn't matter).

     al  w2  x1        ;  proc := subproess;
     rl  w1 (b6)       ;  internal := procfunc;
     jl  w3  d123      ;  remove user(internal,proc);
     jl.     u2.       ;  goto testmore

j0:  (:-1-10:)<16      ;  mask to remove newline
j1:  3                 ;  division constant

e.                     ; end of attention name
\f

; fpa-subproc          terminals
; eli, 15.1.1976

; process found
;
; clear message queue and deliver attention message
;
; upon entry:
; w0
; w1     subproc
; w2  receiver of att-mess
; w3

b. i10, j10
w.

q14:                   ; process found:
     rs. w2  j1.       ; save  receiver
     al  w2  0         ; if att bufer pending then
     rx  w2  x1+a71    ;
     se  w2  0         ;
     jl  w3  d75       ; regret message
     rs. w1  j2.       ; save subproc
     rl. w1   j1.      ; if receiver.att := pseudo proc then
     rl  w0  x1+a10    ; 
     se  w0  0         ; internal := main.pseudoproc
     rl  w1  x1+a50    ;
     am.     (j2.)     ; external :=subhost.sub
     rl  w2  +a50      ; if internal user of subhost then 
     al  w2  x2+p202   ;
     jl  w3  d102      ;  include internal as user of sub
     jl.     i2.       ;+0 not user
     rl. w2  j2.       ;+2 user
     jl  w3  d126      ;
; remove procfunc as user. it was included as user when the subproc was
; created to prevent removel of a partly created subprocess.

i1:
     rl  w1 (b6)       ;  internal := procfunc;
     jl  w3  d123      ;  remove user(internal, subproc);
i2:  rl. w1  j2.       ;
     zl  w0  x1+s5     ; if initial create then
     la. w0  j4.       ; begin
     ls  w0  -4        ;    attflag.init := true
     zl  w2  x1+s5     ;    sub.special_action.init := false
     sz  w2  s14       ; end;
     lx. w2  j4.       ;
     hs  w2  x1+s5     ;
     am     (x1+a50)   ; attflag.i-o := attoperation.status.att_bit
     rl  w2    +p83    ;
     la. w2     j5.    ;  
     ls  w2    -2      ;
     lo  w0    +4      ;
     rs. w0    j3.     ;
     rl. w3  j0.       ;
     al  w0  0         ;   attention message
     ds  w0  g21       ;    +0  :  0
     al  w3  0         ;    +2  : status
     ds  w0  g23       ;    +4  : 0
     jl.     i4.       ;  for mes:= first pending(subproc) while mes<>0 do
i3:  jl  w3  g18       ;  deliver result(1,mes,intervention)
i4:  jl. w3  u22.      ;
     sn  w2  0         ;
     jl.     i5.       ;
     zl  w0  x2+a150   ; if mess.operation = i-o then
     so  w0     2.1    ;    set att_i-o flag.
     jl.        i3.    ;
     rl. w0     j3.    ;
     lo. w0     j6.    ;
     rs. w0     j3.    ;
     jl.        i3.    ;

; deliver the att-message

i5:  al  w2  x1        ;  
     al  w3     0      ;  att.mess0 := 0;
     al  w1     g20    ;  att.mess1 := status;
     rl. w0     j3.    ;
     ds  w0     g21    ;
     rs  w2     g22    ; att.mess2 := pd.terminal
     dl  w0  x2+a11+2  ; att.mess3-mess6 := name of terminal
     ds  w0     g23+2  ;
     dl  w0  x2+a11+6  ;
     ds  w0     g23+6  ;

     rl. w3  j1.       ;  w3:=  receiver
     jd      1<11+17   ;  send message(w2=sender, w3= rec.)
     rl. w1  j2.       ;  <*get subproc*>
     rs  w2  x1+a71    ; save att buffer;

; end of attention

     jl.     u2.       ;  goto testmore

j0:  1<16              ;  attention status
j1:  0                 ;  saved message or process
j2: 0
j3 : 0                 ; status for att-message
j4 : s14               ; special action mask : initial state
j5 : 8.020             ; status mask : att_bit
j6 : 1<2               ; att status  : i-o

e.                     ; end of process found
\f

; fpa-subproc          terminals
; eli, 16.12.1975

; after create
;
; the subproc has just been created.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q5:                    ; after create:
     al  w0  0         ;  user name(subproc,0):= 0
     rs  w0  x1+s1     ;  action selected(subproc):=
     al  w0  s14       ;  action mask(subproc) := initial
     ls  w0  12        ;
     rs  w0  x1+s6     ; 
     rl  w0  x1+a10    ; 
     se  w0     85     ;  if temp link then 
     jl.        j2.    ;  begin
     al  w2  x1        ;
     rl  w3    (b3)    ;   
     al  w0  x3+a54    ;         message:= remoter.eventq.first;
     rl  w3  x3+a54    ;         while message <> none do
     rs. w0     i3.    ;         begin
j3:  rs. w3     i2.    ;
     sn. w3    (i3.)   ;
     jl.        j2.    ;
     zl  w0  x3+a150   ;           if message.operation = wait for connect then
     se  w0     2      ;           begin
     jl.        j1.    ;
     zl  w0  x3+a150+1 ;             if (message.mode = all connections) or
     so  w0     2.1    ;                (message.mode = specific main and
     jl.        j4.    ;                 message.mainaddress = this main) then
     rl  w0  x3+a151   ;             begin
     se  w0 (x2+a50)   ;
     jl.        j1.    ;
j4:  rl  w1  x3+a142   ;               sender:= message.sender;
     rl  w0  x1+a10    ;               if sender.kind<>internal then
     se  w0     0      ;                  sender:=sender.main; <*pseudo proc*>
     rl  w1  x1+a50    ;
     jl  w3     d125   ;               include reserver(sender,proc);
     jl.        j2.    ;           end;
j1:  rl. w3     i2.    ;
     rl  w3  x3+a140   ;           message:=message.next;
     jl.        j3.    ;         end;
j2:  jl        (b101)  ; done: end;

i2:  0                 ; message
i3:  0                 ; mess queue head
     jl      (b101)    ;  goto return

e.                     ; end of after create

e.                     ; end of terminals

z.                     ;

h108=h100
\f


; fpa-subproc          magnetic tape
; eli, 4.11.1975

c.(:a80>13a.1:)-1      ; if magtape bit then include:

b. q20, s10
w.

; this code takes care of special actions for magnetic tapes,
; connected to rc4000 through a devicecontroler

m.                magnetic tape link

; entry point table:

h118:      q0        ; after send message
           q1        ; before header transmit
           q2        ; after header  transmit
           q3        ; after header received
           q4        ; after data received
           q5        ; after create

; definition of local part of subproc

b. j0
w.

s0=p0                ;  start of local area
j0=s0                ;  save start

s1= s0,   s0=s0+2    ;  <state>
s2= s0,   s0=s0+2    ;  <file count>
s3= s0,   s0=s0+2    ;  <block count>
s5= s0,   s0=s0+2    ;   <last status>
          s0=s0+2    ;  one unused word
s4= s0,   s0=s0+2    ;  <remoter proc>

; test for size of private part not exceeded

c.(:s0-j0-v1-1:)     ;  v1= max. size of private part
     m. fpa magnetic tape: private part too long
z.
e.                   ; end of definition of local part
\f

; fpa-subproc          magnetic tape
; eli, 12.9.1975

; after send message
;
; a new message has been received.
; check message and link it to queue of subproc.
; if subproc is free, then link it to mainproc.
;
; upon entry:
; w0     
; w1     subproc
; w2     
; w3

b. i10, j10
w.

q0:  jl. w3  u4.       ; after send message: check and link operation
     al  w0  0         ;  state(magnetic tape):= 0
     rs  w0  x1+s1     ;
     rl  w2  b18       ; 
     bz  w0  x2+8      ;  oper:= operation(mes)
     sn  w0  5         ;  if oper<>output then
     jl.     i0.       ;  
     jl.     u2.       ;  goto testmore
i0:  al  w3  1         ;  sizeminus1:=
     wa  w3  x2+12     ;   last(mes)-first(mes)+1
     ws  w3  x2+10     ;  if sizeminus1>=maxsize(subproc) then
     sl  w3  (x1+p18)  ;
     jl      g5        ;  goto result 3
     jl.     u2.       ;  goto testmore

e.                     ; end of after send message
\f

; fpa-subproc          magnetic tape
; eli, 15.1.1976

; before header
;
; examine the message-queue of the subproc for a pending message.
; if none is found return to mainproc with <no block>-status.
;
; otherwise initialize the mainproc sender table for transmission
; of a header and maybe a datablock.
;
; upon entry:
; w0     
; w1     subproc
; w2
; w3

b. i10, j10
w.

q1:                    ; before header:
     jl. w3  u20.      ;  test answer attention
     jl. w3  u12.      ;  mes:= find first message(subproc)
     sn  w2  0         ;  if mes=0 then
     jl.     u3.       ;   goto no block
  al  w0  0         ;   current message(subproc) := 0;
  rs  w0  x1+p13    ;
     bz  w0  x2+8      ;
     so  w0  2.1       ;   if odd operation then
     jl.     j0.       ;     examine sender(mess);
     jl  w3  g34       ;      stopped: goto stopped;
     jl.     j1.       ;      ok:

j0:  jl. w3  u30.      ;  prepare transfer

; the stop count of the sender will be increased at
; this point for input messages, thus assuring that the sender has not been
; stopped when the datablock arrives.

     bz  w0  x2+8      ;  if oper(mes)<>input then
     se  w0  3         ;
     jl      (b101)    ;  goto mainproc return
     jl. w3  u21.      ;  test and increase stop count
     jl.     u3.       ; stopped: goto no block
     jl      (b101)    ; ok: goto mainproc return
j1:  rl  w0  x1+s5     ; stopped:
     rs  w0  g20       ;     status(mess):=saved status(sub);
     ld  w0  -100      ;
     ds  w0  g22       ;      bytes, chars trf(mess):=0,0;
     dl  w0  x1+s3     ;   file,block count(mess):=saved file, block count(sub);
     ds  w0  g24       ;
     jl  w3  g18       ;     deliver result1;
     jl.     u3.       ;     goto no block;

e.                     ; end of before header
\f

; fpa-subproc          magnetic tape
; eli, 15.1.1976

; after header transmitted
;
; a header and maybe a datablock has been transmitted.
;
; transmission is checked
;
; upon entry
; w0    
; w1     subproc
; w2
; w3

b. i10, j10
w.

q2:                    ; after header transmit:
     jl. w3  u40.      ;  test header and data transmitted
     jl.     u2.       ; error: goto testmore
     jl.     u2.       ;  goto testmore

e.                     ; end of header transmitted
\f

; fpa-subproc          magnetic tape
; eli, 15.1.1976

; after header received
;
; a header has been received.
; the function of the header may be
;
;     <answer input with data> or <answer message with data>
;
; upon entry:
; w0
; w1     subproc
; w2    
; w3

b. i10, j10
w.
q3:                    ; before data receive:
     jl. w3  u50.      ;  test answer header
     jl.     u2.       ;  goto testmore

e.                     ; end of after header received
\f

; fpa-subproc          magnetic tape
; eli, 5.11.1975

; after data received
;
; a datablock following a header has been received.
;
; first adjust the position of the tape described in <file count>
; and <block count>.
;
; then check transmission in standard way
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q4:  jl. w3  q10.      ; after data received: adjust position
     jl. w3  u60.      ;  test data received
     jl.     u2.       ;  goto testmore

; <link+2>: attention received
; find remoterprocess, if any
     jl. w3     q11.   ;   clear queue(state=2);
     rl  w3    (b3)    ;
     al  w0  x3+a54    ;   message:=remoter.eventq.first;
     rl  w3  x3+a54    ;
     rs. w0     j2.    ;
i1:  sn. w3    (j2.)   ;   while message<>none do
     jl.        i4.    ;   begin
     rl  w0  x3+a140   ;     next-message:=message.next;
     rs. w0     j1.    ;
     zl  w0  x3+a150   ;     if message.operation=wait for mt-online and
     se  w0     0      ;      ((message.mode=specific main and
     jl.        i3.    ;        message.main=proc.main) or
     zl  w0  x3+a150+1 ;        message.mode=all main) then
     so  w0     2.1    ;     begin
     jl.        i2.    ;
     rl  w0  x3+a151   ;
     se  w0 (x1+a50)   ;
     jl.        i3.    ;
i2:  rs  w3     b18    ;       message.status:=0;
     al  w0     0      ;       message.mt-addr:=proc;
     ds  w1     g21    ;       deliver result(1);
     jl  w3     g18    ;
i3:  rl. w3     j1.    ;     end;
     jl.        i1.    ;     message:=next-message;
i4:  jl.        u2.    ;   end;
 
j1:  0                 ;   next-message
j2:  0                 ;   remoter eventq

e.
\f

; fpa-subproc          magnetic tape
; eli, 5.11.1975

; after create
;
; the subproc has just been created.
; no special actions needed
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.
q5:                    ; after create:
     rl  w0  (b3)      ;  remoter(subproc):= first in name table
     rs  w0  x1+s4     ;
     jl      (b101)    ;  goto return

e.                     ; end of after create
\f


; fpa-subproc          magnetic tape
; eli, 14.9.1975

; procedure adjust position
;
; the position of the tape as described in <file count> and <block count>
; is adjusted in the following way:
;
; after an input- or output operation <block count> is increased by
; one, unless
;     status bit2 (timer) is set or
;     the size-field of mainproc is zero.
;
; if status bit7 is set (tape mark), <file count> is increased by
; one and <block count> is cleared.
;
; in case of answer message with data, the <file count> and
; <block count> is given in the datablock following.
;
; the new values of <block count> and <file count> are stored
; in the answer-variables g23 and g24, ready for sending of an
; answer
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   unchanged
; w3     link          unchanged

b. i10, j10
w.

q10: ds. w3  j0.       ; adjust position: save link and w2
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     zl  w0  x3+p83+1  ;  if status(main)=intervention then
     ls  w0  12       ; shift status
     sh  w0  -1        ;
     jl.     i4.       ;  goto intervention
     rs  w0  x1+s5     ;  last status(proc):=status(main);
     bz  w0  x3+p81    ;  func:= function(main)
     rl  w2  0         ;  save function in w2
     la  w0  g50       ;  remove databit
     se  w0  v51       ;  if func=answer input or
     sn  w0  v53       ;     func=answer output then
     jl.     i0.       ;  goto increase
     se  w2  v55+(:1<0:); if func<>answer message with data then
     jl.     i2.       ;  goto set g23 and g24

; get values from datablock of answer

     am      (x1+a50)  ;  w2:= first received address(mainproc(subproc))
     rl  w2  +p85      ;
     dl  w0  x2+8      ;  get file- and blockcount from datablock
     ds  w0  x1+s3     ;  goto set g23 and g24
     jl.     i2.       ;

; after input- or output
; adjust file- and blockcount as described above

i0:  bz  w2  x3+p83+1  ; increase:
     rl  w3  x3+p84    ;  if timer(status(main))=0 and
     so  w2  1<9       ;     size(main)<>0 then
     sn  w3  0         ;
     jl.     i1.       ;  
     dl  w0  x1+s3     ;   block count(subproc):= 
     ba. w0  1         ;      blockcount(subproc)+1
     rs  w0  x1+s3     ;

i1:  so  w2  1<4       ;  if tape mark(status(main))=1 then
     jl.     i2.       ;  begin
     al  w3  1         ;   file count(subproc):= file count(subproc)+1
     wa  w3  x1+s2     ;
     al  w0  0         ;   block count(subproc):= 0
     ds  w0  x1+s3     ;  end

; set new (or saved) content in g23 and g24.
; w3w0 holds value

i2:  dl  w0  x1+s3     ; set g23 and g24:
     ds  w0  g24       ;
     jl.     i3.       ;

; intervention status (tape has been set local)

i4:  jl. w3  q12.      ;  clear queue(state:= 1)

; restore w2 and w3 and return

i3:  dl. w3  j0.       ;
     jl      x3        ;

     0                 ; saved w2
j0:  0                 ; saved link

e.                     ; end of procedure adjust position
\f

; fpa-subproc          magnetic tape
; eli, 25.3.1976

; procedure clear queue
;
; called when the tape has been set offline or online.
; the name of the process is removed. an eventual reserver
; is removed. filecount, blockcount are set to -1.
; state is set depending on entrypoint selected.
; an answer with result 4 from the device is simulated.
; all pending messages are returned with result 5 (unknown).
;
;        call          return
; w0                   undefined
; w1     subproc       unchanged
; w2                   undefined
; w3     link          undefined

b. i10, j10
w.

                       ; clear queue:
q11: am      1         ;     state:= 2 (i.e. unknown mounted)
q12: al  w0  1         ;  or state:= 1 (i.e. local)
     rs  w0  x1+s1     ;
     rs. w3  j0.       ;  save link
     al  w0  0         ;  reserver(subproc):=
     rs  w0  x1+a11    ;  name(0):=  0
     rs  w0  x1+a52    ;
     rs  w0  x1+s5     ;  last status(proc):=status(main);
     al  w0  4         ;  simulated result(mainproc(subproc)):= 4
     am      (x1+a50)  ;
     hs  w0  +p82      ;
     al  w0  -1        ;  filecount(subproc):=
     al  w3  -1        ;  blockcount(subproc):= -1
     ds  w0  x1+s3     ;
     jl.     i1.       ;
i0:  al  w0  5         ;  for mes:= all unprocessed messages(subproc) do
     jl  w3  g19       ;  deliver result(mes, 5)
i1:  jl. w3  (j1.)     ;
     se  w2  0         ;
     jl.     i0.       ;

; return

     jl.     (j0.)     ;

j0:  0                 ;  saved link
j1:  u22               ;

e.                     ; end of clear queue

e.                     ; end of magnetic tape

z.                     ;

h118=h100



; stepping stones.

     jl.   u2.   , u2 =k-2
     jl.   u20.  , u20=k-2
     jl.   u21.  , u21=k-2

\f


; fpa-subproc          disc- and areatypes
; eli, 14.10.1975

c.(:a80>14a.1:)-1     ; if disc bit then include:

b. q20, s10
w.
;
; a disc connected to an rc3600 is in rc4000 represented by a subproc.
;
; an area on the disc is represented by a normal area process having
; 'document name' equal to the name of the disc-subproc (as defined
; by 'create peripheral process').
;
; the filestructure of the disc is defined in the normal way by a 
; slicetable in the monitor, provided the disc has been included in
; the bs-system by a call of 'include bs'.
;
; messages may be sent either directly to the disc, in which case
; absolute segment addressing is used, or to an areaprocess in which
; case adressing relative to the start of the area is used.
;
; the following subproc handles both messages to discs and areas.
; the only difference is the initial handling of the message just
; after 'send message'. here the segment number in a message to an
; areaprocess is converted to a physical (absolute) segment number.
;
; like other subprocesses a message may be split into a number of
; messages to the device, each (exept the last) corresponding to
; the maximum buffer length of the device as stated in 'create'.
; but due to the file structure of a disc another level of message-
; splitting is introduced (note: this level of message-splitting
; is already known from the existing handling of a disc, connected
; directly to an rc4000).
;
;    a file need not correspond to a number of physically con-
;    secutive segments.
;
; therefore a message to an areaprocess is treated in the following
; levels:
;
;    1. message level
;       2. slice level: prepare a number of consecutive segments.
;          3. buffer level: transfer these segments in a number
;             of blocks corresponding to the maximum device buffer
;             length.
;
; stage 3 is executed 1 or more times for each instance of stage 2,
; and stage 2 is repeated for each group of consecutive segments
; until either the file in question or the message data area suppli-
; ed from the internal process is exhausted.
;
; in stage 2 and 3 there is no destinction between messages originally
; sent to an areaprocess or to a discprocess. as there is no file-
; structure for messages to the disc, stage 2 must 'automatically'
; be dummy in that case.
;
; the subproc uses the message as storage for information making this
; possible.
;
; originally a message to an area- or a discprocess holds the following
; information:
;
;    message+8:   operation<12+mode
;          +10:   first address
;          +12:   last address
;          +14:   first segment
;                 (absolute for messages to disc,
;                 relative to start of area otherwise)
;
; after 'send message' and in the following processing of the message
; it is transformed in the following way:
;
;    message+8:   unchanged from above
;          +10:   unchanged from above
;          +12:   last address corresponding to current consecutive
;                 segments (initially set equal to +10)
;          +14:   first physical segment 
;          +16:   next physical segment, i.e. start segment for the
;                 next consecutive segments
;          +18:   original value of last address (from above)
;          +20:   expected size
;          +22:   updated first address
;
; note, that +8, +10, +12, +20 and +22 corresponds to a message as it
; is normally required by the common fpa-procedures.
; these procedures may then handle the splitting of the consecutive
; segments depending on the buffersize of the device. only a little
; extra code is required here, taking care of updating of 'first phy-
; sical segment' after each transfer.
;
; when the consecutive segments are exhausted the next number of 
; consecutive segments are selected, and +12, +14 and +16 updated
; correspondingly.
;
; for a message directly to the discprocess, +12 and +18 will be
; set equal to each other, thus simulating that the last part of a
; message is processed.
;
; when a message is sent to an areaprocess the standard 'send message'
; action is entered. there the discprocess corresponding to the area
; is found and if the kind of the discprocess is a subprocess, a jump
; is performed through send message for subprocs to the
; send message action for disc-subprocs. a flag in the
; subproc description shows the area process that is the
; actual receiver of the message
;
; a message to the discprocess itself enters here at q0.
\f

; fpa-subproc          disc- and areatypes
; eli, 15.10.1975

m.                disc link

; entry point table

h106:        q0        ; after send message (only for disc)
             q1        ; before header
             q2        ; after header transmit
             q3        ; after header receive
             q4        ; after data receive
             q5        ; after create

; definition of local part of subproc

b. j0
w.

s0= p0                 ; start of local part
j0= p0                 ; save start

        s0=s0+2        ; 1 unused word
s2=s0,  s0=s0+2        ; <chaintable>
s3=s0,  s0=s0+2        ; <slicelength>
s4=s0,  s0=s0+2        ; <state>

; test for size of private part not exceeded

c. (:s0-j0-v1-1:)
   m. fpa subproc: disctype private part too long
z.
e.                     ; 

q12:         (:-1:)<9  ; constant to mask of to integral number
                       ; of segments
\f

; fpa-subproc          disc- and areatypes
; eli, 22.1.1976

; after send message (disc)
;
; set up the message, so that the procedure 'prepare consecutive
; area' will be dummy when applied to this message. this is done
; by setting
;
;    saved last address(message):= first addr(mes)+
;       (first addr(mes)-last addr(mes))//512*512
;
; upon entry:
; w0   
; w1     subproc
; w2     
; w3

b. i10, j10
w.

q0:                    ; after send message:
     rl  w0  x1+a56    ;  if called via areaprocess then
     sz  w0  (:-1:)<1  ;
     jl.     q11.      ;   goto after send message(area)
     jl. w3  u4.       ;  check and link operation
     rl  w2  b18       ;  w2:= current message
     bz  w0  x2+8      ;  if oper(mes)<>input and
     se  w0  3         ;     oper(mes)<>output then 
     sn  w0  5         ;
     jl.     i0.       ;  
     jl.     u2.       ;  goto testmore
i0:  al  w3  2         ;  saved last(mes):= last(mes):=
     wa  w3  x2+12     ;
     rl  w0  x2+10     ;    (last(mes)-first(mes)+2)//512*512
     ws  w3  0         ;
     la. w3  q12.      ;
     wa  w3  0         ;    + first(mes)
     al  w3  x3-2      ;    - 2
     rs  w3  x2+12     ;
     rs  w3  x2+18     ;
                       ;
     jl.     u2.       ;  goto testmore

e.
\f

; fpa-subproc          disc- and areatypes
; eli, 22.1.1976

; after send message (area)
;
; prepare message for first call of 'prepare consecutive area'

; note, that upon entry w0 will hold the areaprocess address,
;       and b19 (monitor entry) will hold the mainproc
;       address of the areaprocess (i.e. the disc-subproc)
;
; upon entry:
; w0     area
; w1     subproc (disc)   
; w2
; w3

b. i10, j10
w.

q11:                   ; after send message:
     al  w2  0         ;  called via areaprocess:= false
     rs  w2  x1+a56    ;
     rl  w1  0         ;  proc:= area
     rl  w2  b18       ;  w2:= current message
     bz  w0  x2+8      ;  if oper(mes)<>input and
     se  w0  3         ;     oper(mes)<>output then
     sn  w0  5         ;
     jl.     i0.       ;
     jl.     i1.       ;  goto link

; input or output operation

i0:  rl  w0  x2+14     ;  if first segment(mes)<0 or
     sl  w0  0         ;     first segment(mes)>=segments(area) then
     sl  w0  (x1+a61)  ;  goto outside
     jl.     i2.       ;

; adjust addresses to correspond to an integral number of
; segments

     dl  w0  x2+12     ;  last:= last(mes)
     rs  w3  x2+22     ;  updated first(mes):= first(mes)
     al  w3  x3-2      ;
     rs  w3  x2+12     ;  last(mes):= first(mes)-2
     ws  w0  6         ;  coresize:= (last-first(mes)+2)//512*512
     la. w0  q12.      ;
     rl  w3  x1+a61    ;  areasize:= (segments(area)-first segment(mes))*512
     ws  w3  x2+14     ;
     ls  w3  9         ;
     sh  w0  (6)       ;  size:= min(coresize, areasize)
     rl  w3  0         ;
     al  w3  x3-2      ;
     wa  w3  x2+10     ;  saved last(mes):= first(mes)+ size -2
     rs  w3  x2+18     ;

; get start in chain table of segments

     rl  w0  x2+14     ;  no of slices:= first segment(mes)/
     al  w3  0         ;                 slicelength(mainproc(area))
     am      (x1+a50)  ;
     wd  w0  +s3       ;
     rs  w3  x2+16     ;  save first segment in slice

; normally last(mes) points to the last address for which data
;   has been transferred.
; segments are normally transferred from the first segment in
;   a slice an on. this does however not hold for the first
;   transfer, where it starts with segment no
;   (first segment modulo slicelength).
; this is corrected for by subtracting from last(mes)
;   the core occupied by the not transferred segments in the
;   slice.
; this makes last(mes) point to a logical address (ahead of the
;   users buffer) where the transfer of a previous slice would have 
;   terminated.

     ls  w3  9         ;  last(mes):= last(mes)-
     rx  w3  x2+12     ;
     ws  w3  x2+12     ;    first segm in slice*512
     rs  w3  x2+12     ;
     rl  w2  x1+a60    ;  w2:= first slice(area)

; now change to run in mainproc(area), i.e. in the subproc actually
; corresponding to the disc

     rl  w1  x1+a50    ;  proc:= mainproc(area)
     wa  w2  x1+s2     ;  first slice:= first slice(area)+chaintable(proc)
     jl  w3  d74       ;  follow chain(w2=first slice, w0=no of slices)
     ws  w2  x1+s2     ;  next phys segm:= slice*slicelength(proc)+
     al  w0  x2        ;
     rl  w2  b18       ;  +
     wm  w0  x1+s3     ;
     wa  w0  x2+16     ;  first segment in slice
     rs  w0  x2+16     ;
     jl. w3  q10.      ;  prepare consecutive area
i1:  am      (b19)     ; link:
     al  w1  +a54      ;  w1:= addr of message queue of subproc
     jl  w3  d6        ;  link(w1=head, w2=elem)
     rl  w1  b19       ;  restore current subproc.
     jl.     u2.       ;  goto testmore

; first segment of message is outside the area. return
; status 'end of document'.

i2:  rl  w1  g62       ; outside: status:= bit5
     rs  w1  g20       ;
     ld  w1  -65       ;  bytes:= chars:= 0
     ds  w1  g22       ;
     jl  w3  g18       ;  deliver result(1)
     jl.     u2.       ;  goto testmore

e.                     ; end of after message (area)
\f

; fpa-subproc          disc- and areatypes
; eli, 14.10.1975

; before header (disc and area)
;
; prepare transmission of next block.
;
; note, that the fields <status> and <mode> are used to hold the
; segment number in case of an input- or output operation.
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.
q1:                    ; before header:
     jl. w3  u20.      ;  test answer attention
     jl. w3  u12.      ;  w2:= find first message
     sn  w2  0         ;  if w2=0 then
     jl.     u3.       ;   goto no block

; test for input- or output message

     jl. w3  u30.      ;  prepare transfer(message)
     bz  w0  x2+8      ;  if oper(mes)<>input and
     se  w0  3         ;     oper(mes)<>output then
     sn  w0  5         ;
     jl.     i1.       ;
     jl      (b101)    ;  goto mainproc return
i1:  rl  w0  x2+14     ;  w0:= first phys segment(mes)
     am      (x1+a50)  ;  state,mode(mainproc(subproc)):= w0
     rs  w0  +p63      ;

; increase stop count at this time also for input messages,
; thus ensuring that the process is still present when
; the answer arrives (which does not take long time for
; discs)

     jl. w3  u21.      ;  test and increase stop count
     jl.     u3.       ; stopped: goto no block
     jl      (b101)    ; running: goto mainproc return

e.                     ; end of before header
\f


; fpa-subproc          disc- and areatypes
; eli, 3.2.1976

; after header transmit
;
; a header and maybe a corresponding datablock has been transmitted.
; for messages originally sent to an areaprocess, the field
; first physical segment is increased corresponding to the
; size of the datablock transferred.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q2:                    ; after header transmit:
     jl. w3  u8.       ;  mes:= message table(current bufno)
     rs. w2  j0.       ;  save mes
     jl. w3  u40.      ;  test header transmit
     jl.     u2.       ; error: goto testmore
     rl. w2  j0.       ;   restore mes;
     se  w2  0         ;   if mes = 0 then
     jl.     i1.       ;   begin
     rl  w2  x1+p13    ;     mes:= current message;
     sn  w2  0         ;     if mes = 0
     jl.     u2.       ;        then goto testmore;
i1:                    ;   end;
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     bz  w0  x3+p61    ;  if function(main)<>input and
     se  w0  v50       ;     function(main)<>output then
     sn  w0  v52+(:1<0:);
     jl.     i0.       ;
     jl.     u2.       ;  goto testmore
i0:  rl  w0  x3+p64    ;  segments:= convert to 12(size(main))//512
     jl. w3  u15.      ;
     ls  w0  -9        ;
     rl. w2  j0.       ;  restore mes
     wa  w0  x2+14     ;  first phys segm(mes):= first phys segm(mes)+segments
     rs  w0  x2+14     ;

; if the last portion of the current consecutive area has been
;   initialized and more is to be transferred, then prepare
;   next consecutive segments.

     rl  w3  x1+p13    ;  if current message(subproc)=0 and
     rl  w0  x2+12     ;     last(mes)<>saved last(mes) then
     sn  w3  0         ;  begin
     sn  w0  (x2+18)   ;
     jl.     u2.       ;
     rs  w2  x1+p13    ;   current message(subproc):= mes
     jl. w3  q10.      ;   prepare consecutive area
                       ;  end
     jl.     u2.       ;  goto testmore

j0:  0                 ;  saved message address

e.                     ; end of after header transmit
\f

; fpa-subproc          disc- and areatypes
; eli, 14.10.1975

; after header received
;
; a header has been received.
; no special actions required
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q3:  jl. w3  u50.      ; after header receive: test header received
     jl.     u2.       ;  goto testmore

e.                     ; end of after header received
\f

; fpa-subproc          disc- and areatypes
; eli, 14.10.1975

; after data received
;
; a datablock following a header has been received
; 
; status intervention or result disconnected will cause the name of the
; subproc to be removed and the message returned with result 5
; (receiver does not exist)
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q4:                    ; after data:
     rl  w3  x1+a50    ;  main:= mainproc(subproc)
     bl  w2  x3+p82    ;  if result(main)=disconnected or
     bl  w0  x3+p81+1  ;     status(main)=intervention then
     sl  w0  0         ;  begin comment: remove name of proces;
     sn  w2  3         ;
     jl.     +4        ;
     jl.     i1.       ;
     al  w0  4         ;   simulated result(main):= 4
     hs  w0  x3+p82    ;
     al  w0  0         ;   name(subproc):=
     rs  w0  x1+a11    ;   reserver(subproc):= 0
     rs  w0  x1+a52    ;
     rl  w3  b5        ;   for area:= all area procs do
i0:  rl  w2  x3        ;
     sn  w1  (x2+a50)  ;   if main(area)=subpproc then
     rs  w0  x2+a50    ;   main(area):= 0
     al  w3  x3+2      ;
     se  w3  (b6)      ;
     jl.     i0.       ;  end
                       ;
i1:  jl. w3  u60.      ;  test data received
     jl.     u2.       ; normal:    goto testmore
     jl.     u2.       ; attention: goto testmore

e.                     ; end of data received
\f


; fpa-subproc          disc- and areatypes
; eli, 16.12.1975

; after create
;
; a disctype subproc has been created.
;
; the fields <chaintable> and <slice length> will later be
; initialized by procfunc when an internal process executes
; 'create bs'.
;
; upon entry
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q5:                    ; after create:

; adjust maximum buffer size to an integral number of segments

     rl. w0  q12.      ;
     la  w0  x1+p18    ;  size(subproc):= size(subproc)//512*512
     rs  w0  x1+p18    ;

     jl      (b101)    ;  goto return

e.                     ; end of create
\f

; fpa-subproc          disc- and areatypes
; eli, 22.1.1976

; procedure prepare consecutive area
;
; makes the pointers <updated first> and <last> in the
; messagebuffer describe a storage area corresponding to
; a number of consecutive disc segments
;
;        call          return
; w0                   undefined
; w1     subproc(disc) unchanged
; w2     message       unchanged
; w3     link          undefined

b. i10, j10
w.

q10: ds. w3  j1.       ; prepare consecutive area:
     rl  w0  x2+16     ;  save message and link
     rs  w0  x2+14     ;  first phys segm(mes):= next phys segm(mes)
     al  w3  0         ;  slice:= next phys segm(mes)/slicelength(subproc)+
     wd  w0  x1+s3     ;  
     wa  w0  x1+s2     ;  chaintable(subproc)
     rl  w3  x2+18     ;
     rl  w2  x1+s3     ;  length:= slicelength(subproc)*512
     ls  w2  9         ;
     ds. w3  j3.       ;
     am.     (j0.)     ;
     rl  w3  +12       ;
     wa. w3  j2.       ;  addr:= last addr(mes)+ length

; scan slicetable as long as a slice with content 1 is encountered

i0:  bz  w2  (0)       ;  while chaintable(slice)=1 and
     sn  w2  1         ;        addr<saved last(mes) do
     sl. w3  (j3.)     ;  begin
     jl.     i1.       ;
     ba. w0  1         ;   slice:= slice+1
     wa. w3  j2.       ;   addr:= addr+length
     jl.     i0.       ;  end

; dataarea at user exhausted or nonconsecutive segments

i1:  rl. w2  j0.       ;  restore message
     sl. w3  (j3.)     ;  if addr<saved last(mes) then
     jl.     i2.       ;  begin nonconsecutive, more to send.
     rs  w3  x2+12     ;   last(mes):= addr
     ba  w0  (0)       ;   next phys segm(mes):= (next slice(slice)-
     ws  w0  x1+s2     ;      chaintable(subproc))*slicelength(subproc)
     wm  w0  x1+s3     ;
     rs  w0  x2+16     ;  
     jl.     (j1.)     ;  end else
     
i2:  rl  w0  x2+18     ;   last addr(mes):= saved last(mes)
     rs  w0  x2+12     ;

; return

     jl.     (j1.)     ;  goto return

; working locations

j0:  0                 ;  saved message
j1:  0                 ;  saved link
j2:  0                 ;  length (i.e. slicelength*512)
j3:  0                 ;  saved last address(mes)

e.                     ; end of prepare consecutive area
\f




e.                     ; end of disc- and areatypes

z.                    ;

h106=h100
\f


; fpa-subproc          discette
; jr, 78.08.22

; stepping stone:
     jl.     u3. , u3=k-2
     jl.     u12., u12=k-2
     jl.     u4.  , u4=k-2
     jl.     u14. , u14=k-2
     jl.     u30. , u30=k-2
     jl.     u40. , u40=k-2

c.(:a80>15 a.1 :)-1   ; if floppy disc bit then include


b. q20,s10,n10 w.

; this subdriver is used for links to discettes. it differs from the
; 'standard type driver' in these ways:
;   - the stopcount of a sender that wants to input is raised
;     already in entry 1 to prevent a stopped sender when receiving in
;     entry 3.
;   - if sender is stopped (only when inputting or outputting) in entry 1,
;     the state of the process is set to 'stopped' which causes all messages
;     (except reset) to be answered immediately with status stopped.

; note: this driver cannot handle links with more than one operation.

m.                flexible disc link

; entry point table:
h122:                  ; discette:

             q0        ;  after send message
             q1        ;  before header transmit
             q2        ;  after header transmit
             q3        ;  after header received
             q4        ;  after data received
             q5        ;  after creation

; definition of privat part of process description:

   s0=p0               ; state

; state :  0   running
;          2   waiting for stop
;          4   stopped

\f


; fpa-subproc         discette
; jr, 78.08.22

; after send message 
;
; a new message has been received. check that user- or reservation
; status is ok and link message to queue of subproc.
; if state is stopped and if operation is odd then
; deliver answer with status stopped.
; if operation is reset then state is changed to running.
; if the subproc is not busy, then link it to mainproc.
; 
; upon entry: w1=subproc

b. i10,j10 w.

q0:                    ; after send message:
     jl. w3  u4.       ;   check and link operation;
     rl  w3  x1+s0     ;   
     jl.     x3+i0.    ;   goto case state of
i0:  jl.     u2.       ;    ( 0: testmore,
     jl.     j2.       ;      2: exit0,
                       ;      4: stopped);

j0:  am     (b18)      ; stopped:
     bz  w0  +8        ;
     sz  w0  2.1       ;  if operation is odd
     jl.     j1.       ;  then deliver result stopped;
     sn  w0  0         ;  else if not sense then goto test more;
     jl.     u2.       ;
     se  w0  2         ;   if operation(mess)=reset then
     jl.     j1.       ;     state:=running;
     al  w0  0         ;     goto testmore;
     rs  w0  x1+s0     ;
     jl.     u2.       ;
j1:  jl. w3  n0.       ;   deliver result(stopped);
j2:  jl     (b101)     ; exit0: return;

e.                     ; end of after send message
\f


; fpa-subproc          discette
; jr, 78.08.22

; before header
;
; a header (and maybe a corresponding datablock) is to be transmitted.
; find first non-processed message in queue of subproc and initialize
; transmit-parameters in mainproc.
;
; upon entry: w1=subproc

b. i10,j10 w.

q1:                    ; before header:
     jl. w3  u20.      ;   test answer attention;
     jl. w3  u12.      ;   mes:= first pending message;
     sn  w2  0         ;   if mes=0 then
     jl.     u3.       ;     goto no block;

; message found.

     bz  w0  x2+8      ;
     so  w0  2.1       ;   if odd operation then
     jl.     j0.       ;     examine sender(mess);
     jl  w3  g34       ;      stopped: goto stopped;
     jl.     j1.       ;      ok:

j0:  jl. w3  u30.      ;   prepare transfer;
     bz  w0  x2+8      ;
     so  w0  3         ;   if operation=input then
     jl      (b101)    ;
     jl. w3  u21.      ;   test and increase stopcount;
             -1        ;    stopped: impossible (checked above(g34));
     jl      (b101)    ;   goto mainproc return;

j1:  jl. w3  n1.       ; stopped: check queue;
     jl.     u3.       ;    queue not empty: goto no block;
     jl. w3  n2.       ;    queue empty: clean mess queue;
     jl.     u3.       ;    end: goto no block;
     al  w0  0         ;    reset:
     rs  w0  x1+s0     ;   state:=running;
     jl.     j0.       ;   goto prepare;

e.                     ; end of before header
\f

; fpa-subproc          discette
; jr, 78.08.22

; after header and data transmitted
;
; entered by mainproc, when a header and a corresponding datablock
; (if any) has been transmitted.
; the result of the transmission is checked and if an error has
; occured, the message is returned with result=4 (receiver
; malfunction).
;
; finally the state of the subproc is checked for transmission of a
; new block.

b. i10,j10 w.

q2:  jl. w3  u40.      ; after header: test header transmitted
     jl.     u2.       ; error: goto testmore
     jl.     u2.       ;  goto testmore

e.                     ; end of header and data transmitted
\f

; fpa-subproc          discette
; jr, 78.08.22

; after header received
;
; a header has been received.
; for this kind of subprocs (with no special actions) it can
; only specify the functions <answer input with data> or
; <answer message with data>.
;
; upon entry: w1=subproc

b. i10,j10 w.

q3:  jl. w3  u50.      ; after header received: test answer header
     jl.     u2.       ;  goto testmore

e.                     ; end of after header received
\f

; fpa-subproc          discette
; jr, 78.08.22

; after data received
;
; check transmission.
;
; upon entry: w1=subproc

b. i10,j10 w.

q4:  jl. w3  u60.      ; after data received: test data received
     jl.     u2.       ;  goto testmore

; attention. no special action

     jl.     u2.       ;  goto testmore

e.                     ; end of data received
\f

; fpa-subproc          discette
; jr, 78.08.22

; after create
;
; the subproc has just been created.
; no special action
;
; upon entry: w1=subproc

b. i10,j10 w.

q5:                    ; after create:
     jl      (b101)    ;  goto return

e.                     ; end of after create
\f


; special procedures used in the discette driver.

; procedure deliver stopped answer.
; the message buffer defined in b18 is returned to the sender with 
; status = stopped and bytes, chars transferred = 0, 0.
;        call:         return:
; w0                   destroyed
; w1                   proc
; w2                   destroyed
; w3     link          destroyed

b.w.

n0:  al  w0  1<8       ; deliver stopped answer:
     rs  w0  g20       ;   status(answer):=stopped;
     al  w0  0         ;   bytes trf(answer):=0;
     rs  w0  g21       ;   chars trf(answer):=0;
     rs  w0  g22       ;   deliver answer;
     jl      g18       ; exit: return to link;
e.

; procedure check queue.
; if the message entry table is empty (=> no operations under execution
; in the net) the message buffers in the event queue are returned with
; answer stopped until either the queue is empty or a reset operation is
; met.
; the procedure returnes to link+2 when the queue is emptied and a reset
; operation is found, else to link.
; by return the state is
;        0   event queue emptied and reset found
;        2   message entry table not empty
;        4   event queue emptied
;        call:         return:
; w0                   destroyed
; w1     proc          unchanged
; w2                   destroyed
; w3     link          destoyed

b.j4 w.
n1:  al  w0  0         ; check queue:
     al  w2  x1+p19    ;
j0:  se  w0 (x2)       ;   for entry:=first in entry table to last do
     jl.     j1.       ;   if entry used then
     al  w2  x2+2      ;       goto not empty;
     se  w2  x1+p19+v0*2;
     jl.     j0.       ;
     am      4-2       ; empty: state:=stopped;
j1:  al  w2  2         ; not empty: state:=waiting for stop;
     rs  w2  x1+s0     ;
     am      x2-2      ;
     jl      x3        ; exit: return to link+state-2;
e.

; procedure clean mess queue.

b.i6,j6 w.
n2:  rs. w3  i0.       ; clean mess queue:
j0:  jl. w3  u12.      ;   for mess:=first in mess queue until last do
     sn  w2  0         ;     if operation(mess)=reset then
     jl.    (i0.)      ;       return to link+2;
     bz  w0  x2+8      ;
     sn  w0  2         ;
     jl.     j1.       ;
     jl. w3  n0.       ;
     jl.     j0.       ;
j1:  am.    (i0.)      ;
     jl      +2        ;
i0:   0                ;
e.


e.                     ; end of discette driver.

z.                     ;

h122=h100
\f

; fpa-subproc          character level i/o
; ncj, 02.01.1980
  

b. q20, s10
w.
  
; this code handles fpa i/o on character level and is used by fpa
; test programs.
  
; messages received must have the following format:
;
;      +8: operation<12 + mode
;     +10: first
;     +12: last
;     +14: characters
;
 
m.                character level i/o link

; entry point table:
h124:
             q0        ;  after send message
             q1        ;  before header transmit
             q2        ;  after header transmit
             q3        ;  after header received
             q4        ;  after data received
             q5        ;  after creation

; no structure of private part of process description required
\f

; fpa-subproc          character level i/o
; ncj, 2.01.1980

; after send message 
;
; a new message has been received. check that user- or reservation
; status is ok and link message to queue of subproc.
; if the subproc is not busy, then link it to mainproc.
; 
; upon entry:
; w0
; w1     subproc
; w2  
; w3     

b. i10, j10
w.
q0:                    ; after send message:
     jl. w3  u4.       ;  check and link operation
     rl  w2  b18       ;  mes:= current message;
     al  w0  2         ;  size:=
     wa  w0  x2+12     ;        last(mes) - first(mes) + 2;
     ws  w0  x2+10     ;
     jl. w3  u14.      ;  convert to 8bit(size);
     ws  w0  x2+14     ;  rem:= size - chars(mes);
     sl  w0  0         ;  if rem < 0 or
     sl  w0  3         ;     rem > 2
     jl.     j0.       ;     then deliver result 3;
     bz  w0  x2+8      ;  oper:= operation(mes);
     se  w0  3         ;  if oper = input or
     sn  w0  5         ;     oper = output
     jl.     u2.       ;     then goto testmore
j0:  al  w0  3         ;     else deliver result 3;
     jl  w3  g19       ;
     jl.     u2.       ;  goto testmore;
  
e.                     ; end of after send message
\f

; fpa-subproc         character level i/o
; ncj, 2.01.1980

; before header
;
; a header (and maybe a corresponding datablock) is to be transmitted.
; find first non-processed message in queue of subproc and initialize
; transmit-parameters in mainproc.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.
q1:                    ; before header:
     jl. w3  u20.      ;  test answer attention
     jl. w3  u12.      ;  w2:=mes:= first pending message
     sn  w2  0         ;  if mes=0 then
     jl.     u3.       ;   goto no block.

; message found. initiate transfer

     jl. w3  u30.      ;  prepare transfer
     rl  w3  x1+a50    ;  main:= main(subproc);
     rl  w0  x2+14     ;  chars:= chars(mess);
     sl  w0 (x3+p64)   ;  if chars < header size(main) then
     jl     (b101)   ;
     rs  w0  x3+p64    ;    header size(main):= chars;
     rs  w0  x2+20     ;    expected size(mes):= chars;
     bz  w1  x2+8      ;    oper:= operation(mes);
     sn  w1  5         ;    if oper = output
     rs  w0  x3+p66    ;       then data size(main):= chars;
    jl     (b101)   ;

e.                     ; end of before header
\f

; fpa-subproc          character level i/o
; ncj, 2.01.1980

; after header and data transmitted
;
; entered by mainproc, when a header and a corresponding datablock
; (if any) has been transmitted.
; the result of the transmission is checked and if an error has
; occured, the message is returned with result=4 (receiver
; malfunction).
;
; finally the state of the subproc is checked for transmission of a
; new block.

b. i10, j10
w.

q2:  jl. w3  u40.      ; after header: test header transmitted
     jl.     u2.       ; error: goto testmore
     jl.     u2.       ;  goto testmore

e.                     ; end of header and data transmitted
\f

; fpa-subproc          character level i/o
; ncj, 2.01.1980

; after header received
;
; a header has been received.
; for this kind of subprocs (with no special actions) it can
; only specify the functions <answer input with data> or
; <answer message with data>.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3 

b. i10, j10
w.

q3:  jl. w3  u50.      ; after header received: test answer header
     jl.     u2.       ;  goto testmore

e.                     ; end of after header received
\f

; fpa-subproc          character level i/o
; ncj, 2.01.1980

; after data received
;
; check transmission.
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q4:  jl. w3  u60.      ; after data received: test data received
     jl.     u2.       ;  goto testmore

; attention. no special action

     jl.     u2.       ;  goto testmore

e.                     ; end of data received
\f

; fpa-subproc          character level i/o
; ncj, 2.01.1980

; after create
;
; the subproc has just been created.
; no special action
;
; upon entry:
; w0
; w1     subproc
; w2
; w3

b. i10, j10
w.

q5:                    ; after create:
     jl      (b101)    ;  goto return

e.                     ; end of after create

e.                     ; end of character level i/o



; end of subprocess-code
;***********************

e.

; end of fpa-driver code
;***********************

e.
\f


z.    
c. -(:a80>8 a.1 :)  ; if not fpa then  
b89  = -1000  ; define standart return point
z.
▶EOF◀