$CONTROL MAP,CODE,USLINIT                                               00010000
<<IOTERM0 - MODULE 22>>                                                 00015000
<< HP32002C MPE SOURCE C.00.00 >>                                       00020000
<< COPYRIGHT     "(C) COPYRIGHT HEWLETT-PACKARD CO. 1980.           >>  00025000
<<     THIS PROGRAM MAY BE USED WITH ONE COMPUTER SYSTEM AT A       >>  00030000
<<     TIME AND SHALL NOT OTHERWISE BE RECORDED, TRANSMITTED OR     >>  00035000
<<     STORED IN A RETRIEVAL SYSTEM.  COPYING OR OTHER REPRODUCTION >>  00040000
<<     OF THIS PROGRAM EXCEPT FOR ARCHIVAL PURPOSES IS PROHIBITED   >>  00045000
<<     WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT-PACKARD COMPANY.>>  00050000
<< **** Note - Dollar Copyright cannot be used with this module *** >>  00055000
$TITLE " MAY 27,1976   ASYNCHRONOUS TERMINAL MONITOR"                   00060000
$CONTROL PRIVILEGED, UNCALLABLE, MAIN = IOTERM0                         00065000
$THIRTY                                                                 00070000
  <<                                                                    00075000
       TERMINAL REQUESTS -                                              00080000
                                                                        00085000
  OPERATION         FUNC         PARAMETERS                             00090000
                                                                        00095000
    READ             0    P1.( 0:1)  = NOCRLF IF SET                    00100000
                            .(13:3)  = EOF  SPECIFICATION               00105000
                                                                        00110000
                          P2.(0:8 ) - IF <> 0 THEN SPECIAL RD STOP CHAR 00115000
                            .(11:2) - IF 0 THEN ASCII ELSE BINARY       00120000
                            .(10:1) - OWN DC1/DC2 HANDSHAKE             00125000
                                                                        00130000
                                                                        00135000
    WRITE            1    P1 - VERTICAL FORMAT SPECIFICATION            00140000
                                                                        00145000
                                  1 - USE 1ST DATA CHAR AS FORMAT SPEC  00150000
                                                                        00155000
                                %53 - "+", CR ONLY NO LF                00160000
                                %60 - "0", DOUBLE SPACE                 00165000
                                %61 - "1", TOP OF FORM                  00170000
                                                                        00175000
                                %200-%277,  N-%200 LF'S AND A CR        00180000
                                                                        00185000
                                %320- NO CR OR LF                       00190000
                                                                        00195000
                              ALL OTHERS, DO A CR/LF                    00200000
                                                                        00205000
                          P2.(15:1) - PRESPACE FLAG                     00210000
                            .(11:2) - IF NOT 0 THEN BINARY              00215000
                                                                        00220000
                                                                        00225000
  FILE OPEN      2    IF ONLINE NOP ELSE ALLOCATE WITH DEFAULT <<00190>>00230000
  FILE CLOSE         3    CLEAN UP AND CRLF IF NOT NEW LINE             00235000
  DEVICE CLOSE       4    DISCONNECT                                    00240000
                                                                        00245000
  SET READ TIMEOUT   5    P1 - IF 0 CLEAR TIMEOUT ELSE TIME IN SECONDS  00250000
                                                                        00255000
  SET INPUT SPEED    6    P1 - SPEED IN CHARACTERS/SECOND               00260000
                                OLD SPEED RETURNED IN COUNT             00265000
  SET OUTPUT SPEED   7    P1 - SPEED IN CHARACTERS/SECOND               00270000
                                OLD SPEED RETURNED IN COUNT             00275000
                                                                        00280000
  ENABLE ECHO        8    RETURN OLD ECHO SETTING IN COUNT              00285000
  DISABLE ECHO       9    RETURN OLD ECHO SETTING IN COUNT              00290000
                                                                        00295000
  DISABLE BREAK      10                                                 00300000
  ENABLE  BREAK      11                                                 00305000
                                                                        00310000
  DISABLE CONTROL Y  12                                                 00315000
  ENABLE CONTROL Y   13                                                 00320000
                                                                        00325000
  DISABLE TAPEMODE   14                                                 00330000
  ENABLE  TAPEMODE   15                                                 00335000
                                                                        00340000
  DISABLE READ TIMER 16                                                 00345000
  ENABLE READ TIMER  17                                                 00350000
  RETURN READ TIME   18   COUNT CONTAINS READ TIME IN 1/100 SECONDS     00355000
                                                                        00360000
DISABLE PARITY CHK 19   INVALID IF TTYPE OF 8-BIT DATA         <<AMS00>>00365000
                        SEND/RECEIVE DEVICE (HP2635/45K)       <<AMS00>>00370000
ENABLE PARITY CHK  20   INVALID IF TTYPE OF 8-BIT DATA         <<AMS00>>00375000
                        SEND/RECEIVE DEVICE(HP2635/45K)        <<AMS00>>00380000
                                                                        00385000
  LOGGED ON          21   P1 - IF 1 THEN SESSION, SO ENABLE BREAK       00390000
                               IF 2 THEN JOB, NO BREAK         <<00163>>00395000
                               IF 0 THEN DATA, NO BREAK        <<00163>>00400000
                                                                        00405000
  NOT USED           22                                                 00410000
  SET TERM TYPE      23   P1 - TERM TYPE AS SPECIFIED IN THE MPE ERS    00415000
                                                                        00420000
  ALLOCATE TERMINAL  24   P1 - TERM TYPE AS SPECIFIED IN THE MPE ERS    00425000
                          P2 - SPEED IN CHARACTERS/SECOND               00430000
                                                                        00435000
  CLR FLUSH & WRITE  25   PARAMETERS SAME AS WRITE                      00440000
                                                                        00445000
  CNTRL X ECHO ON    26                                                 00450000
  CNTRL X ECHO OFF   27                                                 00455000
                                                                        00460000
  NO OPERATION       28                                                 00465000
                                                                        00470000
  PTAPE READ         29   P1, P2 - SPOOL BUFFER BEGINNING DISC ADDRESS  00475000
                                                                        00480000
  SET BREAK MODE     30   P1 - ODD = SET, EVEN = CLEAR BREAK MODE       00485000
                                                                        00490000
  SET CONSOLE MODE   31   P1 - ODD = SET, EVEN = CLEAR CONSOLE MODE     00495000
                                                                        00500000
  SET PARITY         32   P1 - 0  - NO PARITY GENERATE, BIT 8 ALWAYS 0  00505000
                               1  - NO PARITY GENERATE, BIT 8 ALWAYS 1  00510000
                               2  - EVEN PARITY ON WRITE, EXPECTED ON RD00515000
                               3  - ODD PARITY ON WRITE,EXPECTED ON READ00520000
  ******NOTE: FUNC. INVALID IF TTYPE=HP2635/45K****************<<AMS00>>00525000
                                                                        00530000
  ALLOCATE TERMINAL  33   P1 - TERM TYPE AS SPECIFIED IN THE MPE ERS    00535000
                          P2 - SPEED IN CHARACTERS/SECOND               00540000
                                                                        00545000
  SET TERM TYPE      34   P1 - TERM TYPE AS SPECIFIED IN THE MPE ERS    00550000
                                                                        00555000
  RETURN TERM TYPE   35   TERMINAL TYPE RETURNED IN COUNT WORD          00560000
                                                                        00565000
  RETURN OUT SPEED   36   OUTPUT SPEED RETURNED IN COUNT WORD           00570000
                                                                        00575000
  SET STOP CHARS     37   P1 - IF 0 THEN DISABLE SPECIAL EOR AND        00580000
                               SUBSYSTEM BREAK CHARACTERS ELSE          00585000
                            .(0:8) = SUB SYSTEM BREAK CHARACTER         00590000
                            .(8:8) = END OF RECORD CHARACER             00595000
                                                                        00600000
  SET CONS INTERRUPT 38   P1 - ODD,ENABLE CNTRL A; EVEN DISABLE CNTRL A 00605000
                                                                        00610000
                                                                        00615000
                                                                        00620000
                                                                        00625000
    TERMINAL STATUS RETURNS -                                           00630000
                                                                        00635000
      %00  - NOT COMPLETED OR NOT STARTED                               00640000
                                                                        00645000
       01  - NORMAL COMPLETION                                          00650000
       11  - COMPLETED ON SPECIAL READ STOP CHARACTER                   00655000
                                                                        00660000
       X2  - END OF FILE                                                00665000
                                                                        00670000
       13  - PARITY ERROR ON READ                                       00675000
     14  - TRANSMISSION ERROR (RETUNED FROM 2631B  ONLY)       <<01781>>00680000
       23  - READ TIMED OUT                                             00685000
       33  - I/O ABORTED EXTERNALLY                                     00690000
       43  - DATA LOST, NO BUFFER AVAILABLE OR TOO LONG TAPEMODE RECORD 00695000
       53  - NOT ON LINE, DATA SET NOT READY OR DISCONNECT              00700000
      153  - ENABLE SUB SYS BRK REQUESTED & NO CY PIN                   00705000
      163  - READ TIME RETURNED > (2**16-1) HUNDREDTHS                  00710000
      173  - READ STOPPED WHEN A BREAK DETECTED                         00715000
                                                                        00720000
       04  - INVALID REQUEST, FUNCTION OR PARAMETER                     00725000
       24  - BLOCK MODE READ TIMED OUT                         <<02004>>00730000
       34  - TIMING ERROR, UNIT WAS NOT SERVICED IN TIME                00735000
  >>                                                                    00740000
$PAGE                                                                   00745000
BEGIN    << TERMINAL MONITOR AND DRIVER >>                              00750000
                                                                        00755000
EQUATE                                                                  00760000
    ABORTED   =%33,        << REQUEST ABORTED RETURN STATUS >>          00765000
    ABORTSTOP = 5,         << READ ABORTED STOP >>                      00770000
    ACTIVE'   = 2,         << MONITOR IS RUNNING AGAINST THIS DEVICE >> 00775000
    AJOBS'    = 2,         << THIS DEVICE ACCEPTS JOBS >>               00780000
    ALLOCATE  =24,         << ALLOCATE TERMINAL FUNCTION  CODE >>       00785000
    ALLOCATEX =33,         << ALLOCATE TERMINAL FUNCTION  CODE >>       00790000
    BADPARITY =%13,        << PARITY ERROR REQUEST ERROR STATUS >>      00795000
    BANDWAIT  = 5,         << WAITING FOR LESS TERM ACTIVITY >>         00800000
    BLOCKED'  = 5,         << BLOCKED I/O REQUEST >>                    00805000
    BLOCKTIMED= %24,       << BLOCK TIMEOUT STATUS >>          <<02004>>00810000
    BLOCKTIMEOUT= 8,       << TIMER TYPE >>                    <<02004>>00815000
    BLOCKTO   = 7,         << READ ERROR >>                    <<02004>>00820000
    BLOCKTOSTOP=6,         << READ STOP  >>                    <<02004>>00825000
    BMODE'    =12,         << TERMINAL IN BREAK MODE >>                 00830000
    BREAK'    = 10,        << BREAK IS ALLOWED AND HAS BEEN DETECTED >> 00835000
    BRKEND    = 2,         << READ ENDED WITH BREAK STATUS INDEX >>     00840000
    BREAKEND  =%173,       << READ COMPLETED WHEN A BREAK DETECTED >>   00845000
    BREAKSTOP = 1,         << READ STOP CODE AFTER BREAK ACCEPTED >>    00850000
    BRKOK'    =BREAK'+1,   << BREAK IS ENABLED >>                       00855000
    CFAILTO   = 1,         << CARRIER FAIL TIME OUT REQUEST >>          00860000
    CLOSED    = 4,         << DCLOSE REQUESTED HSTATE >>                00865000
    CMODE'    =11,         << TERMINAL IS IN CONSOLE MODE >>            00870000
    COMPLETED'= 6,         << I/O REQUEST HAS BEEN COMPLETED >>         00875000
    CONSMODE  = 2,         << TMODE OR PREMPT LEVEL OF CONSOLE >>       00880000
    CPCB      = 4,         << CURRENT PCB INDEX >>                      00885000
    CR        = %15,       << OCTAL VALUE OF CARRAGE RETURN >> <<01469>>00890000
    DBREAK    =30,         << IOQP TO SAVED BROKEN READ DATA >>         00895000
    DCNT      = 18,        << COUNT OF BUFFER BEING WRITTEN , ALSO      00900000
                                HOLDS SPEED DURING SPEED SENSING >>     00905000
    DHEAD     = 19,        << SYSDB POINTER TO HEAD OF TBUF LIST >>     00910000
    DILTP     = 5,         << ILT POINTER >>                            00915000
    DIOQP     = 2,         << IOQ POINTER TO FIRST REQUEST >>           00920000
    DISCNCT'  = 1,         << DATA SET HAS DISCONNECTED >>              00925000
    DLINK     = 1,         << DITP LINK TO QUEUED REQUESTS WAITING >>   00930000
    DLDEV     = 3,         << LOGICAL DEVICE AND UNIT NUMBERS >>        00935000
    DMONTR    = 33,        << HOLDS MONITORING CODE >>         <<00.06>>00940000
    DNXTB     = 25,        << TBUF POINTER OF A SAVE TBUF IF NOT 0 >>   00945000
    DPNTR     = 21,        << BYTE POINTER DURING READ & WRITE >>       00950000
    DRCNT     = 17,        << HOLDS COUNT OF READ DATA SAVED >>         00955000
    DRPTR     = 22,        << IF <> 0 THEN HEAD OF READ DATA SAVED >>   00960000
    DRQST     = 6,         << MONITOR SERVICE REQUEST FLAGS >>          00965000
                           << 0 - HANGUPTO    8  - READTO               00970000
                              1 - DISCONNECT  9  - ONLINE               00975000
                              2 - CFAILTO     10 - DSTREADY             00980000
                              3 - TURNTO      11 - LOGONTO              00985000
                              4 - IOERROR     12 - BREAK                00990000
                              5 - IODONE      13 - CONTROL Y            00995000
                              6 - SPOOLEND    14 - CFAIL                01000000
                              7 - SPOOLSW     15 - UNUSED               01005000
                           >>                                           01010000
    DRTMAX    =28,         << MAXIMUM TIME FOR READ TIMEOUT, SECONDS >> 01015000
    DRTIME    =26,         <<  INDEX TO I/O READ TIME >>                01020000
    DSAVE     =13,         << HOLDS WAITED DSTATE, HSTATE & TURN CHAR >>01025000
    DSTATE'   =12,         << DEVICE STATE                              01030000
                               0 - NULL         %10 - EOR SYNC          01035000
                               1 - WRITING      %11 - WRITE BUF FILL    01040000
                               2 - READING      %12 - SEND XON NEXT     01045000
                               3 - XON WRITE    %13 - DELETE CR         01050000
                               4 - WRITE TURN   %14 - DOING SYNCS OR "!"01055000
                               5 - BAND WAIT    %15 - READ CHAR ECHO    01060000
                               6 - EOR LF       %16 - START READ        01065000
                               7 - EOR CR       %17 - STOP READ >>      01070000
    DSTOP     = 14,        << SUB SYS BRK AND EOR CHARACTERS >>         01075000
    DSYNC     = 29,        << CR,LF SYNC DATA AND SYNC COUNTER >>       01080000
    DTAIL     = 20,        << SYSDB POINTER TO END OF TBUF LIST >>      01085000
    DTBLK     = 24,        << LINK WORD FOR QUEUED TBUF REQUESTS >>     01090000
    DTBUF     =18,         << FIRST TBUF POINTER  >>                    01095000
    DTBUFD    = DTBUF/2,   << DOUBLE INDEX TO FIRST TWO TBUF POINTERS >>01100000
    DTBF2     = DTBUFD+1,  << DBL INDEX TO DTBUF2, DISC ADDR IN PTAPE >>01105000
    DTRLX     = 31,        << HOLDS 2640/SPEED AND           >><<01448>>01110000
                           << LOGON/HANGUP/READ TIM.REQ.IND. >><<01448>>01115000
    DWAIT     = 15,        << DITP TO NEXT DEV ON ACTIVITY WAIT >>      01120000
    ECHO'     = 3,         << INPUT IS TO BE ECHOED TO OUTPUT CHANNEL >>01125000
    ECHOOFF   = 0,         << TURN ECHO OFF CODE TO MPXCONTROL >>       01130000
    ENQ       = 5,         << ENQ CHAR >>                      <<00234>>01135000
    EORLF     = 6,         << DSTATE - EOR LF IN PROGRESS >>            01140000
    EORSYNC   =%10,        << DSTATE EOR SEQUENCE START SYNC >>         01145000
    ESC       = %33,       << OCTAL VALUE OF ESCAPE CHAR >>    <<01469>>01150000
    FF        = %14,       << OCTAL VALUE OF FORM FEED CHAR >> <<01469>>01155000
     FILEOPEN  = 2,        << FILE OPEN FUNCTION CODE>>        <<00190>>01160000
    FINREAD   =%17,        << FINISH STOPPED READ DSTATE >>             01165000
    FMAX      = 38,        << MAXIMUM FUNCTION CODE >>                  01170000
    FORMFEED'  = 4,        << DEVICE RESPONDES TO A FORM FEED >>        01175000
    GOODIO    = 1,         << SUCCESSFUL I/O STATUS RETURN >>           01180000
    HANGINGUP = 7,         << DSET HANGUP DELAY IN PROGRESS >>          01185000
    HANGUP    = 3,         << HANG UP DSET CONTROL CODE >>              01190000
    HANGUPTURN= 6,         << HANGUP 202 TURN TK READ WAIT >>           01195000
    HANGUPTO  = 5,         << HANGUP TIMEOUT REQUEST TYPE >>            01200000
    HP2640TO  = 0,         << 2640/44 READ/WRITE TIME OUT REQUEST >>    01205000
    HP2635    = 15,        <<HP2635 8-BIT TTYPE>>              <<AMS00>>01210000
    HP2635A   = 15,        << HP2635 8 BIT TTYPE>>             <<00234>>01215000
    HP2631B   = 19,        << 2631B, 7 BIT DATA >>             <<01469>>01220000
    ISIOP     = 8,         << POINTS TO SIO PROGRAM AREA >>    <<01300>>01225000
    INITTO    = 7,         << SPEED SENSE DISCONNECTED TIME REQUEST >>  01230000
    INVALIDOP = 4,         << INVALID OPERATION REQUESTED >>            01235000
    IOQSIZE   =11,         << IOQ ELEMENT SIZE >>                       01240000
    IOWAIT    =%100,       << UNBLOCKED I/O WAIT >>                     01245000
    IOWAKE'   = 4,         << WAKE CALLER ON COMPLETION IF SET >>       01250000
    JMATdst   = 25,                                            <<01470>>01255000
    JMATsir   = 15,                                            <<01470>>01260000
    JUNKWAIT  = %20,                                                    01265000
    LDTDST    = 14,        << LOGICAL DEVICE TABLE DST NUMBER >>        01270000
    LOGGINGON = 2,         << HSTATE LOGGING ON >>                      01275000
    LOGONTO   = 4,         << LOG ON TIME OUT REQUEST TYPE >>           01280000
    LOSTCSTAT =%34,        << LOST CHARACTER REQUEST ERROR STATUS >>    01285000
    LOSTDATA  = 3,         << BUFFER NOT AVAILABLE >>                   01290000
    LOSTDSTAT =%43,        << LOST DATA REQUEST ERROR STATUS >>         01295000
    M202'     = 2,         << 202 OR 2002 MODEM >>                      01300000
    M202      =M202'+1,    << CIRCULAR SHIFT COUNT TO GET 202 TO BIT15>>01305000
    MAXSPEED  = 7,         << MAXIMUM SPEED INDEX >>                    01310000
    MAXTIO    = 12,        << MAX TERM I/O TO PREVENT BLOCK OVERRUNS >> 01315000
    NEWLINE'  = 8,         << LF WAS LAST CHARACTER OUTPUT >>           01320000
    NOEOFCHECK= 5,         << NO CHECK & KEEP ANY SAVED DATA >>         01325000
    NOCYPIN   =%153,       << ENABLE ESCAPE & NO CY PIN ERROR >>        01330000
    NOPTY'    = 2,         <<8-BIT DATA  FLAG-->>              <<AMS00>>01335000
                           <<SET IN 8TH BIT>>                  <<AMS00>>01340000
    NOTNEW    = 1,         << REQUEST PROCESSING HAS STARTED >>         01345000
    NOTREADING = 0,         << DEVICE NOT IN READING STATE >>  <<01.02>>01350000
    NOTRDYMSG = 11,        << CONSOLE MESAGE INDEX >>          <<01469>>01355000
    NOWAIT    = 0,         << DONT WAIT IN WAKE >>                      01360000
    NULL      = 0,                                                      01365000
    OFFLINE   =%53,        << DEVICE OFFLINE OR HUNGUP RETURN STATUS >> 01370000
    ONLINE    = 1,         << SPEED SENSED AND ONLINE HSTATE >>         01375000
    OPCONSOLE = 0,         << DIRECTS IOMESSAGE TO CONSOLE >>  <<01469>>01380000
    OUTSPD    = 7,         << SET OUT SPEED FUNCTION CODE >>            01385000
    PCB3      = 3,         << FOURTH WORD OF PCB >>                     01390000
    PCB9      = 9,                                                      01395000
    PCBSIZE   =16,                                                      01400000
    POSTSPACE =%33,        << RSTATE, POSTSPACE TBUF WAIT >>            01405000
    PREMPT'   = 0,         << A PREMPTIVE REQUEST IS IN THE QUEUE >>    01410000
    PREMPTSTOP= 3,         << STOP READ FOR PREMPTIVE REQUEST >>        01415000
    PRESPLAST'=13,         << LAST WRITE WAS A PRESPACE >>              01420000
    PRESPACE  =%31,        << REQUEST WAITING FOR TBUF FOR PRESPACE >>  01425000
    PRETOPOST =%30,        << ADDING A CR/LF IN PRE TO POST SPACING >>  01430000
    PRIMARY   = 1,         << GET ONLY FROM PRIMARY TABLE >>            01435000
    PTYCHK'   = 9,         << PARITY CHECK READS >>                     01440000
    PTYCNTRL' = 7,         << PARITY IS TO BE SENT IN 8TH BIT >>        01445000
    PTYERROR  = 5,         << READ PARITY ERROR >>             <<01.02>>01450000
    QADDR     = 5,         << TARGET BANK OF DST OFFSET >>              01455000
    QDSTN     = 4,         << BANK OR DST NUMBER >>                     01460000
    QFUNC     = 6,         << FUNCTION  >>                              01465000
    QLINK     = 1,         << NEXT IOQ POINTER >>                       01470000
    QMISC     = 3,         << MISCELLANEOUS STORAGE >>                  01475000
    QPAR1     = 8,         << READ EOF CONTROL; WRITE SPACE CONTROL >>  01480000
    QPAR2     = 9,         << READ STOP CHAR; WRITE PRESPACE FLAG >>    01485000
    QP1D      = QPAR1/2,   << DOUBLE INDEX TO QPAR1 AND QPAR2 >>        01490000
    QSTAT     =10,         << REQUEST STATUS AND PCB NUMBER >>          01495000
    QWBCT     = 7,         << WORD (+) OR BYTE (-) COUNT >>             01500000
    READING   = 2,         << DSTATE- READ IN PROGRESS >>               01505000
    READTO    = 6,         << READ TIMED OUT READERRORS CODE >>         01510000
    HP2635B   = 16,        << HP2635 7 BIT TTYPE>>             <<00234>>01515000
    READTIMEOUT= 3,        << READ TIME OUT REQUEST TYPE >>             01520000
    READTOSTOP= 4,         << STOP READ AFTER READ TIME OUT >>          01525000
    READWAITING= 5,        << READ WAITING TO START AFTER WRITE DONE >> 01530000
    REQUEST'  = 3,         << MONITOR SERVICE REQUESTED WHILE ACTIVE >> 01535000
    RESET31   = 6,         << REQ STATE WHEN RESETTING 31B >>  <<01469>>01540000
    RTOVERFLOW=%163,       << READ TIME RETURNED TO LARGE ERROR >>      01545000
    SENDXON   =%12,        << READ TO BE ACTUALLY STARTED DSTATE >>     01550000
    SESSION   = 1,         << JOB TYPE IS A SESSION >>                  01555000
    SIOSIZE   = 8,                                             <<01469>>01560000
    SIOSIZED2 =(SIOSIZE+1)/2, <<FIX B.O. FIX FOR ILT'S>>       <<01469>>01565000
    SOFTKILL  =%20,        << SOFT KILL FLAG >>                         01570000
    SOFTPREMPT=3,          << PREMPT READS IF NOTHING INPUT SO FAR >>   01575000
    SPECIALEND=%11,        << TERM READ TERMINATE ON SPECIAL CHAR >>    01580000
    SPDSENSING'= 4,        << DEVICE IS IN DIAGNOSTIC OR SPD SNSE MODE>>01585000
    SPEEDTO   = 6,         << SPEED SENSING TIMEOUT TYPE >>             01590000
    SPOOLING' = 5,         << PTAPE READ IN PROGRESS >>                 01595000
    SSBREAK'  = 4,         << SUB SYS BRK IS ALLOWED &  HAS BEEN DET. >>01600000
    SSBRKSTOP = 2,         << SUB SYSTEM BREAK READ STOP CODE >>        01605000
    SSBRKOK'  =SSBREAK'+1, << SUB SYS BRK IS ENABLED >>                 01610000
    STARTREAD =%16,        << TIP TO START READ NEXT >>                 01615000
    SYSBUFR'  =  3,        << REQUEST DATA IS IN SYSTEM BUFFERS >>      01620000
    SYSDISK   = 1,         << SYSTEM DISK LOGICAL DEVICE # >>           01625000
    SYSDB     =%1000,                                                   01630000
    SYSDB1    = SYSDB + 1,                                              01635000
    SYSDST    = 2,                                             <<00.05>>01640000
    SYSLPDT   =%10,        << LOGICAL PHYSICAL DEVICE TABLE >>          01645000
    SYSPCB    = 3,                                                      01650000
    SYSSBUF   = 6,                                                      01655000
    TAPEMODE' = 0,         << PAPER TAPE READ MODE;NO EDIT RESPONSES >> 01660000
    TBMAXB    = 30,        << TBUF SIZE IN BYTES >>                     01665000
    TBQN      = 0,         << RESOUCE QUEUE # FOR TBUF REQUESTS >>      01670000
    TBMAXW    = TBMAXB/2,  << TBUF SIZE IN WORDS >>                     01675000
    TBWAIT    =%32,        << REQUEST WAITING FOR TBUF OR TBUF SPACE >> 01680000
    TDITSIZE  = 37,        << TERM DIT SIZE >>                 <<01469>>01685000
    TIMEDOUT  =%23,        << READ TIMED OUT REQUESTERROR STATUS >>     01690000
    TQUEUE    = DLINK,     << RESOUCE NUMBER OF TERMINAL I/O QUEUE >>   01695000
    TRANSMIT  = 4,         << FINSH TURNING 202 TO WRITE STATE >>       01700000
    TURN202    = 4,        << DSTATE, TURNING 202 TO READ OR WRITE >>   01705000
    TURNTO     = 2,        << 202 TURN AROUND TIME OUT TYPE >>          01710000
    UNDEFINED =%37,        << UNDEFINED TERMINAL TYPE >>                01715000
    UP'       = 1,         << ON LINE,SPEED SENSED AND CAN DO I/O >>    01720000
    WAITED    =%11,        << READ/WRITE/BANDWAIT HELD FOR BREAK >>     01725000
    WRITING   = 1,         << DSTATE IS WRITING >>                      01730000
       WRITEWAIT = 7,         <<RQSTATE FOR 2631B WRITES>>     <<01781>>01735000
    WRTCHAN   =-1,         << FLAG TO INDICATE WRITE CHANNEL MPXCNTRL >>01740000
    YCINTRPT  = 2,         << CONTROL Y PSEUDOINTERRUPT FLAG >>         01745000
    XONWRIT   = 3,         << DSTATE XON WRITE >>                       01750000
  ENDEQ       = 0;                                                      01755000
                                                                        01760000
  DEFINE                                                                01765000
    ABS       =ABSOLUTE#,                                               01770000
    ACCEPTING =(AJOBS':2)#,<< ACCEPTING JOBS AND DATA FIELDS IN LPDT >> 01775000
    ACKWAIT   = (11:1)#,                                       <<01468>>01780000
    ACTIVE    =(ACTIVE'  :1)#,                                          01785000
    ASMB      = ASSEMBLE#,                                              01790000
    BINARY    =(11:2)#,    << IF 0 THEN ASCII ELSE BINARY READ >>       01795000
    BLOCKED   =(BLOCKED':1)#,<< BLOCKED, WAIT CALLER UNTIL COMPLETION >>01800000
    BMODE     =(BMODE':1)#,<< TERMINAL IN BREAK MODE >>                 01805000
    BRKOK     =(BRKOK':1)#,                                             01810000
    BWRITE    =( 7:1)#,    << BINARY WRITE, PTY DISABLE >>              01815000
    CB        = ( 5:1)#,   << CLEAR TO SEND, REQST TO SEND DELAYED >>   01820000
    CF        =( 4:1)#,    << CARRIER DETECTED IF SET >>                01825000
    CFAILCNT  =( 4:6)#,    << CARRIER FAILURE COUNTER >>                01830000
    CMODE     =(CMODE':1)#,<< TERMINAL IN CONSOLE MODE >>               01835000
    COMPLETED =(COMPLETED':1)#,   << REQUEST COMPLETED >>               01840000
    CYPIN     =( 8:8)#,    << SUB SYSTEM BREAK PIN IN LDT >>            01845000
    CONSINTRPT=(11:1)#,    << CONSOLE INTERRUPT OK IF SET >>            01850000
    DEVREC    =( 0:2)#,    <<  DEVICE RECOGNITION STATE >>              01855000
    DISABLE   = ASSEMBLE( SED 0 )#,                                     01860000
    DISCNCT   =(DISCNCT' :1)#,                                          01865000
    DLDEVN    =(8:8)#,     << LOGICAL DEVICE NUMBER OF DIT >>           01870000
    DSTATE    =(DSTATE'  :4)#,                                          01875000
    DPAGEEJECT=DITPL(DMONTR).(3:1)#, << 1 -> AUTO EJECT >>     <<01469>>01880000
    DSTFIELD  =(1:10)#,    << DST NUMBER EXTRACT FROM PCB >>            01885000
    ECHO      =(ECHO':1)#,                                              01890000
    ENABLE    = ASSEMBLE( SED 1 )#,                                     01895000
    ENQACKWAIT=(11:1)#,    << 2640 WRITE ENQ/ACK WAIT >>                01900000
    EOFCODE   =(13:3)#,    << EOF CHECK SPECIFICATION >>                01905000
    ESIZE     =(8:8)#,     << TABLE ENTRY SIZE >>                       01910000
    FILLING   =(10:1)#,    << TERM IS FILLING TBUFS WITH WRITE DATA >>  01915000
    FLUSH     =( 0:1)#,    << FLUSH AFTER BREAK OR CONTROL Y >>         01920000
    FORMFEED  =(FORMFEED':1)#,                                          01925000
    FUNC      =( 8:8)#,    << QFUNC, FUNCTION CODE >>                   01930000
    HSTATE    =( 4:3)#,    << HANG UP STATE                             01935000
                               0 - HUNGUP       3 - HNGP SPD SNS DISCNCT01940000
                               1 - ONLINE       4 - DCLOSE DISCONNECT   01945000
                               2 - LOGGING ON   5 - LO SPD SNS DISCNCT  01950000
                               6 - HANG UP TURN 7 - HANGING UP >>       01955000
    INSPEED   =(12:4)#,    << INPUT SPEED AND CHARACTER SIZE >>         01960000
                           <<  0 - NOT DETERMINED  4 - 30 CPS           01965000
                               1 - 240 CPS         5 - 15 CPS           01970000
                               2 - 120 CPS         6 - 10 CPS           01975000
                               3 -  60 CPS         7 - 14 CPS  >>       01980000
    IOSTAT    =( 8:8)#,    << TOTAL REQUEST STATUS RETURNED >>          01985000
    IOWAKE    =(IOWAKE':1)#,                                            01990000
    LOADMEMORY=ASSEMBLE( LSEA )#,                              <<00.05>>01995000
    LOGONTRLX =(8:8)#,     << TIM. REQ. INDEX FOR LOGONTO >>   <<01448>>02000000
    LOGONTYPE =(0:2)#,     <<:DATA=0  :HELLO=1   :JOB=2>>      <<00163>>02005000
    LPLEVEL   =(13:3)#,    << LAST PREMPT LEVEL                         02010000
                                0 - NONE       3 - SOFT PREMPT          02015000
                                1 - NOT USED   4 - HARD PREMPT          02020000
                                2 - CONSOLE                      >>     02025000
    MAINPIN   =( 0:8)#,    << JOB MAIN PIN IN LDT >>                    02030000
    MCODE     =(10:6)#,    << MONITORING FUNCTION CODE >>               02035000
    MTYPE     =( 1:3)#,    << MODEM TYPE                                02040000
                                0 - HARDWIRED   2 - 202C                02045000
                                1 - 103         3 - 2002   >>           02050000
MEASURE = LOGICAL(ABS(%1267))#,                                <<01240>>02055000
    NEWFORM   = DLASTPL.(11:1)#,                               <<01469>>02060000
    NEWLINE   =(NEWLINE' :1)#,                                          02065000
    NO'CX'ECHO=( 1:1)#,    << IF SET DONT ECHO !!! ON CONTROL X >>      02070000
    NOPREMPT  =(11:1)#,    << NO PREMPTS OF THIS STATE ALLOWED >>       02075000
    NOPTY     =(NOPTY':1)#,   <<8-BIT DATA FLAG-->>            <<AMS00>>02080000
                          <<NO PARITY SET IN 8TH BIT>>         <<AMS00>>02085000
    NOSTOP    =(10:1)#,    << NO PREMPTS OR ABORTS ALLOWED >>           02090000
    NOSYNC    =( 7:1)#,    << NO SYNC TERMINAL, USES ENQ AND ACK >>     02095000
    NXTDSTATE =( 9:4)#,    << NEXT DSTATE AFTER 202 TURN AROUND >>      02100000
    OUTSPEED  =( 6:4)#,    << OUTPUT SPEED AND CHARACTER SIZE CODE      02105000
                               SEE INSPEED FOR MEANING >>               02110000
    PAIR      =( 7:1)#,    << INDICATES SPECIAL ACTION ON NEXT CHAR >>  02115000
    PCBS      =LSR(8)#,    << SHIFT TO GET PCB NUMBER FROM IOQ >>       02120000
    PDISABLE  = ASSEMBLE( PSDB )#,     << PSUEDO DISABLE >>             02125000
    PAIRCODE  =(12:4)#,    << DENOTES LAST PAIR CHAR INPUT >>  <<01.02>>02130000
    PENABLE   = ASSEMBLE( PSEB )#,     << PSEUDO ENABLE >>              02135000
    PARITYBITS=(PTYCNTRL':2)#,<< PARITY CONTROL AND SENSE >>            02140000
    PARITYSAVE=( 8:2)#,    << HOLDS PRTY CNTRL DURING BINARY OPS >>     02145000
    PTYCHK    =(PTYCHK'  :1)#,                                          02150000
    PRESPLAST =(PRESPLAST':1)#,                                         02155000
    PREMPT    =(PREMPT' :1)#,                                           02160000
    QPAGEEJECT=IOQPL(QPAR2).(14:1)#, << 0 -> AUTO EJECT >>     <<01469>>02165000
    RBYTE     =(8:8)#,                                                  02170000
    RDCOUNTED =( 8:1)#,    << RDCOUNTER INCREMENTED >>                  02175000
    READSTOP  =( 7:3)#,    << IF NOT ZERO THEN STOP READ BECAUSE        02180000
                                 0 - NONE        4 - LOGON TIMED OUT    02185000
                                 1 - BREAK       5 - ABORTED            02190000
                                 2 - PREMPT      6 - NOT USED           02195000
                                 3 - TIMED OUT   7 - NOT USED  >>       02200000
    REQUEST   =(REQUEST':1)#,<< REQUEST FOR SERVICE WHILE ACTIVE >>     02205000
    RPLEVEL   =(13:3)#,    << REQUEST PREMPT LEVEL,SEE LPLEVEL  >>      02210000
    RSTATE    =(10:6)#,    << REQUEST STATE -                           02215000
                              0 - NEW       %30 - PRE TO POST TBUF WAIT 02220000
                              1 - STARTED   %31 - PRESPACE TBUF WAIT    02225000
                              2 - READING    32 - WRT DATA TBUF WAIT    02230000
                             43 - RD CMPLTD  33 - POSTSPACE TBUF WAIT   02235000
                             44 - RD STOPPED                            02240000
                              5 - READ WAITING                          02245000
                             %34-%37 SAME A %30-%33 BUT ENQ ADD WAIT    02250000
                           >>                                           02255000
    READERRORS=(10:3)#,    << 0-OK,1-SPECIALSTOP,2-PTY ERR,3-LOST DATA, 02260000
                              4-LOST CHAR,5-BRK STOP,6-TIMEDOUT >>      02265000
    SB        =( 6:1)#,    << SECONDARY CARRIER DETECT >>               02270000
    SERVREQ   =( 0:1)#,    << DEVICE RECOGNITION SERVICE REQUEST >>     02275000
    SPDSENSING=(SPDSENSING':1)#,                                        02280000
    SPOOLING  =(SPOOLING':1)#,                                          02285000
    SSBRKOK   =(SSBRKOK':1)#,                                           02290000
    REQSTAT   = DITPL(36).(12:1)#, << 2631 STAT REQ ACTIVE >>  <<01469>>02295000
    STATDONE   = (15:1)#,  << DRQST, STAT REQ COMPLETED >>     <<01469>>02300000
    SYSBUFR   =(SYSBUFR':1)#,                                           02305000
    TAPEMODE  =(TAPEMODE':1)#,                                          02310000
    TIMEREAD  =( 1:1)#,    << TIME READ OPERATIONS >>                   02315000
    TTYPE     =( 5:5)#,    << TERMINAL TYPE AS IN MPE ERS >>            02320000
    TERMINALTYPE=( 0:7)#,  << DEFAULT TERMINAL TYPE >>                  02325000
    TERMSPEED =(12:4)#,    << PRECONFIGURED TERMINAL SPEED >>  <<00.06>>02330000
    TESTBIT   = ASSEMBLE(TBC#,                                          02335000
    TMODE     =(11:2)#,    << TERMINAL MODE                             02340000
                                 0 - NORMAL   2 - CONSOLE               02345000
                                 1 - BREAK    3 - CONSOLE FROM BREAK >> 02350000
    UP        =(UP'      :1)#,                                          02355000
    WAITEDSTATE=(0:4)#,    << STATE WAITED FOR BREAK >>                 02360000
    WRTCOUNTED=( 9:1)#,    << WRTCOUNTER INCREMENTED >>                 02365000
    XONWAIT   =(2:1)#,                                         <<01468>>02370000
    ENDDEF    = 0#;                                                     02375000
                                                                        02380000
                                                                        02385000
                                                                        02390000
                                                                        02395000
                                                                        02400000
  <<----------- GENERAL SERVICE VARIABLES -------------->>              02405000
                                                                        02410000
    INTEGER POINTER PS0 = S-0;                                          02415000
    LOGICAL LS0 = S-0,  LX = X;                                         02420000
    INTEGER S0=S-0, S1=S-1, S2=S-2, S3=S-3, S4=S-4, X = X;     <<01469>>02425000
                                                                        02430000
    INTEGER ARRAY WA0(*) = DB + 0;                                      02435000
    BYTE    ARRAY BA0(*) = DB + 0;                                      02440000
    BYTE POINTER  BPS1   = S  - 1;                                      02445000
                                                                        02450000
    INTEGER ARRAY LPDT(@) = DB + SYSLPDT;                               02455000
    DOUBLE ARRAY LPDTD(@) = DB + SYSLPDT;                               02460000
    INTEGER ARRAY SBUF(@) = DB + SYSSBUF;                               02465000
    INTEGER ARRAY PCB (@) = DB + SYSPCB ;                               02470000
    INTEGER ARRAY DST (@) = DB + SYSDST;                       <<00.05>>02475000
    DOUBLE ARRAY DSTD (@) = DB + SYSDST;                       <<00.05>>02480000
                                                                        02485000
    INTEGER RDCOUNTER  = DB + %64; << # OF TERMINAL READS IN PROGESS >> 02490000
    INTEGER WRTCOUNTER = DB + %65; << # OF TERMNAL WRITES IN PROGRESS >>02495000
                                                                        02500000
    INTEGER DEVRECPCBP = DB + %145;  << DEVICE RECOGNITION PCB INDEX >> 02505000
    INTEGER CONSLDEV   = DB + %74;  << SYSTEM CONSOLE LDEV >>           02510000
$PAGE " EXTERNAL PROCEDURE DECLARATIONS"                                02515000
                                                                        02520000
  << DIT DEFINITION AND DRIVER LINKAGE DATA >>                          02525000
                                                                        02530000
BYTE ARRAY DLT(0:7 ) = DB :=                                            02535000
  TDITSIZE, 2, 0, 0, 0, 0, SIOSIZED2, 0;  << TYPE 2 MONITOR >> <<01300>>02540000
                                                                        02545000
ARRAY DIT(1:TDITSIZE) = DB :=                                           02550000
  %100400,   << SET TERMINAL FLAG AND PAIR >>                           02555000
  0, 0, 0, 0, 0, 0, %20, 0, << BIT SET TO ENABLE CONTROL A >>           02560000
  %014000,   << SET ECHO ON, SPEED SENSE >>                             02565000
  %602,      << MPX CONTROL WORD AND GENERATE PARITY>>                  02570000
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;         <<01469>>02575000
                                                                        02580000
ARRAY SIOA( 1:SIOSIZE) = DB :=                                          02585000
  %11415,%05012,%11415,%06005, << DC3,CR,LF,LF,DC3,FF,ENQ >>   <<01469>>02590000
  %15446,%66060,%00000,%53000; << ESC,&,l,0,NULL,NULL,V >>     <<01469>>02595000
                                                                        02600000
                                                                        02605000
PROCEDURE ABORTJOB(UMAINPIN);                                  <<01470>>02610000
  VALUE UMAINPIN; INTEGER UMAINPIN;                            <<01470>>02615000
  OPTION EXTERNAL;                                             <<01470>>02620000
                                                               <<01470>>02625000
PROCEDURE ADDTAIL(DITP,LINKINDEX,QUEUENUMBER);                          02630000
  VALUE LINKINDEX, QUEUENUMBER;   INTEGER LINKINDEX, QUEUENUMBER;       02635000
  ARRAY DITP;   OPTION EXTERNAL;                                        02640000
                                                                        02645000
DOUBLE PROCEDURE ATTACHIO(LDEV,QMISC,DSTX,ADDR,FNCT,CNT,P1,P2,FLAGS);   02650000
  VALUE LDEV,QMISC,DSTX,ADDR,FNCT,CNT,P1,P2,FLAGS;                      02655000
  INTEGER LDEV,QMISC,DSTX,ADDR,FNCT,CNT,P1,P2,FLAGS;                    02660000
  OPTION EXTERNAL;                                                      02665000
                                                                        02670000
PROCEDURE AWAKE(PCBPT, N, WAITF);                                       02675000
  VALUE PCBPT, N, WAITF;                                                02680000
  INTEGER PCBPT, N, WAITF;                                              02685000
  OPTION EXTERNAL;                                                      02690000
                                                                        02695000
PROCEDURE BREAKJOB(LDEV, PIN );                                         02700000
  VALUE LDEV, PIN;  INTEGER LDEV, PIN;                                  02705000
  OPTION EXTERNAL;                                                      02710000
                                                                        02715000
PROCEDURE BREAKSS(LDEV, PINS );                                <<DS.06>>02720000
  VALUE LDEV, PINS;  INTEGER LDEV, PINS;                       <<DS.06>>02725000
  OPTION EXTERNAL;                                             <<DS.06>>02730000
                                                               <<DS.06>>02735000
PROCEDURE CHECKTQUEUE(DITP);                                            02740000
  ARRAY DITP;   OPTION EXTERNAL;                                        02745000
                                                                        02750000
PROCEDURE DELAY(TIME);                                                  02755000
  VALUE TIME;  DOUBLE TIME;                                             02760000
  OPTION EXTERNAL;                                                      02765000
                                                                        02770000
PROCEDURE EOFCHECK(IOQP,BUFADDR,COUNT,HARDEOF);                         02775000
  VALUE BUFADDR,COUNT,HARDEOF;  DOUBLE BUFADDR;                         02780000
  ARRAY IOQP;  INTEGER COUNT,HARDEOF;                                   02785000
  OPTION EXTERNAL;                                                      02790000
                                                                        02795000
PROCEDURE DMONITOR(DITP,ID,P1,P2);                                      02800000
  VALUE ID, P1, P2;  INTEGER ID, P1,P2;                                 02805000
  INTEGER ARRAY DITP;  OPTION EXTERNAL;                                 02810000
                                                                        02815000
PROCEDURE DSET1;  OPTION EXTERNAL;                                      02820000
                                                                        02825000
PROCEDURE DSET2;  OPTION EXTERNAL;                                      02830000
PROCEDURE DSETCONTROL( CONTROL, DITP );                                 02835000
  VALUE CONTROL, DITP;  INTEGER CONTROL;                                02840000
  INTEGER POINTER DITP;                                                 02845000
  OPTION EXTERNAL;                                                      02850000
                                                                        02855000
INTEGER PROCEDURE EXCHANGEDB(DSTNUMBER);                                02860000
  VALUE DSTNUMBER;  INTEGER DSTNUMBER;                                  02865000
  OPTION EXTERNAL;                                                      02870000
                                                                        02875000
INTEGER PROCEDURE GETIOQ(TYPE);                                         02880000
  VALUE TYPE;  INTEGER TYPE;                                            02885000
  OPTION EXTERNAL;                                                      02890000
                                                                        02895000
INTEGER PROCEDURE GETTBUF(FLAG);                                        02900000
  VALUE FLAG;  INTEGER FLAG;                                            02905000
  OPTION EXTERNAL;                                                      02910000
                                                                        02915000
INTEGER PROCEDURE GETSBUF(FLAG);                                        02920000
  VALUE FLAG;  INTEGER FLAG;                                            02925000
  OPTION EXTERNAL;                                                      02930000
                                                                        02935000
Logical Procedure Getsir (Sir);                                <<01470>>02940000
Value Sir;                                                     <<01470>>02945000
Integer Sir;                                                   <<01470>>02950000
OPTION EXTERNAL;                                               <<01470>>02955000
                                                               <<01470>>02960000
PROCEDURE HELP;  OPTION EXTERNAL;                                       02965000
                                                                        02970000
LOGICAL PROCEDURE IOMESSAGE(SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,   <<01469>>02975000
  DEST,REPLY,OFFSET,DITP,IOTYPE);                              <<01469>>02980000
VALUE SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,DEST,REPLY,OFFSET,DITP,  <<01469>>02985000
  IOTYPE;                                                      <<01469>>02990000
INTEGER SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,DEST,REPLY,OFFSET,     <<01469>>02995000
  IOTYPE;                                                      <<01469>>03000000
INTEGER POINTER DITP;                                          <<01469>>03005000
OPTION VARIABLE,EXTERNAL;                                      <<01469>>03010000
                                                               <<01469>>03015000
DOUBLE PROCEDURE IOSTATUS(IOQX);                                        03020000
  VALUE IOQX;  INTEGER IOQX;                                            03025000
  OPTION EXTERNAL;                                                      03030000
                                                                        03035000
PROCEDURE INITCHANNEL(DITP);                                            03040000
  INTEGER ARRAY DITP;  OPTION EXTERNAL;                                 03045000
                                                                        03050000
PROCEDURE LOGERROR(DITP,IOQP,DEVSTAT);                         <<00.05>>03055000
  VALUE DEVSTAT;  ARRAY DITP,IOQP;                             <<00.05>>03060000
  INTEGER DEVSTAT;    OPTION EXTERNAL;                         <<00.05>>03065000
                                                               <<00.05>>03070000
PROCEDURE MMSTAT(EVENTNUM,P1,P2,P3);                           <<01240>>03075000
VALUE EVENTNUM,P1,P2,P3;                                       <<01240>>03080000
INTEGER EVENTNUM,P1,P2,P3;                                     <<01240>>03085000
OPTION EXTERNAL;                                               <<01240>>03090000
                                                               <<01240>>03095000
PROCEDURE MPXWRITE(CHAR,DITP);                                          03100000
  VALUE DITP, CHAR;  INTEGER CHAR;                                      03105000
  INTEGER POINTER DITP;                                                 03110000
  OPTION EXTERNAL;                                                      03115000
                                                                        03120000
PROCEDURE MPXCONTROL( DATA, DITP );                                     03125000
  VALUE DITP, DATA;  INTEGER DATA;                                      03130000
  INTEGER POINTER DITP;                                                 03135000
  OPTION EXTERNAL;                                                      03140000
                                                                        03145000
Procedure Relsir (Sir,Sirstat);                                <<01470>>03150000
Value Sir,Sirstat;                                             <<01470>>03155000
Integer Sir;                                                   <<01470>>03160000
Logical Sirstat;                                               <<01470>>03165000
OPTION EXTERNAL;                                               <<01470>>03170000
                                                               <<01470>>03175000
PROCEDURE RESETDB(OLDDB);                                               03180000
  VALUE OLDDB;  INTEGER OLDDB;                                          03185000
  OPTION EXTERNAL;                                                      03190000
                                                                        03195000
PROCEDURE RETURNSYSBUF(INDEX);                                          03200000
  VALUE INDEX;  INTEGER INDEX;                                          03205000
  OPTION EXTERNAL;                                                      03210000
                                                                        03215000
PROCEDURE RETURNTBUF(TBUFP);                                            03220000
  VALUE TBUFP;  INTEGER TBUFP;                                          03225000
  OPTION EXTERNAL;                                                      03230000
                                                                        03235000
PROCEDURE RETURNIOQ(IOQP);                                              03240000
  VALUE IOQP;  INTEGER IOQP;                                            03245000
  OPTION EXTERNAL;                                                      03250000
                                                                        03255000
PROCEDURE SENDSYNC(NEWDSTATE,DITP);                                     03260000
  VALUE NEWDSTATE;  INTEGER NEWDSTATE;                                  03265000
  ARRAY DITP;   OPTION EXTERNAL;                                        03270000
                                                                        03275000
PROCEDURE SET'PSIF(PCBPT,FLAG);                                         03280000
  VALUE PCBPT, FLAG;  INTEGER PCBPT, FLAG;                              03285000
  OPTION EXTERNAL;                                                      03290000
                                                                        03295000
PROCEDURE SETREADERROR(IOQP,ENUMB);                                     03300000
  VALUE ENUMB;  INTEGER ENUMB;                                          03305000
  ARRAY IOQP;   OPTION EXTERNAL;                                        03310000
                                                                        03315000
INTEGER PROCEDURE SETSYSDB;  OPTION EXTERNAL;                           03320000
                                                                        03325000
PROCEDURE SETTERMTYPE(TYPE,ISPD,OSPD,DITP);                             03330000
  VALUE    TYPE, ISPD,OSPD;                                             03335000
  INTEGER  TYPE, ISPD,OSPD;                                             03340000
  ARRAY DITP;   OPTION EXTERNAL;                                        03345000
                                                                        03350000
PROCEDURE STARTTIMEOUT(TYPE,DITP);                                      03355000
  VALUE TYPE;   INTEGER TYPE;                                           03360000
  ARRAY DITP;   OPTION EXTERNAL;                                        03365000
                                                                        03370000
PROCEDURE STOPTIMEOUT(TYPE,DITP);                                       03375000
  VALUE TYPE;    INTEGER TYPE;                                          03380000
  ARRAY DITP;    OPTION EXTERNAL;                                       03385000
                                                               <<01.02>>03390000
PROCEDURE SUDDENDEATH(N);                                      <<01.02>>03395000
  VALUE N;  INTEGER N;                                         <<01.02>>03400000
  OPTION EXTERNAL;                                             <<01.02>>03405000
                                                                        03410000
PROCEDURE TERMINIT(DITP);                                               03415000
  INTEGER ARRAY DITP;                                                   03420000
  OPTION EXTERNAL;                                                      03425000
                                                               <<01240>>03430000
DOUBLE PROCEDURE TIMER; OPTION EXTERNAL;                       <<01240>>03435000
                                                                        03440000
PROCEDURE TIP;   OPTION EXTERNAL;                                       03445000
$PAGE                                                          <<00.05>>03450000
                                                               <<00.05>>03455000
DOUBLE PROCEDURE DATA'ADR(IOQP);                               <<00.05>>03460000
  INTEGER ARRAY IOQP;                                          <<00.05>>03465000
  <<                                                                    03470000
    THIS PROCEDURE MAKES THE DATA SEGMENT REFERENCED IN THE IOQ         03475000
    PRESENT AND RETURNS THE DST NUMBER AND OFFSET TO THE TARGET         03480000
    IT MUST BE CALLED WITH ONE LEVEL OF PSEUDO DISABLE IN EFFECT        03485000
    IF THE DST IN NOT CORE RESIDENT.                                    03490000
  >>                                                                    03495000
  BEGIN                                                        <<00.05>>03500000
    INTEGER DSTN, OFFSET := 0;                                 <<00.05>>03505000
                                                               <<00.05>>03510000
    X := IOQP(QDSTN)&LSL(2);  << DST # TIMES 4 >>              <<00.05>>03515000
    DSTN := X&LSR(2);   << STRIP OFF DB RELATIVE BIT >>        <<00.05>>03520000
                                                               <<00.05>>03525000
    WHILE DST(X)<0 DO  << ABSENT, SO MAKE PRESENT >>           <<00.05>>03530000
      BEGIN  << DUMY MOVE TO MAKE PRESENT >>                   <<00.05>>03535000
        PENABLE;                                               <<00.05>>03540000
        TOS := DSTN;                                           <<00.05>>03545000
        ASMB(ZERO,DDUP);                                       <<00.05>>03550000
        TOS := 1;    ASMB( MDS );                              <<00.05>>03555000
        PDISABLE;                                              <<00.05>>03560000
      END;                                                     <<00.05>>03565000
                                                               <<00.05>>03570000
    IF IOQP(QDSTN)<0 THEN  << STACK, ADD DB OFFSET TO ADDR >>  <<00.05>>03575000
      BEGIN                                                    <<00.05>>03580000
        TOS := DSTD(DSTN*2+1);    << BANK AND OFFSET >>        <<00.05>>03585000
        TOS := TOS + 1;   << ADDR OF DB OFFSET >>              <<00.05>>03590000
        LOADMEMORY;       << DB TO DL OFFSET   >>              <<00.05>>03595000
        OFFSET := TOS;                                         <<00.05>>03600000
      END;                                                     <<00.05>>03605000
                                                               <<00.05>>03610000
    TOS := DSTN;                                               <<00.05>>03615000
    TOS := IOQP(QADDR) + OFFSET;                               <<00.05>>03620000
    DATA'ADR := TOS;                                           <<00.05>>03625000
  END;   << DATA  ADR >>                                       <<00.05>>03630000
$PAGE " ASYNCHRONOUS TERMINAL MONITOR - TERM"                           03635000
                                                                        03640000
PROCEDURE TERMIOM(DITP,FLAGS);                                          03645000
  VALUE   FLAGS;  INTEGER FLAGS;                                        03650000
  INTEGER ARRAY DITP;                                                   03655000
  OPTION UNCALLABLE, PRIVILEGED;                                        03660000
  <<                                                                    03665000
    TERMINAL MONITOR.  THIS PROCEDURE HANDLES INITIATION, COMPLETION    03670000
    AND OTHER FUNCTIONS ASSOCIATED WITH I/O TO TERMINALS CONNECTED      03675000
    TO THE ASYNCHRONOUS TERMINAL MULTIPLEXER                            03680000
  >>                                                                    03685000
  BEGIN                                                                 03690000
                                                                        03695000
    INTEGER ARRAY  Q0(  *  ) = Q + 0;                                   03700000
    INTEGER ARRAY  Q1( 0:30) = Q;  << TEMP WRITE DATA BUFFER >>         03705000
    BYTE    ARRAY BQ1(  *  ) = Q1;                                      03710000
                                                                        03715000
    INTEGER                                                             03720000
      BCNT,             << BYTE COUNT OF DATA TO BE TRANSFERED >>       03725000
      WCNT,             << WORD TRANSFER COUNT FOR READS >>             03730000
      SCNT,             << SPACE COUNT OR END OF SBUF COUNT >>          03735000
      TEMP,             << TEMP AND I ARE USED A PAIR IN SPOOLING >>    03740000
      I,                << GENERAL INDEX VARIABLE >>                    03745000
      IFLAG,            << FOR SETTING FLAG >>                          03750000
      RQSTATE,          << CURRENT REQUEST STATE >>                     03755000
      FUNCTION,         << FUNCTION CODE FOR CURRENT REQUEST >>         03760000
      TADDR,            << OFFSET IN DST OF TARGET BUFFER >>            03765000
      STACKDST,         << DST NUMBER OF CURRENT STACK >>               03770000
      TBASE;            << TBUF PNTR OR OFFSET TO ARRAY Q1 >>           03775000
                                                                        03780000
    DOUBLE                                                              03785000
      Q1ADDR  = STACKDST, << DSTN AND OFFSET OF ARRAY Q1 >>             03790000
      SIOADDR = TBASE +1; << DSTN & OFFSET OF CARRIAGE CONTROL CHARS >> 03795000
                                                                        03800000
    INTEGER                                                             03805000
    ABSSIOADDR = SIOADDR + 1,                                  <<01469>>03810000
      LDEV    = SIOADDR + 2,                                            03815000
      TCNT    = IFLAG,     << WORDS REMAINING TO FILL TBUF >>           03820000
      NPL     = I;         << NEW PREMPT LEVEL >>                       03825000
                                                                        03830000
    LOGICAL                                                             03835000
      FLAG   = IFLAG,                                                   03840000
      LFLAGS = FLAGS;                                                   03845000
                                                                        03850000
    INTEGER POINTER                                                     03855000
      THISP  = BCNT,    << POINTER TO IOQ TO BE EXAMINED >>             03860000
      LASTP  = BCNT+1,  << POINTER TO PREVIOUS IOQ >>                   03865000
      STHISP = SCNT,  << POINTER TO IOQ WITH HIGHEST PREMPT LEVEL >>    03870000
      SLASTP = SCNT+1;<< POINTER TO IOQ PRECEDING MOST PREMPTIVE >>     03875000
$PAGE                                                                   03880000
                                                                        03885000
    INTEGER ARRAY                                                       03890000
      IOQP(@)    = LDEV + 1,                                            03895000
      QMISCP(@)  = IOQP + 1,                                            03900000
      QWBCTP(@)  = QMISCP + 1,                                          03905000
      QPAR1P(@)  = QWBCTP + 1,                                          03910000
      DRQSTP(@)  = QPAR1P + 1,                                          03915000
      DTYPEP(@)  = DRQSTP + 1,                                          03920000
      DMODEMP(@) = DTYPEP + 1,                                          03925000
      DSPEEDP(@) = DMODEMP + 1,                                         03930000
      DCNTRLP(@) = DSPEEDP + 1,                                         03935000
      DRBCTP(@)  = DCNTRLP + 1,                                         03940000
      DBCNTP(@)  = DRBCTP  + 1,                                         03945000
      DXCNTP(@)  = DBCNTP  + 1,                                         03950000
      DLASTP(@)  = DXCNTP  + 1;                                         03955000
                                                                        03960000
    LOGICAL POINTER                                                     03965000
      DMODEMPL = DMODEMP,                                               03970000
      DSPEEDPL = DSPEEDP,                                               03975000
      DTYPEPL  = DTYPEP,                                                03980000
      DITPL    = DITP,                                                  03985000
      DLASTPL  = DLASTP,                                                03990000
      QMISCPL  = QMISCP,                                                03995000
      IOQPL    = IOQP;                                                  04000000
                                                                        04005000
    DOUBLE POINTER                                                      04010000
      DITPD   = DITP,                                                   04015000
      IOQPD   = IOQP;                                                   04020000
                                                                        04025000
    DOUBLE                                                              04030000
      DS6     = S - 6,  << TO REFERENCE BUFADR IN MOVEDATA >>           04035000
      TEMPD   = TEMP,                                                   04040000
      RQSFUNC = RQSTATE,<< FOR SETTING RQSTATE AND FUNCTION >>          04045000
      QPQM    = IOQP,   << FOR SETTING IOQP AND QMISCP >>               04050000
      QCQP1   = QWBCTP, << FOR SETTING QWBCTP AND QPAR1P >>             04055000
      THESEPS = THISP,  << FOR SAVING POINTERS >>                       04060000
      SAVEPS  = STHISP;                                                 04065000
                                                                        04070000
    INTEGER ARRAY READSTATUS(0:7) = PB :=                      <<02004>>04075000
      GOODIO,SPECIALEND,BREAKEND,LOSTDSTAT,LOSTCSTAT,          <<02004>>04080000
      BADPARITY,TIMEDOUT,BLOCKTIMED;                           <<02004>>04085000
                                                                        04090000
                                                                        04095000
    INTEGER ARRAY SPEED(0:MAXSPEED) = PB :=                             04100000
      240,240,120, 60, 30, 15, 10, 14;                                  04105000
  BYTE ARRAY B'RESET31B(0:67) = PB :=                          <<01469>>04110000
   ESC,"&dA",  ESC,"&k1E",  ESC,")A",  ESC,"(@",  ESC,"&k0I",  <<01469>>04115000
   %17,  ESC,"&klF",  ESC,"&s1I",  ESC,"&k0S",  ESC,"&l6D",    <<01469>>04120000
   ESC,"&l1L",  ESC,"&l3M",  ESC,"&l0N",                       <<01469>>04125000
   ESC,"3",  ESC,"&s0C",  ESC,"Z",  CR,  FF, 0;                <<01469>>04130000
  ARRAY RESET31B(*) = B'RESET31B;                              <<01469>>04135000
$PAGE                                                                   04140000
                                                                        04145000
SUBROUTINE RETURNBUFS;                                                  04150000
  <<                                                                    04155000
     THIS SUBROUTINE RETURNS ANY TBUFS OUTSTANDING AS INDICATED         04160000
     BY NON ZERO TBUF POINTERS IN THE DIT. IF SPOOLING SET THEN         04165000
     THE POINTER AREA IS JUST CLEARED.                                  04170000
  >>                                                                    04175000
  BEGIN                                                                 04180000
    CHECKTQUEUE(DITP);   << START ANY WAITING OPERATIONS >>             04185000
                                                                        04190000
    DISABLE;                                                            04195000
    TEMP := DITP(DNXTB);   DITP(X) := 0;                                04200000
    IF <> THEN  BEGIN  TOS := TEMP;   RETURNTBUF( * );  END;            04205000
                                                                        04210000
    TOS := DBCNTP;    << SAVE RETURN BUFS TEST >>                       04215000
    DITP(DCNT) := DBCNTP := 0;                                          04220000
                                                               <<01.02>>04225000
    TOS := DITP;                                               <<01.02>>04230000
    TOS.ENQACKWAIT := 0;  << IN CASE SET FROM BINARY READ >>   <<01.02>>04235000
    TOS.SPOOLING := 0;                                         <<01.02>>04240000
    DITP := TOS;                                               <<01.02>>04245000
    ENABLE;                                                             04250000
                                                                        04255000
    IF <> THEN ASMB( DEL,ZERO);  << SPOOLING,NO TBUFS TO RETURN >>      04260000
                                                                        04265000
    IF TOS<>0 THEN X := DITP(DHEAD);  << DBCNT#0, TBUFS TO RETURN >>    04270000
    WHILE <> DO  << RETURN TBUFS >>                                     04275000
      BEGIN                                                             04280000
        TOS := X;   << GET POINTER FOR RETURNING >>                     04285000
        X := WA0(X);      << GET LINK TO NEXT >>                        04290000
        RETURNTBUF( * );                                                04295000
      END;                                                              04300000
    DITP(DHEAD) := 0;<<SO WE DON'T TRY TO RETURN THEM AGAIN>>  <<02085>>04305000
  END;  << RETURN BUFS >>                                               04310000
                                                                        04315000
                                                                        04320000
                                                                        04325000
                                                                        04330000
                                                                        04335000
SUBROUTINE CLEANUP;                                                     04340000
  <<                                                                    04345000
    THIS ROUTIME CLEANS UP TAPEMODE, NO CONTROL X ECHO, TIMEOUTS,       04350000
    SPECIAL EOR AND SUB SYSTEM BREAK AND PARITY CHECK FLAGS.            04355000
  >>                                                                    04360000
  BEGIN                                                                 04365000
    DSPEEDP.TAPEMODE := 0;                                              04370000
    DITP(DLDEV).NO'CX'ECHO := 0;                                        04375000
    DITP(DRTMAX) := 0;   << DISABLE READ TIMEOUTS >>                    04380000
    DITP(DSTOP) := 0;   << DISABLE SPECIAL SUB SYS BRK & EOR  >>        04385000
                                                                        04390000
    DISABLE;                                                            04395000
  IF DITP(DLDEV).NOPTY <> 0 THEN <<CHECKS 8-BIT DATA FLAG>>    <<AMS00>>04400000
    BEGIN                                                      <<AMS00>>04405000
    DITP.PTYCHK :=1;  << SETS 8-BIT DATA PTYCHK>>              <<AMS00>>04410000
    DCNTRLP.PARITYBITS :=0;  <<DISABLE PARITY GEN>>            <<AMS00>>04415000
    END                                                        <<AMS00>>04420000
    ELSE                                                       <<+1.M3>>04425000
    DITP.PTYCHK := 0;                                                   04430000
    DTYPEP.TIMEREAD := 0;                                               04435000
                                                                        04440000
    TOS := LPDTD(LDEV);                                                 04445000
    TOS.(SSBREAK':1) := 0;                                              04450000
    LPDTD( X ) := TOS;                                                  04455000
                                                               <<00.05>>04460000
    TOS := DITP(DBREAK);                                       <<00.05>>04465000
    IF <> THEN  << RETURN BREAK SAVE IOQ AND TBUFS >>          <<00.05>>04470000
      BEGIN                                                    <<00.05>>04475000
        DITP(DBREAK) := 0;   << CLEAR BREAK SAVE >>            <<00.05>>04480000
        X := PS0( 7 );    << GET HEAD POINTER >>               <<00.05>>04485000
        WHILE <> DO   << RETURN ANY SAVED TBUFS >>             <<00.05>>04490000
          BEGIN                                                <<00.05>>04495000
            TOS := X;   << GET POINTER FOR RETURNTBUF >>       <<00.05>>04500000
            X := WA0(X);     << GET LINK TO NEXT TBUF >>       <<00.05>>04505000
            RETURNTBUF( * );                                   <<00.05>>04510000
          END;                                                 <<00.05>>04515000
        RETURNIOQ( S0 );                                       <<00.05>>04520000
      END;                                                     <<00.05>>04525000
                                                                        04530000
    DEL;  << DELETE DBREAK WORD >>                             <<00.05>>04535000
    RETURNBUFS;                                                <<00.05>>04540000
  END;    << CLEAN UP >>                                       <<00.05>>04545000
                                                                        04550000
                                                                        04555000
                                                                        04560000
                                                                        04565000
SUBROUTINE STARTWRITE;                                                  04570000
  <<                                                                    04575000
      THIS SUBROUTINE STARTS NEW WRITE REQUESTS                         04580000
  >>                                                                    04585000
  BEGIN                                                                 04590000
    X := DBCNTP; << CHECK PENDING WRITE COUNT >>                        04595000
    IF <> AND DITP.DSTATE=NULL THEN                                     04600000
      BEGIN   << NULL AND NON ZERO BYTE COUNT >>                        04605000
        DISABLE;                                                        04610000
        SENDSYNC(WRITING,DITP);                                         04615000
      END;                                                              04620000
  END;    << START WRITE >>                                             04625000
$PAGE                                                                   04630000
                                                                        04635000
SUBROUTINE STOPREAD(STOPTYPE);                                          04640000
  VALUE STOPTYPE;  INTEGER STOPTYPE;                                    04645000
  <<                                                                    04650000
    THIS ROUTINE STOPS READ OPERATIONS. THE STOPTYPE IS SET IN READSTOP 04655000
    SO THAT WHEN THEN READ STOP IS COMPLETED, THE TYPE OF STOP AND NEXT 04660000
    ACTION REQUIRED CAN BE IDENTIFIED. MUST BE CALLED DISABLED.         04665000
  >>                                                                    04670000
    BEGIN                                                               04675000
      X := @IOQP;                                                       04680000
      IF <> AND QMISCP.RSTATE=READING AND QMISCP.READSTOP<STOPTYPE THEN 04685000
        BEGIN                                                           04690000
          TOS := QMISCP;                                                04695000
          TOS.READSTOP := S2;    << STOP TYPE >>                        04700000
          TOS.NOSTOP := 1;  << SUPPRESS ABORTS AND PREMPTS >>           04705000
          QMISCP := TOS;                                                04710000
                                                                        04715000
          IF DITP.DSTATE=READING AND NOT DMODEMPL.RDCOUNTED THEN        04720000
            BEGIN    << STOP NON BLOCK MODE READS >>                    04725000
              MPXCONTROL(ECHOOFF,DITP);                                 04730000
              DCNTRLP.NXTDSTATE :=     << DSTATE AFTER FINREAD >>       04735000
                IF DITPL.NEWLINE OR STOPTYPE=SSBRKSTOP OR      <<00.05>>04740000
                  STOPTYPE=READTOSTOP THEN EORLF ELSE EORSYNC; <<00.05>>04745000
              SENDSYNC(FINREAD,DITP); << STOP READ, CLEAN UP CARRIAGE >>04750000
            END;                                                        04755000
        END;                                                            04760000
      END;  << STOP READ >>                                             04765000
                                                                        04770000
                                                                        04775000
LOGICAL SUBROUTINE READABORTED;                                         04780000
  <<                                                                    04785000
    THIS ROUTINE CHECKS IF A READ IS AND CAN BE ABORTED. IF A READ      04790000
    IS ABORTED THEN A TRUE INDICATION IS RETURNED. CALL DISABLED ONLY.  04795000
  >>                                                                    04800000
  BEGIN                                                                 04805000
    X := @IOQP;                                                         04810000
    IF <> THEN   << A REQUEST IS OUTSTANDING >>                         04815000
      BEGIN                                                             04820000
        X := IOQP;  << TEST IF ABORTED >>                               04825000
        IF < AND RQSTATE=READING THEN   << READING AND ABORTED >>       04830000
          BEGIN                                                         04835000
            STOPREAD(ABORTSTOP);                                        04840000
            DCNTRLP.NXTDSTATE := EORLF;                                 04845000
            SENDSYNC(FINREAD,DITP);                                     04850000
            READABORTED := TRUE;                                        04855000
          END;                                                          04860000
      END;                                                              04865000
  END;    << READ ABORTED >>                                            04870000
$PAGE                                                                   04875000
                                                                        04880000
SUBROUTINE STOPOPERATION(STOPTYPE);                                     04885000
  VALUE STOPTYPE;   INTEGER STOPTYPE;                                   04890000
  <<                                                                    04895000
    THIS ROUTINE STOPS THE CURRENT READ OR WRITE OPERATION AND IN       04900000
    THE CASE OF READ SETS THE STOPTYPE IN READSTOP FOR IDENTIFICATION   04905000
    OF THE STOP TYPE WHEN THE READ STOP CLEAN UP HAS BEEN COMPLETED.    04910000
  >>                                                                    04915000
    IF DITP.DSTATE=WAITED THEN  << FINISH STOPPING OPERATION >>         04920000
      BEGIN                                                             04925000
        TEMP := DITP(DSAVE).WAITEDSTATE;                                04930000
        IF TEMP=BANDWAIT THEN TEMP := DCNTRLP.NXTDSTATE;                04935000
                                                                        04940000
        DISABLE;                                                        04945000
        DITP.DSTATE := TEMP;   << RESTORE DSTATE >>                     04950000
        MPXCONTROL(ECHOOFF,DITP);  << ENABLE CHANNEL INTERRUPTS >>      04955000
                                                                        04960000
        IF QMISCP.RSTATE=READWAITING THEN QMISCP := 0; << RESTART >>    04965000
        STOPREAD(STOPTYPE);    << STOP READ IF READING >>               04970000
        STOPTIMEOUT(HP2640TO,DITP);                                     04975000
                                                                        04980000
        IF TEMP=WRITING THEN                                            04985000
          BEGIN                                                         04990000
            DITP.ENQACKWAIT := 0;                                       04995000
            RETURNBUFS;                                                 05000000
            MPXWRITE(NULL,DITP);   << CONTINUE WRITE IF NECESSARY >>    05005000
          END;                                                          05010000
                                                                        05015000
        DITP(DMONTR).XONWAIT:=0;                               <<01468>>05020000
                                                               <<01468>>05025000
        ENABLE;                                                         05030000
      END;    << STOP OPERATION >>                                      05035000
$PAGE                                                                   05040000
                                                                        05045000
SUBROUTINE RESTARTOPERATION;                                            05050000
  <<                                                                    05055000
    THIS ROUTINE RESTARTS READ AND WRITES STOPPED FOR BREAK AND         05060000
    SUB SYSTEM BREAK CHECKS.                                            05065000
  >>                                                                    05070000
    IF DITP.DSTATE=WAITED THEN   << RESTART OPERATION >>                05075000
      BEGIN                                                             05080000
        TEMP := DITP(DSAVE).WAITEDSTATE;                                05085000
        DISABLE;                                                        05090000
        SENDSYNC(NULL,DITP);  << JUST SET DSTATE NULL >>                05095000
        MPXCONTROL(ECHOOFF,DITP);   << ENABLE CHANNEL INTERRUPTS >>     05100000
                                                                        05105000
        IF TEMP=WRITING THEN SENDSYNC(WRITING,DITP)  << RESTART WRITE >>05110000
        ELSE IF TEMP=READING THEN SENDSYNC(XONWRIT,DITP) << RESTART >>  05115000
        ELSE IF TEMP=BANDWAIT THEN   << RESTART WAITED OPERATION >>     05120000
          IF DCNTRLP.NXTDSTATE=WRITING THEN STARTWRITE                  05125000
            ELSE SENDSYNC(SENDXON,DITP);                                05130000
                                                                        05135000
        ENABLE;                                                         05140000
      END;    << RESTART OPERATION >>                                   05145000
                                                               <<00.05>>05150000
                                                               <<00.05>>05155000
                                                               <<00.05>>05160000
SUBROUTINE WRTSPOOLBUF(SBUFP);                                 <<00.05>>05165000
  VALUE SBUFP;   INTEGER SBUFP;                                <<00.05>>05170000
  <<                                                                    05175000
    THIS SUBROUTINE WRITES OUT THE 128 WORDS OF THE SBUF POINTER        05180000
    BY SBUFP TO THE DISC ADDRESS HELD IN DITPD(DTBF2). IT WAITS         05185000
    UNTIL THE I/O IS COMPLETED AND SETS LOST DATA STATUS IF AN          05190000
    ERROR OCCURS.                                                       05195000
  >>                                                                    05200000
  BEGIN                                                        <<00.05>>05205000
    TOS := ATTACHIO(SYSDISK,0,8,SBUFP-@SBUF,WRITING,128,       <<00.05>>05210000
                    DITP(DTAIL),DITP(DPNTR),%11);              <<00.05>>05215000
    DEL;                                                       <<00.05>>05220000
    IF TOS.(13:3)<>GOODIO THEN SETREADERROR(IOQP,LOSTDATA);    <<00.05>>05225000
    DITPD(DTBF2) := DITPD(DTBF2) + 1 D; << BUMP DISC ADDR >>   <<00.05>>05230000
  END;   << WRT SPOOL BUF >>                                   <<00.05>>05235000
$PAGE                                                                   05240000
                                                                        05245000
SUBROUTINE MOVEDATA(BUFADR,COUNT,OFFSET);                               05250000
  VALUE BUFADR, COUNT, OFFSET;   INTEGER COUNT, OFFSET;   DOUBLE BUFADR;05255000
  <<                                                                    05260000
    THIS SUBROUTINE MOVES DATA INTO THE TERMINAL BUFFERS. IT CHECKS     05265000
    FOR ADDING AN ENQ AFTER 80 CHARACTERS ON THE HP2640.                05270000
                                                                        05275000
    RETURN CC - CCE = DATA TRANSFER COMPLETED                           05280000
                CCG = TOO MUCH DATA TO TANK NOW OR NO TBUF AVAILABLE    05285000
                                                                        05290000
     BUFADR - DST NUMBER AND OFFSET OF DATA TO BE WRITTEN               05295000
     COUNT  - NUMBER OF BYTES TO BE TANKED.                             05300000
     OFFSET - OFFSET IN BYTES FROM BUFADR TO START FROM                 05305000
  >>                                                                    05310000
  BEGIN                                                                 05315000
    X := DITP(DLDEV);   << TEST BREAK FLUSH IN BIT 0 >>                 05320000
    IF < OR QMISCPL.FLUSH THEN IF IOQP.RPLEVEL=NULL THEN                05325000
      BEGIN  << BREAK OR CONTROL Y FLUSH, DONT MOVE DATA >>             05330000
        DXCNTP := DXCNTP + COUNT;                                       05335000
        ASMB(DZRO, CMP);  RETURN;  << RETURN WITH CC = CCE >>           05340000
      END;                                                              05345000
                                                                        05350000
STARTM:                                                                 05355000
    I := COUNT;   IF = THEN RETURN;   << NO DATA TO TRANSFER >>         05360000
                                                                        05365000
    IF IOQPL.SYSBUFR THEN                                               05370000
      BEGIN  << FORM ADDR TO GET DATA AND CHECK COUNT >>                05375000
        TEMP := OFFSET&LSR(8);  << SBUF NUMBER IN LINKED LIST >>        05380000
        TOS := BUFADR;                                                  05385000
MV1:                                                                    05390000
        TEMP := TEMP - 1;                                               05395000
        IF >= THEN  << FIND SYSBUF IN LINKED LIST >>                    05400000
          BEGIN  X := TOS-1;  TOS := SBUF(X);  GOTO MV1; END;           05405000
                                                                        05410000
        X := TOS;   DEL;   << SAVE BASE OF SYSBUF IN X >>               05415000
        TADDR := X + OFFSET.(8:7) - INTEGER(BUFADR);                    05420000
        X := 256 - OFFSET.(8:8);                                        05425000
        IF X<I THEN I := X;   << REMAINING IN SYSBUF IS CONSTRAINT >>   05430000
      END                                                               05435000
    ELSE TADDR := OFFSET&LSR(1);   << OFFSET IN DST IN WORDS >>         05440000
                                                                        05445000
    X := 270 - DBCNTP;                                                  05450000
    IF = THEN  BEGIN  X := COUNT;  RETURN;  END; << NO ROOM LEFT >>     05455000
    IF X<I THEN   << LIMIT ON MAX TANKED IS CONSTRAINT >>               05460000
      IF 270>COUNT THEN RETURN   << DONT BREAK UP THIS BLOCK >>         05465000
        ELSE I := X;    << MAX TANK IS CONSTRAINT >>                    05470000
                                                                        05475000
    IF DMODEMPL.NOSYNC THEN    << CHECK FOR 80 CHARS TO 2640 >>         05480000
      BEGIN  X := DITP(DSYNC);    IF X<I THEN I := X;  END;             05485000
                                                                        05490000
    X := I;                                                             05495000
    IF <> THEN   << SOMETHING TO MOVE >>                                05500000
      BEGIN                                                             05505000
        DISABLE;                                                        05510000
                                                                        05515000
        TOS := DBCNTP MOD TBMAXB;   TOS := -S0;                         05520000
        IF = THEN    << NEW TBUF NEEDED >>                              05525000
          BEGIN                                                         05530000
            TOS := DITP(DNXTB);  TOS := S0;   DITP(X) := 0;             05535000
            IF = THEN  << NO TBUF SAVED FOR THIS DEVICE >>              05540000
              BEGIN                                                     05545000
                DDEL;                                                   05550000
                TOS := GETTBUF(PRIMARY);     TOS := S0;                 05555000
                IF = THEN   << NO TBUF AVAILABLE >>                     05560000
                  BEGIN                                                 05565000
                    ENABLE;                                             05570000
                    DDEL;  DDEL;     << CLEAN UP STACK >>               05575000
                    ADDTAIL(DITP, DTBLK, TBQN); << QUEUE TBUF REQUEST >>05580000
                    RETURN;   << WITH CC = CCG >>                       05585000
                  END;                                                  05590000
              END;                                                      05595000
                                                                        05600000
            X := DBCNTP;  << TEST BYTE COUNT SO FAR >>                  05605000
            IF = THEN  << ADDING 1ST TBUF >>                            05610000
              BEGIN                                                     05615000
                DITP(DPNTR) := S0&LSL(1) + 1;                           05620000
                DITP(DHEAD) := TOS;                                     05625000
              END                                                       05630000
            ELSE  WA0(DITP(DTAIL)) := TOS;   << LINK TO END >>          05635000
            DITP(DTAIL) := TOS;     << SET NEW END POINTER >>           05640000
          END;                                                          05645000
                                                                        05650000
        DSPEEDP.FILLING := 1;                                           05655000
        ENABLE;                                                         05660000
                                                                        05665000
        X := TOS + TBMAXB;   IF X<I THEN TEMP := I := X;                05670000
        TEMP := TOS + DITP(DTAIL)&LSL(1) + 2;                           05675000
                                                                        05680000
        IF LOGICAL(OFFSET) OR LOGICAL(TEMP) THEN                        05685000
          BEGIN   << MOVE FROM OR TO ODD BYTE BOUNDRY REQUIRED >>       05690000
            TOS := BUFADR;  DEL;   << LEAVE SOURCE DST # ON TOS >>      05695000
            IF TOS<>FLAGS&LSR(6) THEN  << DATA NOT ON THIS STACK >>     05700000
              BEGIN   << MOVE DATA TO THE LOCAL BUFFER >>               05705000
                TOS := Q1ADDR;                                          05710000
                TOS := DS6;   << GET BUFADR >>                          05715000
                TOS := TOS + TADDR;                                     05720000
                TOS := (I+2)&LSR(1);   ASMB( MDS );                     05725000
                TADDR := 0;  << NO OFFSET FROM TBASE >>                 05730000
              END                                                       05735000
            ELSE                                                        05740000
              TADDR := INTEGER(BUFADR) + TADDR - TBASE;                 05745000
                                                                        05750000
            X := OFFSET.(15:1);                                         05755000
            PDISABLE;   PUSH( Q );                                      05760000
                                                                        05765000
            TOS := TEMP;  << BYTE POINTER TO ENTER IN TBUF >>           05770000
            TOS := I;     << BYTE COUNT TO MOVE >>                      05775000
            TOS := S2 + TADDR;     << BASE OF SOURCE BUFFER >>          05780000
            SET( Q );                                                   05785000
                                                                        05790000
MV2:                                                                    05795000
            BPS1 := BQ1(X);    << MOVE A BYTE >>                        05800000
            ASMB(INCX,INCB);   << BUMP ADDRESSES >>                     05805000
            TOS := TOS - 1;    IF > THEN GOTO MV2;                      05810000
                                                                        05815000
            DDEL;      SET( Q );                                        05820000
            PENABLE;                                                    05825000
          END                                                           05830000
        ELSE                                                            05835000
          BEGIN   << MOVE WORDS >>                                      05840000
          IF S4<>0 THEN                                        <<01469>>05845000
            BEGIN << MOVE NOT PB REL >>                        <<01469>>05850000
            TOS := 6;  TOS := TEMP&LSR(1)+SYSDB;  << TBUF OFFSET >>     05855000
            TOS := DS6;     << GET BUFADR >>                            05860000
            TOS := TOS + TADDR;                                         05865000
            TOS := (I+1)&LSR(1);    ASMB( MDS );                        05870000
            END                                                <<01469>>05875000
          ELSE << MOVE FROM PB ARRAY >>                        <<01469>>05880000
            MOVE WA0(TEMP&LSR(1)) := RESET31B(TADDR),          <<01469>>05885000
            ((I+1)&LSR(1));                                    <<01469>>05890000
          END;                                                          05895000
                                                                        05900000
        DISABLE;                                                        05905000
        DSPEEDP.FILLING := 0;                                           05910000
                                                                        05915000
        IF DITP(DCNT)=-2 THEN  << TBUF END DURING FILL >>               05920000
          BEGIN   << RESTORE DCNT AND RESTART >>                        05925000
            DITP( X ) := 1;                                             05930000
            MPXWRITE(NULL,DITP);                                        05935000
          END;                                                          05940000
                                                                        05945000
        IF DBCNTP<TBMAXB THEN  << DATA ADDED TO CURRENT TBUF >>         05950000
          DITP(DCNT) := (IF DITP.DSTATE=NULL THEN DBCNTP                05955000
                              ELSE DITP(DCNT)) + I;                     05960000
        DBCNTP := DBCNTP + I;   << NEW CURRENT WRITE BYTE COUNT >>      05965000
        ENABLE;                                                         05970000
                                                                        05975000
        IF DMODEMPL.NOSYNC THEN DITP(DSYNC) := DITP(DSYNC) - I;         05980000
        DXCNTP := DXCNTP + I;    OFFSET := OFFSET + I;                  05985000
      END;                                                              05990000
                                                                        05995000
                                                                        06000000
    COUNT := COUNT - I;    IF = THEN RETURN;  << MOVE DONE >>           06005000
                                                                        06010000
    IF DMODEMPL.NOSYNC AND DITP(DSYNC)=0 THEN                           06015000
      BEGIN                                                             06020000
        DITP(DSYNC) := 80;                                     <<01227>>06025000
        IF NOT DLASTPL.BWRITE AND NOT DMODEMPL&CSL(M202) THEN           06030000
          BEGIN   << ADD ENQ FOR 2640 NOT ON A 202 >>                   06035000
            TOS := DXCNTP;   << SAVE DXCNT  OVER CALL >>       <<01.02>>06040000
            MOVEDATA(SIOADDR,1,7);   << ADD ENQ >>                      06045000
            DXCNTP := TOS;   << RESTORE DXCNT >>               <<01.02>>06050000
            IF <> THEN     << ENQ NOT ADDED, WAIT REQUEST >>            06055000
              BEGIN                                                     06060000
                RQSTATE := RQSTATE + 4;  << INDICATE AN ADD ENQ WAIT >> 06065000
                RETURN;    << WITH CC = CCG >>                          06070000
              END;                                                      06075000
          END;                                                          06080000
      END;                                                              06085000
                                                                        06090000
    GOTO STARTM;        << CONTINUE THIS OPERATION >>                   06095000
                                                                        06100000
  END;   << MOVE DATA >>                                                06105000
                                                                        06110000
                                                                        06115000
                                                                        06120000
                                                                        06125000
SUBROUTINE DOSPACE;                                                     06130000
  <<                                                                    06135000
    THIS SUBROUTINE PUTS THE SPECIFED CARRIAGE CONTROL CHARACTERS IN    06140000
    THE TERMINAL TANKS.                                                 06145000
                                                                        06150000
    RETURN CC - CCE = DATA TRANSFER COMPLETED                           06155000
                CCG = TOO MUCH DATA TO TANK NOW OR NO TBUF AVAILABLE    06160000
  >>                                                                    06165000
  BEGIN                                                                 06170000
     IF DTYPEP.TTYPE=HP2631B AND DPAGEEJECT=QPAGEEJECT THEN    <<01469>>06175000
       BEGIN  << TANK ESC SEQ TO OR NOT TO AUTO PAGE EJECT >>  <<01469>>06180000
       ABS(ABSSIOADDR+6) := IF QPAGEEJECT THEN %30114          <<01469>>06185000
         ELSE %30514;                                          <<01469>>06190000
       MOVEDATA(SIOADDR,6-DXCNTP,8+DXCNTP);                    <<01469>>06195000
       IF <> THEN RETURN;                                      <<01469>>06200000
       DPAGEEJECT := NOT DPAGEEJECT;                           <<01469>>06205000
       DXCNTP := 0;                                            <<01469>>06210000
       END;                                                    <<01469>>06215000
    IF DLASTPL.BWRITE THEN GOTO ALLDONE;                                06220000
    TEMP := 0;     << INDEX TO LF EOR SEQUENCE >>                       06225000
                                                                        06230000
    IF QPAR1P=1 THEN  << SPACE CONTROL IMBEDED IN BUFFER >>             06235000
      BEGIN                                                             06240000
        X := BCNT;                                                      06245000
        IF = THEN GOTO BADREQUEST;                                      06250000
        PDISABLE;                                              <<00.05>>06255000
        TOS := Q1ADDR;     TOS := DATA'ADR(IOQP);              <<00.05>>06260000
        TOS := 1;    ASMB( MDS );     << FIRST WORD TO ARRAY Q1 >>      06265000
        PENABLE;                                               <<00.05>>06270000
        X := BQ1;   << GET FIRST BYTE >>                                06275000
      END                                                               06280000
    ELSE X := QPAR1P;   << PUT SPACE CONTROL IN X >>                    06285000
                                                                        06290000
  NEWFORM := IF X="1" THEN TRUE ELSE FALSE;                    <<01469>>06295000
    X := X-%53;                                                         06300000
    IF < THEN GOTO SINGLESPACE;                                         06305000
    IF = THEN GOTO DS1;    << "+" = %53 = NO LF >>                      06310000
    X := X-5;    << X = CHAR - %60 >>                                   06315000
    IF = THEN   <<  "0" = %60 = DOUBLE SPACE >>                         06320000
      BEGIN   X := 2;  GOTO DS1;    END;                                06325000
    X := X-1;    << X = CHAR - %61 >>                                   06330000
    IF = AND DTYPEPL.FORMFEED THEN  << "1" = TOP OF FORM >>             06335000
      TEMP := 4;   << OFFSET TO XOFF, CR AND FF >>                      06340000
  IF %217<=X AND X<%237 AND DTYPEPL.TTYPE=HP2631B THEN         <<01469>>06345000
    BEGIN    << FORM VFC SEQ >>                                <<01469>>06350000
    TEMP := 8; SCNT := 0; I := 7-DXCNTP;                       <<01469>>06355000
    TOS := (X-%216) MOD 10 + %60;                              <<01469>>06360000
    IF X>%227 THEN TOS := TOS LOR %30400                       <<01469>>06365000
      ELSE TOS := TOS LOR %30000;                              <<01469>>06370000
    ABS(ABSSIOADDR+6) := TOS;                                  <<01469>>06375000
    GOTO DESC;                                                 <<01469>>06380000
    END;                                                       <<01469>>06385000
    X := X-%237;    << X = CHAR - %320 >>                               06390000
    IF <> THEN   << NOT A %320 >>                                       06395000
      BEGIN                                                             06400000
        X := X+%120;   << X = CHAR - %200 >>                            06405000
        IF NOT (0<=X<=%77) THEN    << NOT MULTIPLE LINE FEEDS >>        06410000
SINGLESPACE:                                                            06415000
          X := 1;   << SET X TO SINGLE SPACE >>                         06420000
DS1:                                                                    06425000
        SCNT := X + 2;   << LF COUNT + 2 FOR XOFF, CR >>                06430000
                                                                        06435000
        X := DXCNTP;  << NO XOFF IF TERM NOT HARD COPY >>      <<01.02>>06440000
        IF = AND DTYPEP.TTYPE>6 THEN DXCNTP := DXCNTP+1;      <<00.06>> 06445000
        I := (IF SCNT>4 THEN 4 ELSE SCNT) - DXCNTP;                     06450000
        IF > THEN  << ADD XOFF, CR, 1 OR 2 LF'S OR FF >>                06455000
DESC:                                                          <<01469>>06460000
          BEGIN                                                         06465000
            MOVEDATA( SIOADDR, I, DXCNTP+TEMP );                        06470000
            IF <> THEN RETURN;   << GO WAIT REQUEST >>                  06475000
          END;                                                          06480000
                                                                        06485000
        WHILE DXCNTP<SCNT DO                                            06490000
          BEGIN                                                         06495000
            MOVEDATA(SIOADDR, 1, 2);   << APPEND LINE FEEDS >>          06500000
            IF <> THEN RETURN;  << GO WAIT REQUEST >>                   06505000
          END;                                                          06510000
      END;                                                              06515000
                                                                        06520000
ALLDONE:                                                                06525000
    ASMB(DZRO,CMP );   << SET CC = CCE >>                               06530000
  END;    << DO SPACE >>                                                06535000
                                                                        06540000
                                                                        06545000
                                                                        06550000
INTEGER SUBROUTINE PINWORD;                                             06555000
  <<                                                                    06560000
     THIS SUBROUTINE RETURNS THE PIN OF THE MAIN PROCESS TO WHICH       06565000
     THE DEVICE IS CURRENTLY ATTACHED.                                  06570000
  >>                                                                    06575000
    BEGIN                                                               06580000
      RESETDB(-1);                                                      06585000
      TEMP := EXCHANGEDB(LDTDST);                                       06590000
      PINWORD := WA0(WA0.ESIZE*LDEV+1);                                 06595000
      TOS := EXCHANGEDB(TEMP);   << RESTORE DB >>                       06600000
      ASMB( PCAL SETSYSDB );   DEL;                                     06605000
    END;    << MAIN PIN >>                                              06610000
                                                                        06615000
                                                                        06620000
SUBROUTINE SETUPCHANNEL;                                                06625000
  << THIS SUBROUTINE INITIALIZES THE WRITE AND READ CHANNELS >>         06630000
  BEGIN                                                                 06635000
    DISABLE;                                                            06640000
    DITP.UP := 1;                                                       06645000
    IF = THEN                                                  <<01469>>06650000
      BEGIN                                                    <<01469>>06655000
      IF DITP(DTRLX).LOGONTRLX <> 0 THEN                       <<01448>>06660000
        STOPTIMEOUT(LOGONTO,DITP);                             <<01448>>06665000
      IF DTYPEP.TTYPE=HP2631B THEN RQSTATE := RESET31;         <<01469>>06670000
      END;                                                     <<01469>>06675000
    DSPEEDP.SPDSENSING := 0;                                            06680000
    ENABLE;                                                             06685000
                                                                        06690000
    MPXCONTROL( WRTCHAN, DITP);   << INITIALIZE WRITE CHANNEL >>        06695000
    MPXCONTROL(ECHOOFF, DITP);  << INITIALIZE RECIEVE CHANNEL >>        06700000
  END;  << SET UP CHANNEL >>                                            06705000
$PAGE "ASYCHRONOUS TERMINAL MONITOR  -  TERM "                          06710000
                                                                        06715000
       <<--------- BEGIN MONITOR/DRIVER ------------>>                  06720000
                                                                        06725000
    TOS := 6;    << DST NUMBER OF CORE >>                               06730000
    TOS := SYSDB + WA0(DITP(DILTP)+ISIOP);  << SET SIOADDR >>           06735000
    TOS := DITP(DLDEV).DLDEVN;   << SET LDEV >>                         06740000
    TOS := 0 D;  TOS := 0 D;   << ROOM FOR IOQP,QMISCP,QWBCTP,QPAR1P >> 06745000
                                                                        06750000
    TOS := @DITP+DRQST;          <<  SET DRQSTP >>                      06755000
    TOS := S0 + 1;               <<  SET DTYPEP  >>                     06760000
    TOS := S0 + 1;               <<  SET DMODEMP >>                     06765000
    TOS := S0 + 1;               <<  SET DSPEEDP >>                     06770000
    TOS := S0 + 1;               <<  SET DCNTRLP >>                     06775000
    TOS := S0 + 1;               <<  SET DRBCTP  >>                     06780000
    TOS := S0 + 1;               <<  SET DBCNTP  >>                     06785000
    TOS := S0 + 4;               <<  SET DXCNTP  >>                     06790000
    TOS := S0 + 7;               <<  SET DLASTP  >>                     06795000
                                                                        06800000
    DISABLE;                                                            06805000
    TOS := DITP;                                                        06810000
    TOS.ACTIVE := 1;                                                    06815000
    IF = THEN GOTO CONTINUE;  << SERVICE REQUEST HERE >>                06820000
                                                                        06825000
    TOS.REQUEST := 1;   << ALREADY ACTIVE SET REQUEST FLAG >>           06830000
    DITP := TOS;                                                        06835000
    RETURN;                                                             06840000
                                                                        06845000
GOWAIT:                                                                 06850000
    X := DBCNTP;                                               <<01.02>>06855000
    IF <> AND NOT DITPL.UP THEN SUDDENDEATH(203);              <<01.02>>06860000
                                                               <<01.02>>06865000
    DISABLE;                                                            06870000
    TOS := DITP;                                                        06875000
    TOS.REQUEST := 0;                                                   06880000
    IF <> THEN GOTO CONTINUE;  << SERVICE REQUESTED, EXECUTE AGAIN >>   06885000
                                                                        06890000
    TOS.ACTIVE := 0;                                                    06895000
    DITP := TOS;                                                        06900000
    RETURN;                                                             06905000
                                                                        06910000
AGAIN:                                                                  06915000
    DISABLE;                                                            06920000
    TOS := DITP;                                                        06925000
$PAGE                                                                   06930000
                                                                        06935000
CONTINUE:                                                               06940000
    TOS := DITP(DIOQP);   TOS := S0;  << GET IOQP >>                    06945000
    TOS := S0 + QMISC;    << FORM QMISCP >>                             06950000
    QPQM  := TOS;         << SET IOQP   AND QMISCP >>                   06955000
                                                                        06960000
    ASMB(TEST     );   << TEST IOQP >>                                  06965000
    IF <> THEN << USER REQUEST PENDING >>                               06970000
      BEGIN                                                             06975000
        TOS := QMISCP.RSTATE;   << SET RQSTATE >>                       06980000
        TOS := IOQP(QFUNC).FUNC; << SET FUNCTION >>                     06985000
      END                                                               06990000
    ELSE ASMB(DZRO,DECB);  << NULL RSTATE & INVALID FUNCTION >>         06995000
    RQSFUNC := TOS;        << SET RQSTATE AND FUNCTION >>               07000000
                                                                        07005000
    TOS := TOS + QWBCT;    << FORM QWBCTP >>                            07010000
    TOS := S0 + 1;         << FORM QPAR1P >>                            07015000
    QCQP1 := TOS;          << SET QWBCTP AND QPAR1P >>                  07020000
                                                                        07025000
    X := DBCNTP;                                               <<01.02>>07030000
    IF <> AND NOT DITPL.UP THEN SUDDENDEATH(203);              <<01.02>>07035000
                                                               <<01.02>>07040000
                                                                        07045000
    <<------------ CHECK FOR ONLINE ---------->>                        07050000
                                                                        07055000
    TOS.REQUEST := 0;                                                   07060000
    TESTBIT UP');                                                       07065000
    DITP := TOS;                                                        07070000
                                                                        07075000
    IF = AND DRQSTP=0 THEN    << NOT ONLINE & NO SERVICE REQUESTS >>    07080000
      BEGIN                                                             07085000
        X := @IOQP;                                                     07090000
        IF = THEN GOTO GOWAIT;  << NO REQUESTS PENDING >>               07095000
         IF FUNCTION = FILEOPEN THEN FUNCTION := ALLOCATE;     <<00190>>07100000
                                                                        07105000
        IF NOT(1<=(FUNCTION-ALLOCATE+1)<=16) OR %077647&CSL(X) <<01469>>07110000
        OR RQSTATE<>0 THEN << OR NOT OLD REQUEST >>            <<01469>>07115000
          BEGIN  << NOT ALLOCATE,GET SPD, GET TYPE >>          <<00.06>>07120000
            TOS := OFFLINE;                                             07125000
            GOTO CLEARCOUNT;                                            07130000
          END;                                                          07135000
      END;                                                              07140000
$PAGE                                                                   07145000
                                                                        07150000
    <<-------- CHECK FOR ANY TERMINAL SERVICE REQUESTS ----------- >>   07155000
                                                                        07160000
    X := DRQSTP;      << TEST SERVICE REQUEST FLAGS >>                  07165000
    IF = THEN GOTO CHKABORT;    << NO SERVICE REQUESTS PENDING >>       07170000
                                                                        07175000
    DMONITOR(DITP,%12,DITP,DRQSTP);                                     07180000
                                                                        07185000
    TOS := DRQSTP;    ASMB( SCAN 0 );    DEL;                           07190000
                                                                        07195000
    TOS := DRQSTP;        << CLEAR REQUEST FLAG >>                      07200000
    ASMB( TRBC 0,X );                                                   07205000
    DRQSTP := TOS;                                                      07210000
    ENABLE;                                                             07215000
                                                                        07220000
    ASMB( LOAD RTABLE,X; ADAX      ;  BR RTABLE,X;                      07225000
                                                                        07230000
RTABLE:  << TERM SERVICE REQUEST JUMP TABLE >>                          07235000
                                                                        07240000
      CON HANGUPTOL;CON DISCNCTL;  CON CFAILTOL; CON TURNTOL;           07245000
      CON HP2640TOL;CON CHKABORT;  CON SPOOLSWL; CON SPOOLENDL;<<00.06>>07250000
      CON READTOL;  CON ONLINEL;   CON DSETRDYL; CON LOGONTOL;          07255000
      CON BREAKL;   CON SSBREAKL;  CON BLOCKTOL; CON CHKSTAT); <<02004>>07260000
                                                                        07265000
                                                                        07270000
  CHKSTAT:                                                     <<01469>>07275000
    IF @IOQP=0 THEN GOTO GOWAIT;                               <<01469>>07280000
    TOS := IOQP(QSTAT).IOSTAT;                                 <<01469>>07285000
    IF <> AND FUNCTION<>FILEOPEN THEN GOTO SETSTATUS;          <<01469>>07290000
    DEL;                                                       <<01469>>07295000
    GOTO GOODDONE;                                             <<01469>>07300000
                                                                        07305000
  <<-------- CHECK FOR REQUEST ABORT OR PREMPT ------------->>          07310000
                                                                        07315000
CHKABORT:                                                               07320000
    X := @IOQP;                                                         07325000
    IF = THEN GOTO GOWAIT;     << NO USER REQUESTS >>                   07330000
                                                                        07335000
    <<------------ CHECK FOR ABORTS AND PREMPTIONS ------------ >>      07340000
                                                                        07345000
    DISABLE;                                                            07350000
    IF QMISCPL.NOSTOP THEN GOTO RSWITCH; << NO ABORT/PREMPT >>          07355000
    IF READABORTED THEN GOTO GOWAIT;                                    07360000
                                                                        07365000
    IF DITP.DSTATE=WRITING AND (DITP(DMONTR).XONWAIT=1 OR      <<01468>>07370000
      DITP.ACKWAIT=1) THEN                                     <<01468>>07375000
      BEGIN                                                    <<00.06>>07380000
        @THISP := @IOQP;                                       <<00.06>>07385000
        WHILE <> DO << LOOK FOR ABORTED REQUESTS >>            <<00.06>>07390000
          BEGIN                                                <<00.06>>07395000
            IF THISP<0 THEN << REQUEST ABORTED >>              <<00.06>>07400000
              BEGIN  << RESTART PAUSED WRITE >>                <<00.06>>07405000
                DITP.ENQACKWAIT := 0;                          <<00.06>>07410000
                DITP(DMONTR).XONWAIT := 0;                     <<01468>>07415000
                SENDSYNC(WRITING,DITP);                        <<00.06>>07420000
              END;                                             <<00.06>>07425000
            @THISP := THISP(QLINK);   << STEP TO NEXT >>       <<00.06>>07430000
          END;                                                 <<00.06>>07435000
      END;                                                     <<00.06>>07440000
                                                               <<00.06>>07445000
    X := IOQP;   << TEST BIT 0 FOR ABORT >>                             07450000
    IF < THEN  << ABORT REQUESTED >>                                    07455000
      BEGIN                                                             07460000
        IF DITP.DSTATE=STARTREAD THEN SENDSYNC(NULL,DITP);              07465000
ABORTL:                                                                 07470000
        DISABLE;                                               <<00.06>>07475000
    IF DITP.DSTATE=WRITING THEN                                <<01469>>07480000
      BEGIN                                                    <<01469>>07485000
      DITP.DSTATE := NULL;                                     <<01469>>07490000
      IF DTYPEP.TTYPE=HP2631B THEN SENDSYNC(EORSYNC,DITP);     <<01469>>07495000
      END;                                                     <<01469>>07500000
        RETURNBUFS;                                                     07505000
        TOS := ABORTED;                                                 07510000
CLEARCOUNT:                                                             07515000
        QWBCTP := 0;                                                    07520000
        GOTO SETSTATUS;                                                 07525000
      END;     <<  ABORT PROCESSING >>                                  07530000
                                                                        07535000
    ENABLE;                                                             07540000
                                                                        07545000
                                                                        07550000
  <<-------------- CHECK FOR AND PROCESS PREMPTS --------------->>      07555000
                                                                        07560000
    X := DMODEMP;   << BIT 0 PREMPTIVE REQUEST INDICATOR >>             07565000
    IF < AND NOT QMISCPL.NOPREMPT THEN                                  07570000
      BEGIN  << PREMPTABLE AND PREMPT REQUESTED >>                      07575000
        @THISP := @IOQP;    NPL := 0;                                   07580000
        WHILE <> DO  << FIND MOST PREMPTIVE >>                          07585000
          BEGIN                                                         07590000
            IFLAG := THISP.RPLEVEL;                                     07595000
            IF IFLAG=CONSMODE AND NOT DMODEMPL.CMODE THEN               07600000
              THISP.RPLEVEL := NULL   << SET CORRECT PREMPT LEVEL >>    07605000
                                                                        07610000
            ELSE IF IFLAG>NPL THEN  << MORE PREMPTIVE >>                07615000
              BEGIN                                                     07620000
                NPL := THISP.RPLEVEL;                                   07625000
                SAVEPS := THESEPS;    << SAVE THISP AND LASTP >>        07630000
              END;                                                      07635000
            @LASTP := @THISP;  @THISP := THISP(QLINK); <<STEP TO NEXT>> 07640000
          END;                                                          07645000
                                                                        07650000
        DISABLE;                                                        07655000
        TOS := NPL;                                                     07660000
        IF = THEN DMODEMP.PREMPT :=  0;  << NO PREMPTIVE REQUESTS >>    07665000
                                                                        07670000
        IF TOS>IOQP.RPLEVEL THEN  << FIRST HAS BEEN PREMPTED >>         07675000
          BEGIN                                                         07680000
            IFLAG := QMISCP.RSTATE;                                     07685000
            IF = OR IFLAG=READWAITING THEN  << NEW SO JUST RELINK >>    07690000
              BEGIN                                                     07695000
                IF DITP.DSTATE=STARTREAD THEN SENDSYNC(NULL,DITP);      07700000
                QMISCP := 0;   << FORCE RESTART OF REQUEST >>           07705000
                DITP(DIOQP) := @STHISP;  << LINK NEW TO DIT >>          07710000
                SLASTP(QLINK) := STHISP(QLINK); << DELINK,RELINK REST >>07715000
                STHISP(QLINK) := @IOQP;  << LINK REST TO NEW >>         07720000
                GOTO AGAIN;                                             07725000
              END;                                                      07730000
                                                                        07735000
            IF NPL>=SOFTPREMPT AND (> OR DBCNTP=0) THEN                 07740000
              STOPREAD(PREMPTSTOP);  << HARD OR SOFT & NO INPUT >>      07745000
            GOTO GOWAIT;                                                07750000
          END;                                                          07755000
      END;     << PREMPT PROCESSING  >>                                 07760000
$PAGE                                                                   07765000
                                                                        07770000
    << SWITCH ON REQUEST STATE, NO SERVICE REQUESTS PENDING >>          07775000
RSWITCH:                                                                07780000
    ENABLE;                                                             07785000
    DMONITOR(DITP,%10,QPAR1P CAT IOQP(QFUNC) (0:9:7), -1);              07790000
                                                                        07795000
    IF FUNCTION<=WRITING THEN   << FORM WORD AND BYTE COUNTS >>         07800000
      BEGIN                                                             07805000
        TOS := DRBCTP;                                                  07810000
        WCNT := (S0+1)&LSR(1);    BCNT := TOS;                          07815000
                                                                        07820000
        TOS := ABS(ABS(CPCB)+PCB3).DSTFIELD;   << STACK DST NUMBER >>   07825000
        PUSH( Q, DL );    TOS := TOS-TOS+1;  << OFFSET TO PCB LENGTH >> 07830000
        X := -S0;                                                       07835000
        TOS := TOS + Q0(X);   << DST RELATIVE ADDR OF Q+1 >>            07840000
        Q1ADDR := TOS;   << SET STACKDST AND TBASE >>                   07845000
      END;                                                              07850000
                                                                        07855000
    X := RQSTATE.(12:4);  << MASK TO SWITCH PART >>                     07860000
    ASMB( LOAD RQTABLE,X;  ADAX;   BR RQTABLE,X;                        07865000
                                                                        07870000
RQTABLE:                                                                07875000
      CON NEWL;       CON NOTNEWL;  CON GOWAIT;     CON READDONEL;      07880000
      CON STOPPEDL;  CON RDSTART1;  CON RESETL;  CON GOWAIT;   <<01469>>07885000
      CON PRETOPOSTL; CON PRESPACEL;CON TBWAITL;    CON POSTSPACEL;     07890000
      CON FINISHENQ;  CON FINISHENQ;CON FINISHENQ;  CON FINISHENQ);     07895000
$PAGE                                                                   07900000
                                                                        07905000
    << ------------ START NEW REQUESTS -------------- >>                07910000
                                                                        07915000
NEWL:                                                                   07920000
    IF DITP(DSAVE).HSTATE >= HANGUPTURN THEN BEGIN             <<02859>>07925000
        TOS := OFFLINE;                                        <<02859>>07930000
        GOTO SETSTATUS;                                        <<02859>>07935000
    END;                                                       <<02859>>07940000
    IF DMODEMP.TMODE>=CONSMODE AND IOQP.RPLEVEL<CONSMODE THEN           07945000
      GOTO GOWAIT;   << MODE LEVEL HOLD OFF OF REQUEST >>               07950000
                                                                        07955000
    FLAG := (IOQP(QPAR2).BINARY<>0) XOR DLASTPL.BWRITE;                 07960000
    IF FLAG OR IOQP.RPLEVEL<>DMODEMP.LPLEVEL OR FUNCTION>WRITING        07965000
     OR DITP.DSTATE>WRITING THEN                                        07970000
      BEGIN   << CAN NOT CONCATENATE WRITES >>                          07975000
        IF DITP.DSTATE<>NULL THEN GOTO GOWAIT;                          07980000
                                                                        07985000
        IF FUNCTION<>WRITING OR FLAG THEN                               07990000
          BEGIN  << RESTORE PARITY TO ORGINAL SENSE >>                  07995000
            DLASTP.BWRITE := 0;                                         08000000
            IF <> THEN   << WAS IN BINARY MODE, SO RESTORE >>           08005000
              BEGIN                                                     08010000
                DCNTRLP.PARITYBITS := DLASTP.PARITYSAVE;                08015000
                SETUPCHANNEL;                                           08020000
              END;                                                      08025000
          END;                                                          08030000
                                                                        08035000
        IF IOQP.RPLEVEL>DMODEMP.LPLEVEL AND NOT DITPL.NEWLINE THEN      08040000
          BEGIN    << HIGHER PREMPT LEVEL AND NOT NEW LINE >>           08045000
            SENDSYNC(EORSYNC,DITP);   << DO A CR/LF >>                  08050000
            GOTO GOWAIT;                                                08055000
          END;                                                          08060000
      END;                                                              08065000
                                                                        08070000
    DISABLE;                                                            08075000
    DMODEMP.LPLEVEL := IOQP;         << SET NEW PREMPT LEVEL >>         08080000
                                                                        08085000
    TOS := QWBCTP;                                                      08090000
    IF < THEN TOS := -TOS ELSE TOS := TOS&LSL(1);                       08095000
    IF < THEN BEGIN DEL; TOS := %77777; END;                            08100000
    DRBCTP := TOS;                                                      08105000
                                                                        08110000
    DXCNTP := 0;                                                        08115000
    RQSTATE := NOTNEW;                                                  08120000
    GOTO RSWITCH;   << SET COUNTS AND SWITCH ON FUNCTION >>             08125000
$PAGE                                                                   08130000
                                                                        08135000
NOTNEWL:                                                                08140000
    <<------------ SWITCH ON FUNCTION ------------->>                   08145000
                                                                        08150000
    X := FUNCTION;                                                      08155000
    X := X-FMAX;                                                        08160000
    IF <= THEN    << FUNCTION OK  >>                                    08165000
      ASMB( LOAD FTABEND,X;  ADAX      ;  BR FTABEND,X;                 08170000
        CON READL;    CON WRITEL;   CON FOPENL;    CON FCLOSEL;         08175000
        CON DCLOSEL;  CON SETTOL;   CON INSPDL;    CON OUTSPDL;         08180000
        CON ECHOONL;  CON ECHOOFFL; CON BRKOFFL;   CON BRKONL;          08185000
        CON SSBRKOFFL;CON SSBRKONL; CON TAPEOFFL;  CON TAPEONL;         08190000
        CON TIMEOFFL; CON TIMEONL;  CON READTIMEL; CON PRTYOFFL;        08195000
        CON PRTYONL;  CON LOGGEDONL;CON BADREQUEST;CON TERMTYPEL;       08200000
        CON ALLOCATEL;CON CFWRITEL; CON CXECHOON;  CON CXECHOOFF;       08205000
        CON GOODDONE; CON PTAPEL;   CON SETBMODEL; CON SETCMODEL;       08210000
        CON SETPTYL;  CON ALLOCATEL;CON TERMTYPEL; CON GETTERMTYPE;     08215000
        CON RETURNSPD;CON STOPCHARS;                           <<00.03>>08220000
FTABEND:                                                                08225000
        CON SETCNTRLA);                                        <<00.03>>08230000
                                                                        08235000
BADREQUEST:                                                             08240000
    TOS := INVALIDOP;                                                   08245000
    GOTO CLEARCOUNT;                                                    08250000
                                                                        08255000
                                                                        08260000
FINISHENQ:                                                              08265000
    TOS := DXCNTP;            << SAVE TRANSFER COUNT >>                 08270000
    MOVEDATA(SIOADDR, 1,7);   << ADD AN ENQ >>                          08275000
    DXCNTP := TOS;            << RESTORE TRANSFER COUNT >>              08280000
    IF <> THEN GOTO GOWAIT;   << STILL NOT POSSIBLE TO ADD ENQ >>       08285000
    RQSTATE := RQSTATE - 4;   << RESTORE BACK TO INTERUPTED OPERATION >>08290000
    GOTO RSWITCH;                                                       08295000
$PAGE                                                                   08300000
                                                                        08305000
    << ------------- INITIATE READS -------------- >>                   08310000
                                                                        08315000
READL:                                                                  08320000
    IF IOQP.RPLEVEL=NULL THEN  << OK TO FLUSH >>                        08325000
      BEGIN                                                             08330000
        X:= DITP(DLDEV);  << TEST FOR BREAK FLUSH >>                    08335000
        IF < THEN  << BREAK FLUSH >>                                    08340000
          BEGIN                                                         08345000
            TOS := BREAKEND;                                            08350000
            GOTO CLEARCOUNT;                                            08355000
          END;                                                          08360000
                                                                        08365000
        X := QMISCP;                                                    08370000
        IF < THEN GOTO CNTRLDONE;  << CONTROL Y FLUSH, RETURN DONE OK >>08375000
      END;                                                              08380000
                                                                        08385000
    EOFCHECK(IOQP, 0 D, 0, 0);                                          08390000
    IF <> THEN    << END OF FILE, NO READ >>                            08395000
      BEGIN                                                             08400000
        TOS := IOQP(QSTAT);   << GET EOF STATUS >>                      08405000
        GOTO SETSTATUS;                                                 08410000
      END;                                                              08415000
                                                                        08420000
    X := DITP(DRPTR);  << TEST FOR SAVED READ DATA >>                   08425000
    IF <> AND QPAR1P.EOFCODE<>NOEOFCHECK THEN                           08430000
      BEGIN  << SET UP AS IF JUST READ >>                               08435000
        IF DITP.DSTATE<>NULL THEN GOTO GOWAIT;                          08440000
        TOS := DITP(DRPTR);  DITP(DRPTR) := 0;                          08445000
        DITP(DHEAD) := TOS;   << LINK IN TBUFS >>                       08450000
        DBCNTP := DITP(DRCNT);                                          08455000
        GOTO READDONEL;                                                 08460000
      END;                                                              08465000
                                                                        08470000
READSTART:                                                              08475000
    DISABLE;                                                   <<WH.30>>08480000
    QMISCP.RSTATE := READWAITING;                                       08485000
                                                                        08490000
RDSTART1:                                                               08495000
    DISABLE;                                                   <<WH.23>>08500000
    IF DITP.DSTATE=NULL AND QMISCP.RSTATE=READWAITING THEN     <<00209>>08505000
MEASUREMENT1:                                                  <<01240>>08510000
       BEGIN                                                   <<01240>>08515000
       IF MEASURE THEN DITPD(17):=TIMER;                       <<01240>>08520000
       SENDSYNC(STARTREAD,DITP);                               <<00209>>08525000
       END;                                                    <<01240>>08530000
    GOTO GOWAIT;                                                        08535000
$PAGE                                                                   08540000
   <<------------------ READ STOPPED ------------------->>              08545000
                                                                        08550000
STOPPEDL:                                                               08555000
    X := QMISCP.READSTOP - 1;                                           08560000
    ASMB( LOAD STOPTAB,X;  ADAX;  BR STOPTAB,X;                         08565000
                                                                        08570000
STOPTAB:                                                                08575000
      CON BRKSTOP;   CON READDONEL;   CON PRMPTSTOP; CON TIMEOUTL;      08580000
      CON ABORTL;    CON BKTIMEOUTL);                          <<02004>>08585000
                                                                        08590000
PRMPTSTOP:                                                              08595000
    RETURNBUFS;                                                         08600000
    QMISCP := 0;   << RESTORE REQUEST TO NEW STATE >>                   08605000
    GOTO AGAIN;                                                         08610000
                                                                        08615000
TIMEOUTL:                 << READ TIMED OUT AND STOPPED >>              08620000
    RETURNBUFS;                                                         08625000
    SETREADERROR(IOQP,READTO);                                          08630000
    GOTO READDONEL;                                                     08635000
                                                               <<02004>>08640000
BKTIMEOUTL:                                                    <<02004>>08645000
    RETURNBUFS;                                                <<02004>>08650000
    SETREADERROR(IOQP, BLOCKTO);                               <<02004>>08655000
    GO TO READDONEL;                                           <<02004>>08660000
                                                                        08665000
BRKSTOP:                                                                08670000
    X := DBCNTP;   << ANY BROKEN READ DATA? >>                          08675000
    IF <>  AND IOQP.READERRORS= NULL THEN                               08680000
    << CHECK FOR DOUBLE BREAK (POSSIBLE VIA INTERACTIVE >>     <<00195>>08685000
    << STREAM COMMAND).                                 >>     <<00195>>08690000
    IF DITP(DBREAK) = 0 THEN   << IF NOT  DOUBLE BREAK>>       <<00195>>08695000
      BEGIN  << GET AN IOQ AND SAVE BROKEN READ RESTART DATA >>         08700000
        TOS := GETIOQ( 0 );   << IMPEDE IF NO IOQ AVAILABLE >>          08705000
        MOVE PS0 := DBCNTP,(10);                                        08710000
        PS0(QLINK) := 0;  << NECESSARY FOR IOQ RETURN TEST >>  <<01.02>>08715000
        DITP(DBREAK) := TOS;   << SAVE IOQP TO SAVED DATA >>            08720000
        DBCNTP := 0;  << SO NO TBUF RETURN >>                           08725000
      END;                                                              08730000
                                                                        08735000
    SETREADERROR(IOQP,BRKEND);                                          08740000
$PAGE                                                                   08745000
                                                                        08750000
    <<-------------- READ COMPLETION -------------->>                   08755000
                                                                        08760000
READDONEL:                                                              08765000
    TOS := IF DRBCTP<DBCNTP THEN DRBCTP ELSE DBCNTP;                    08770000
    WCNT := (S0+1)&LSR(1);    BCNT := TOS;                              08775000
                                                                        08780000
    IF LOGICAL(BCNT) THEN   << ADD IN LAST ODD CHAR FOR WORD MOVES >>   08785000
      BEGIN                                                             08790000
        X := DITP(DHEAD);                                               08795000
        TEMP := BCNT/TBMAXB;   << NUMBER OF BUFFERS - 1 MORE OR LESS >> 08800000
        WHILE > DO   << STEP DOWN CHAINED BUFS TO ONE TO MODIFY >>      08805000
          BEGIN   X := WA0(X);   TEMP := TEMP -1;  END;                 08810000
        TEMP := BCNT MOD TBMAXB + (X+1)&LSL(1); << BYTE ADDRESS >>      08815000
        PDISABLE;                                              <<00.05>>08820000
        TOS := Q1ADDR;    TOS := DATA'ADR(IOQP);               <<00.05>>08825000
        TOS := TOS + WCNT - 1;  << ADDRESS OF LAST WORD >>     <<00.05>>08830000
        TOS := 1;    ASMB( MDS );  << GET LAST WORD >>         <<00.05>>08835000
        BA0(TEMP) := Q1;  << BYTE TO BE RESTORED >>            <<00.05>>08840000
        PENABLE;                                               <<00.05>>08845000
      END;                                                     <<00.05>>08850000
                                                                        08855000
    IF IOQP.READERRORS<BRKEND AND IOQP(QPAR2).BINARY=0 THEN    <<01.02>>08860000
      BEGIN   << NO BAD ERRORS AND NOT BINARY, SO CHECK FOR EOF >>      08865000
        EOFCHECK(IOQP,DOUBLE(DITP(DHEAD)+SYSDB1),-DBCNTP,1);            08870000
        IF <> THEN      << AN EOF >>                                    08875000
          BEGIN                                                         08880000
            IF < THEN << BACKUP, SAVE DATA >>                           08885000
              BEGIN                                                     08890000
                DITP(DRCNT) := DBCNTP;   << SAVE DATA READ COUNT >>     08895000
                DITP(DRPTR) := DITP(DHEAD);                             08900000
                DBCNTP := 0;   << SO NO TBUFS RETURNED >>               08905000
              END;                                                      08910000
                                                                        08915000
            RETURNBUFS;                                                 08920000
            TOS := IOQP(QSTAT);  << GET EOF STATUS >>                   08925000
            GOTO SETSTATUS;                                             08930000
          END;                                                          08935000
      END;                                                              08940000
                                                                        08945000
    X := QWBCTP;                                                        08950000
    QWBCTP := IF >= THEN WCNT ELSE -BCNT;                               08955000
                                                                        08960000
    PDISABLE;                                                  <<00.05>>08965000
    TOS := DATA'ADR(IOQP);                                     <<00.05>>08970000
    TADDR := TOS;      TEMP := TOS;                            <<00.05>>08975000
    SCNT := IF IOQPL.SYSBUFR THEN 128 ELSE WCNT;               <<00.05>>08980000
    TCNT := TBMAXW;    TBASE := DITP(DHEAD);                   <<00.05>>08985000
                                                               <<00.05>>08990000
    WHILE WCNT>0 DO                                            <<00.05>>08995000
      BEGIN                                                    <<00.05>>09000000
        I := WCNT;                                             <<00.05>>09005000
        IF I>TCNT THEN I := TCNT;  << TBUF END IS MOVE CONSTRAINT >>    09010000
        IF I>SCNT THEN I := SCNT;  << SBUF END IS CONSTRAINT >>         09015000
                                                                        09020000
        TOS := TEMP;   TOS := TADDR;                           <<00.05>>09025000
        TOS := 6;    TOS := TBASE + SYSDB1;                             09030000
        TOS := I;    ASMB( MDS );                                       09035000
                                                                        09040000
        WCNT := WCNT - I;   << UPDATE REMAINING WORD COUNT >>           09045000
        IF <> THEN      << MORE TO MOVE >>                              09050000
          BEGIN                                                         09055000
            TBASE := TBASE + I;                                <<01.02>>09060000
            TADDR := TADDR + I;                                         09065000
            TCNT  := TCNT  - I;                                         09070000
            IF = THEN   << END OF A TBUF >>                             09075000
             BEGIN TBASE:=WA0(TBASE-TBMAXW); TCNT:=TBMAXW; END;<<01.02>>09080000
                                                                        09085000
            SCNT := SCNT - I;                                           09090000
            IF = THEN    << END OF AN SBUF >>                           09095000
              BEGIN                                                     09100000
                TADDR := SBUF(TADDR-129);   << STEP TO NEXT SBUF >>     09105000
                SCNT := 128;                                            09110000
              END;                                                      09115000
          END;                                                 <<00.05>>09120000
      END;                                                     <<00.05>>09125000
                                                               <<00.05>>09130000
    PENABLE;                                                   <<00.05>>09135000
                                                                        09140000
READDONE1:                                                              09145000
    DISABLE;                                                            09150000
    IF DMODEMPL.NOSYNC THEN DITP(DSYNC) := 80;                 <<01227>>09155000
                                                                        09160000
    RETURNBUFS;                                                         09165000
    TOS := READSTATUS(IOQP.READERRORS);                                 09170000
    GOTO SETSTATUS;                                                     09175000
$PAGE                                                                   09180000
                                                                        09185000
  <<----------- PROCESS WRITES ----------------->>                      09190000
                                                                        09195000
WRITEL:                                                                 09200000
    IF IOQP(QPAR2).BINARY<>0 AND NOT DLASTPL.BWRITE THEN                09205000
      BEGIN << MODES DONT AGREE, SO SET TO BINARY MODE >>               09210000
        TOS := DLASTP;                                                  09215000
        TOS.BWRITE := 1;                                                09220000
        TOS.PARITYSAVE := DCNTRLP.PARITYBITS;                           09225000
        DCNTRLP.PARITYBITS := 0;  << NO PARITY GENERATE >>              09230000
        DLASTP := TOS;                                                  09235000
        SETUPCHANNEL;                                                   09240000
      END;                                                              09245000
MEASUREMENT4:                                                  <<01240>>09250000
  IF MEASURE THEN MMSTAT(232,LDEV,0,BCNT);                     <<01240>>09255000
                                                                        09260000
    IF IOQPL(QPAR2) THEN  << PRESPACE >>                                09265000
      BEGIN                                                             09270000
        RQSTATE := PRESPACE;                                            09275000
PRESPACEL:                                                              09280000
        DOSPACE;                                                        09285000
        IF <> THEN GOTO WAITREQUEST;                                    09290000
      END                                                               09295000
    ELSE                                                                09300000
      BEGIN                                                             09305000
        DCNTRLP.PRESPLAST := 0;                                         09310000
        IF <> AND NOT DITPL.NEWLINE THEN  << DO A CR/LF >>              09315000
          BEGIN                                                         09320000
            RQSTATE := PRETOPOST;                                       09325000
PRETOPOSTL:                                                             09330000
            MOVEDATA(SIOADDR, 2, 1);   << ADD A CR/LF >>                09335000
            IF <> THEN GOTO WAITREQUEST;                                09340000
          END;                                                          09345000
      END;                                                              09350000
                                                                        09355000
    DXCNTP := 0;                                               <<01.02>>09360000
    IF QPAR1P=1 THEN   << CHECK BYTE COUNT >>                  <<01.02>>09365000
      BEGIN                                                    <<01.02>>09370000
        IF BCNT=0 THEN GOTO BADREQUEST;  << INVALID BYTE COUNT <<01.02>>09375000
        DXCNTP := DXCNTP + 1;   << STEP OVER CONTROL BYTE >>   <<01.02>>09380000
      END;                                                     <<01.02>>09385000
                                                               <<01.02>>09390000
    RQSTATE := TBWAIT;                                                  09395000
                                                                        09400000
TBWAITL:                                                                09405000
    PDISABLE;                                                  <<00.05>>09410000
    MOVEDATA( DATA'ADR(IOQP), BCNT-DXCNTP, DXCNTP );           <<00.05>>09415000
    IF <> THEN   << MOVE NOT COMPLETED, SO WAIT REQUEST >>              09420000
      BEGIN                                                             09425000
        PENABLE;                                               <<00.05>>09430000
WAITREQUEST:                                                            09435000
        QMISCP.RSTATE := RQSTATE;   << SAVE REQUEST STATE FOR RESTART >>09440000
        STARTWRITE;                                                     09445000
        GOTO GOWAIT;                                                    09450000
      END;                                                              09455000
    PENABLE;                                                   <<00.05>>09460000
                                                                        09465000
    IF NOT IOQPL(QPAR2) THEN  << POST SPACE >>                          09470000
      BEGIN                                                             09475000
        RQSTATE := POSTSPACE;   DXCNTP := 0;                            09480000
POSTSPACEL:                                                             09485000
        DOSPACE;                                                        09490000
        IF <> THEN GOTO WAITREQUEST;   << SPACING NOT COMPLETED >>      09495000
      END;                                                              09500000
                                                                        09505000
    IF DTYPEPL.TTYPE=HP2631B AND DBCNTP<>0 THEN                <<01469>>09510000
      BEGIN                                                    <<01469>>09515000
      RQSTATE := WRITEWAIT;    << GO WAIT UNTIL STATUS DONE>>  <<01781>>09520000
      GOTO WAITREQUEST;                                        <<01469>>09525000
      END;                                                     <<01469>>09530000
    STARTWRITE;                                                         09535000
                                                                        09540000
                                                                        09545000
    <<-------- FINISH UP USER REQUESTS ------------->>                  09550000
                                                                        09555000
GOODDONE:                                                               09560000
RESETL:                                                        <<01469>>09565000
    IF RQSTATE=RESET31 THEN                                    <<01469>>09570000
      BEGIN                                                    <<01469>>09575000
      NEWFORM := 1;                                            <<01469>>09580000
      IF = THEN I := 68 ELSE I := 66;                          <<01469>>09585000
      MOVEDATA(0D,I-DXCNTP,DXCNTP);                            <<01469>>09590000
      IF <> THEN                                               <<01469>>09595000
        BEGIN                                                  <<01469>>09600000
        QMISCP.RSTATE := RQSTATE;                              <<01469>>09605000
        GOTO GOWAIT;                                           <<01469>>09610000
        END;                                                   <<01469>>09615000
      RQSTATE := WRITEWAIT;    << GO WAIT UNTIL STATUS DONE>>  <<01781>>09620000
      REQSTAT := 1;                                            <<01469>>09625000
      DPAGEEJECT := 1;                                         <<01469>>09630000
      GOTO WAITREQUEST;                                        <<01469>>09635000
      END;                                                     <<01469>>09640000
    TOS := GOODIO;                                                      09645000
                                                                        09650000
SETSTATUS:                                                              09655000
    DMONITOR(DITP,%11,S0 CAT IOQP(QFUNC) (0:9:7), -1);        <<00.05>> 09660000
                                                                        09665000
    DISABLE;                                                            09670000
    DITP(DMONTR).CFAILCNT := 0; << RESET CARRIER FAILURE COUNTER 01.01>>09675000
    IOQP(QSTAT).IOSTAT := TOS;   << SET COMPLETION STATUS >>            09680000
    IOQP.COMPLETED := 1;                                                09685000
    TEMP := IOQP(QSTAT)&PCBS;    << EXTRACT PCB NUMBER >>               09690000
    DITP(DIOQP) := IOQP(QLINK);                                         09695000
    ENABLE;                                                             09700000
                                                                        09705000
    IF LOSTDATA<=IOQP.READERRORS<=PTYERROR THEN                <<00.05>>09710000
      LOGERROR(DITP,IOQP,RDCOUNTER+WRTCOUNTER);                <<00.05>>09715000
                                                                        09720000
    IF IOQPL.IOWAKE THEN                                                09725000
      AWAKE(TEMP*PCBSIZE,IOWAIT&LSL(IOQP.BLOCKED),NOWAIT);              09730000
                                                                        09735000
    X := TEMP;     << TEST PCB NUMBER >>                                09740000
    IF = THEN    << NO PCB I/O, RETURN IOQ AND SYSBUFS >>               09745000
      BEGIN                                                             09750000
        X := IOQP(QADDR);  << CHECK FOR SYSBUF TO BE RETURNED >>        09755000
        IF <> THEN RETURNSYSBUF( X );                                   09760000
        RETURNIOQ(@IOQP);                                               09765000
      END;                                                              09770000
                                                                        09775000
    GOTO AGAIN;  << CHECK FOR FURTHER REQUESTS >>                       09780000
$PAGE                                                                   09785000
                                                                        09790000
   << --------- FILE CLOSE AND DEVICE CLOSE -------------- >>           09795000
                                                                        09800000
FCLOSEL:                                                                09805000
    IF DMODEMP.TMODE=NULL THEN CLEANUP;                                 09810000
    IF NOT DITPL.NEWLINE AND DTYPEP.TTYPE<>HP2631B THEN        <<01469>>09815000
      SENDSYNC(EORSYNC,DITP); << CR, LF >>                     <<01469>>09820000
    GOTO FOPENL;                                               <<01469>>09825000
                                                                        09830000
DCLOSEL:                                                                09835000
    DITP(DSAVE).HSTATE := CLOSED;  << SO NO SOFTKILL >>                 09840000
    DRQSTP.DISCNCT := 1;                                                09845000
MEASUREMENT3:                                                  <<01240>>09850000
  IF MEASURE THEN MMSTAT(235,LDEV,0,0);                        <<01240>>09855000
                                                                        09860000
FOPENL:                                                                 09865000
  IF DTYPEPL.TTYPE=HP2631B THEN                                <<01469>>09870000
    BEGIN                                                      <<01469>>09875000
    NEWFORM := 1;                                              <<01469>>09880000
    IF = THEN BEGIN                                            <<01469>>09885000
      MPXWRITE(CR, DITP);  DELAY(100D);                        <<01469>>09890000
      MPXWRITE(FF, DITP);  DELAY(100D);  END;                  <<01469>>09895000
    END;                                                       <<01469>>09900000
CNTRLDONE:                                                              09905000
    ENABLE;                                                             09910000
    TOS := 0;                                                           09915000
                                                                        09920000
CNTRLDONE1:                                                             09925000
    QWBCTP := TOS;                                                      09930000
    GOTO GOODDONE;                                                      09935000
                                                                        09940000
SETTOL:                                                                 09945000
    DITP(DRTMAX) := QPAR1P;                                             09950000
    GOTO CNTRLDONE;                                                     09955000
                                                                        09960000
INSPDL:                                                                 09965000
OUTSPDL:                                                                09970000
    TOS := DTYPEP.TTYPE;   << GET TERMINAL TYPE >>                      09975000
    TOS := QPAR1P;         << GET NEW SPEED VALUE >>                    09980000
                                                                        09985000
FINDSPEED:                                                              09990000
    TEMP := TOS;    << SAVE REQUESTED SPEED >>                          09995000
    X := MAXSPEED;   << SEARCH SPEED TABLE FOR SPEED >>                 10000000
    DO IF TEMP=SPEED(X) THEN GOTO SPEEDFOUND UNTIL DXBZ;                10005000
    GOTO BADREQUEST;   << SPEED NOT FOUND >>                            10010000
                                                                        10015000
SPEEDFOUND:                                                             10020000
    TOS := X;   << SPEED NUMBER TO TOS >>                               10025000
    IF FUNCTION<>ALLOCATE AND FUNCTION<>ALLOCATEX THEN                  10030000
      BEGIN << RETURN OLD SPEED >>                                      10035000
        TOS := DSPEEDP.INSPEED;                                         10040000
        TOS := DSPEEDP.OUTSPEED;                                        10045000
                                                                        10050000
        IF FUNCTION=OUTSPD THEN ASMB( CAB     );  << SPD # TO TOS >>    10055000
                                                                        10060000
        ASMB( XCH,STAX);   << OLD SPEED # TO X >>                       10065000
        QWBCTP := SPEED( X );  << RETURN OLD SPEED >>                   10070000
      END                                                               10075000
    ELSE TOS := S0;   << DUP NEW SPEED NUMBER >>                        10080000
                                                                        10085000
SETTYPE:                                                                10090000
    SETTERMTYPE( *, *, *, DITP );                                       10095000
    IF <> THEN GOTO BADREQUEST;  << INVALID TYPE OR SPEED >>            10100000
                                                                        10105000
    SETUPCHANNEL;                                                       10110000
    DISABLE;                                                            10115000
    DITP(DSAVE).HSTATE := ONLINE;                                       10120000
    ENABLE;                                                             10125000
    GOTO GOODDONE;                                                      10130000
                                                                        10135000
ECHOONL:                                                                10140000
ECHOOFFL:                                                               10145000
    TOS := (NOT DSPEEDPL).ECHO; << RTN CURRENT STATE >>        <<01.01>>10150000
    DSPEEDP.ECHO := NOT LOGICAL(FUNCTION);  << SET OR RESET >>          10155000
    GOTO CNTRLDONE1;                                                    10160000
                                                                        10165000
BRKOFFL:                                                                10170000
BRKONL:                                                                 10175000
    DSPEEDP.BRKOK := FUNCTION;   << SET OR RESET >>                     10180000
    GOTO CNTRLDONE;                                                     10185000
                                                                        10190000
SSBRKONL:                                                               10195000
SSBRKOFFL:                                                              10200000
    DISABLE;                                                            10205000
    TOS := LPDTD(LDEV);                                                 10210000
    TOS.(SSBREAK':1) := 0;   << CLEAR SUB SYS BRK OCCURRED FLAG >>      10215000
    LPDTD(X) := TOS;                                                    10220000
                                                                        10225000
    DSPEEDP.SSBRKOK := FUNCTION;                                        10230000
    GOTO CNTRLDONE;                                                     10235000
                                                                        10240000
TAPEOFFL:                                                               10245000
TAPEONL:                                                                10250000
    DSPEEDP.TAPEMODE := FUNCTION;                                       10255000
    GOTO CNTRLDONE;                                                     10260000
                                                                        10265000
TIMEOFFL:                                                               10270000
TIMEONL:                                                                10275000
    DTYPEP.TIMEREAD := FUNCTION;                                        10280000
    GOTO CNTRLDONE;                                                     10285000
$PAGE                                                                   10290000
                                                                        10295000
    <<****** FORM TIME OF LAST READ IN 1/100 SECONDS *********>>        10300000
                                                                        10305000
READTIMEL:                                                              10310000
    IF DITP(DRTIME)<>-1 THEN   << VALID TIME, NO OVERFLOW >>            10315000
      BEGIN                                                             10320000
        TOS := DITP(X);   << GET TIME TAKEN TO COMPLETE READ >>         10325000
        GOTO CNTRLDONE1;                                                10330000
      END;                                                              10335000
                                                                        10340000
    TOS := RTOVERFLOW;                                                  10345000
    GOTO CLEARCOUNT;                                                    10350000
                                                                        10355000
PRTYOFFL:                                                               10360000
PRTYONL:                                                                10365000
    DISABLE;                                                            10370000
    IF DITP(DLDEV).NOPTY <>0 THEN  GOTO BADREQUEST;            <<AMS00>>10375000
 <<PARITY CHECKING NOT ALLOWED IF TTYPE IS 8-BIT TTYPE>>       <<AMS00>>10380000
    DITP.PTYCHK := NOT LOGICAL(FUNCTION);                               10385000
    GOTO CNTRLDONE;                                                     10390000
                                                                        10395000
LOGGEDONL:                                                              10400000
    STOPTIMEOUT(LOGONTO,DITP);                                          10405000
    IF DITP(DSAVE).HSTATE=LOGGINGON THEN                                10410000
      DITP(DSAVE).HSTATE := ONLINE;                                     10415000
                                                                        10420000
    IF QPAR1P=SESSION THEN DSPEEDP.BRKOK := 1;                          10425000
    DITP(DMONTR).LOGONTYPE := QPAR1P;                          <<00163>>10430000
MEASUREMENT2:                                                  <<01240>>10435000
  IF MEASURE THEN MMSTAT(234,LDEV,0,0);                        <<01240>>10440000
    GOTO CNTRLDONE;                                                     10445000
                                                                        10450000
ALLOCATEL:                                                              10455000
                                                                        10460000
    X := LOGICAL(QPAR1P) LOR IOQPL(QPAR2); << TEST FOR DEFAULT   00.06>>10465000
    IF = THEN  << USE PRECONFIGURED VALUES >>                  <<00.06>>10470000
      BEGIN                                                    <<00.06>>10475000
        TOS := DLASTP.TERMINALTYPE;                            <<00.06>>10480000
        TOS := SPEED(DLASTP.TERMSPEED);                        <<00.06>>10485000
      END                                                      <<00.06>>10490000
    ELSE                                                       <<00.06>>10495000
      BEGIN                                                    <<00.06>>10500000
        TOS := QPAR1P;  << TERMINAL TYPE >>                    <<00.06>>10505000
        TOS := IOQP(QPAR2);   << SPEED SPECIFICATION >>        <<00.06>>10510000
      END;                                                     <<00.06>>10515000
    IF = THEN GOTO BADREQUEST ELSE GOTO FINDSPEED;                      10520000
                                                                        10525000
    <<---------------- CLEAR FLUSH FLAG THEN WRITE ----------------->>  10530000
                                                                        10535000
CFWRITEL:                                                               10540000
    DITP(DLDEV).FLUSH := 0;                                             10545000
    IF <> THEN DCNTRLP.PRESPLAST := 1;   << FORCE NEWLINE >>            10550000
    IOQP(QFUNC).FUNC := WRITING;                                        10555000
    GOTO AGAIN;  << GO DO WRITE >>                                      10560000
                                                                        10565000
CXECHOON:                                                               10570000
CXECHOOFF:                                                              10575000
    DITP(DLDEV).NO'CX'ECHO := FUNCTION;                                 10580000
    GOTO CNTRLDONE;                                                     10585000
$PAGE                                                                   10590000
                                                                        10595000
SETBMODEL:                                                              10600000
    DISABLE;                                                            10605000
    DMODEMP.BMODE := QPAR1P;                                            10610000
    GOTO CNTRLDONE;                                                     10615000
                                                                        10620000
SETCMODEL:                                                              10625000
    DISABLE;                                                            10630000
    DMODEMP.CMODE := QPAR1P;                                            10635000
    GOTO CNTRLDONE;                                                     10640000
                                                                        10645000
SETPTYL:                                                                10650000
    IF DITP(DLDEV).NOPTY<>0 OR LOGICAL(QPAR1P) > 3 THEN        <<AMS00>>10655000
        GOTO BADREQUEST;                                       <<AMS00>>10660000
 <<PARITY SET FUNC. NOT ALLOWED IF TTYPE IS 8-BIT TTYPE>>      <<AMS00>>10665000
    TOS := DCNTRLP.PARITYBITS;                                          10670000
    DCNTRLP.PARITYBITS := QPAR1P;                                       10675000
                                                                        10680000
    SETUPCHANNEL;                                                       10685000
    GOTO CNTRLDONE1;                                                    10690000
                                                                        10695000
TERMTYPEL:                                                              10700000
    TOS := QPAR1P;        << SET NEW TERM TYPE >>                       10705000
    TOS := DSPEEDP.INSPEED;                                             10710000
    TOS := DSPEEDP.OUTSPEED;                                            10715000
    GOTO SETTYPE;                                                       10720000
                                                                        10725000
GETTERMTYPE:                                                            10730000
    TOS := DTYPEP.TTYPE;   << GET TERMINAL TYPE >>                      10735000
    GOTO CNTRLDONE1;                                                    10740000
                                                                        10745000
RETURNSPD:                                                     <<00.03>>10750000
    TOS := SPEED(DSPEEDP.OUTSPEED);                                     10755000
    GOTO CNTRLDONE1;                                                    10760000
                                                                        10765000
STOPCHARS:                                                              10770000
    DITP(DSTOP) := QPAR1P;    << SET SUB SYS BRK & EOR CHARS >>         10775000
    GOTO CNTRLDONE;                                                     10780000
                                                               <<00.03>>10785000
SETCNTRLA:                                                     <<00.03>>10790000
    DTYPEP.CONSINTRPT := QPAR1P;                               <<00.03>>10795000
    GOTO CNTRLDONE;                                            <<00.03>>10800000
$PAGE                                                                   10805000
                                                                        10810000
    << -------------DATA SET READY SERVICE ------------->>              10815000
                                                                        10820000
DSETRDYL:                                                               10825000
    IF DITP(DSAVE).HSTATE=0 AND LPDT(LDEV*2+1).ACCEPTING<>0 THEN<<0.04>>10830000
      BEGIN                                                             10835000
        DITP(DSAVE).HSTATE := LOGGINGON;                                10840000
        STARTTIMEOUT(LOGONTO,DITP);                                     10845000
      END;                                                              10850000
                                                                        10855000
    IF DMODEMPL&CSL(M202) THEN                                          10860000
      BEGIN   << TURN TERMINAL TO READ STATE >>                         10865000
        DSETCONTROL(WRITING,DITP);                                      10870000
        DSETCONTROL(TRANSMIT,DITP);  << RAISE CA >>                     10875000
        DELAY( 2000 D );   << LET CF RAISE AT TERMINAL >>               10880000
        DSETCONTROL(READING,DITP);                                      10885000
      END;                                                              10890000
                                                                        10895000
    GOTO AGAIN;                                                         10900000
                                                                        10905000
                                                                        10910000
        <<---------- ON LINE SERVICE -------------->>                   10915000
                                                                        10920000
ONLINEL:                                                                10925000
    TEMP := DITP(DSAVE).HSTATE;                                         10930000
    IF = OR TEMP=LOGGINGON THEN   << CHECK FOR DEVICE RECOGNITION >>    10935000
      IF LPDT(LDEV*2+1).DEVREC=0 AND LPDT(X).ACCEPTING<>0 THEN <<00.04>>10940000
        BEGIN                                                           10945000
          DISABLE;                                                      10950000
          LPDT(X).SERVREQ := 1;  << REQUEST DEVREC SERVICE >>           10955000
          LPDT(1) := LPDT(1) + 1;<< BUMP SERVICE REQUEST COUNTER >>     10960000
          ENABLE;                                                       10965000
                                                                        10970000
          SETTERMTYPE(DLASTP.TERMINALTYPE,DITP(DCNT),DITP(X),DITP);     10975000
          IF <> THEN  << CONFIGURE AS UNDEFINED TERMTYPE >>             10980000
            BEGIN                                                       10985000
              SETTERMTYPE(UNDEFINED,DITP(X),DITP(X),DITP);              10990000
              IF <> THEN GOTO DISCNCTL;                                 10995000
            END;                                                        11000000
                                                                        11005000
          SETUPCHANNEL;                                                 11010000
          DITP(DSAVE).HSTATE := LOGGINGON;                              11015000
          STOPTIMEOUT(SPEEDTO,DITP);                                    11020000
          STARTTIMEOUT(LOGONTO,DITP);                                   11025000
          AWAKE(DEVRECPCBP,JUNKWAIT,NOWAIT);                            11030000
        END;                                                            11035000
                                                                        11040000
    GOTO AGAIN;                                                         11045000
$PAGE                                                                   11050000
                                                                        11055000
         <<--------- BREAK ACCEPTED SERVICE ---------------->>          11060000
                                                                        11065000
BREAKL:                                                                 11070000
    BREAKJOB(LDEV,PINWORD.MAINPIN);                            <<DS.06>>11075000
    IF = THEN       << BREAK ACCEPTED, STOP OPERATION >>                11080000
      BEGIN                                                             11085000
        DITP(DLDEV).FLUSH := 1;                                         11090000
        STOPOPERATION(BREAKSTOP);                                       11095000
      END                                                               11100000
    ELSE  RESTARTOPERATION;   << BREAK REFUSED >>                       11105000
    GOTO AGAIN;                                                         11110000
                                                                        11115000
                                                                        11120000
   <<--------CONTROL Y ACCEPTED SERVICE ------------>>                  11125000
                                                                        11130000
SSBREAKL:                                                               11135000
    BREAKSS(LDEV,PINWORD);                                     <<DS.06>>11140000
    IF = AND DMODEMP.TMODE=NULL THEN  << NOT IN A BREAK >>     <<DS.06>>11145000
      BEGIN   << STOP READ/WRITE AND FLUSH REQUESTS >>         <<DS.06>>11150000
        STOPOPERATION(SSBRKSTOP);                              <<DS.06>>11155000
        X := @IOQP;                                            <<DS.06>>11160000
        WHILE <> DO  << SET FLUSH FLAGS >>                     <<DS.06>>11165000
          BEGIN                                                <<DS.06>>11170000
            DISABLE;                                           <<DS.06>>11175000
            IOQP(QMISC).FLUSH := 1;                            <<DS.06>>11180000
            @IOQP := IOQP(QLINK);  << STEP TO NEXT >>          <<DS.06>>11185000
          END;                                                 <<DS.06>>11190000
        GOTO AGAIN;                                            <<DS.06>>11195000
      END;                                                     <<DS.06>>11200000
                                                                        11205000
    RESTARTOPERATION;   << NO CY PIN SO NO SUB SYS BREAK >>             11210000
    GOTO AGAIN;                                                         11215000
$PAGE                                                                   11220000
                                                                        11225000
                                                                        11230000
  <<--------- 202 TURN AROUND TIMED OUT -------->>                      11235000
                                                                        11240000
TURNTOL:                                                                11245000
    STOPTIMEOUT(TURNTO,DITP);                                           11250000
    DISABLE;                                                            11255000
    IF READABORTED OR DITP.DSTATE<>TURN202 THEN GOTO AGAIN;             11260000
    SENDSYNC(NULL,DITP);  << SO ANY INTERRUPTS ARE IGNORED >>           11265000
    ENABLE;                                                             11270000
                                                                        11275000
    DSETCONTROL(READING,DITP);  << RAISE SB AT TERMINAL >>              11280000
    DELAY( 2000 D );  << LET RAISE >>                                   11285000
    SENDSYNC(TURN202,DITP);    << TRY TO WRITE AGAIN >>                 11290000
    GOTO AGAIN;                                                         11295000
                                                                        11300000
    <<-------- HP2640 READ OR WRITE TIME OUT SERVICE ---------->>       11305000
                                                                        11310000
HP2640TOL:                                                              11315000
    STOPTIMEOUT(HP2640TO,DITP);                                         11320000
    CHECKTQUEUE(DITP);  << DEQUEUE THIS AND START ANY WAITING >>        11325000
                                                                        11330000
    TEMP := DITP(DSAVE).HSTATE;                                         11335000
    IF %55&LSR(TEMP) THEN   << A SPEED SENSING TIMEOUT >>               11340000
      BEGIN                                                             11345000
        IF TEMP<=LOGGINGON THEN  << DISCONNECT SPEED SENSING >>         11350000
          BEGIN                                                         11355000
            DITP(DSAVE).HSTATE := TEMP+3;  << SAVE OLD HSTATE >>        11360000
            DSPEEDP.SPDSENSING := 0;                                    11365000
            STARTTIMEOUT(INITTO,DITP);                                  11370000
          END                                                           11375000
        ELSE   << RECONNECT SPEED SENSING >>                            11380000
          BEGIN                                                         11385000
            DSPEEDP.SPDSENSING := 1;                                    11390000
            DITP(DSAVE).HSTATE := TEMP-3;  << RESTORE HSTATE >>         11395000
          END;                                                          11400000
                                                                        11405000
        MPXCONTROL(ECHOOFF,DITP);                                       11410000
        GOTO AGAIN                                                      11415000
      END;                                                              11420000
                                                                        11425000
    DISABLE;                                                            11430000
    X := @IOQP;                                                         11435000
     IF <> OR DBCNTP<>0 THEN    << REQUEST NOT DONE >>         <<01227>>11440000
      BEGIN                                                             11445000
        IF RQSTATE=READING THEN                                         11450000
          BEGIN                                                         11455000
            TEMP := QMISCP.READSTOP;   << BLOCK MODE READ STOPPED? >>   11460000
            IF <> THEN   << BLOCK MODE READ STOP WAS REQUESTED >>       11465000
              BEGIN                                                     11470000
                QMISCP.READSTOP := NULL;                                11475000
                STOPREAD(TEMP);  <<  STOP READ NOW >>                   11480000
              END;                                                      11485000
          END                                                           11490000
        ELSE   << RESTART ANY WAITING WRITES >>                         11495000
          IF (DTYPEP.TTYPE = HP2635A OR                        <<00234>>11500000
             DTYPEP.TTYPE = HP2635B) AND                       <<00234>>11505000
             NOT DMODEMPL&CSL(M202) THEN                       <<00234>>11510000
             BEGIN  <<ASSUME PAPEROUT CONDITION ON HP2635>>    <<00234>>11515000
                STARTTIMEOUT(HP2640TO,DITP);                   <<00234>>11520000
                DITP.ENQACKWAIT := 1;                          <<00234>>11525000
                MPXWRITE(ENQ,DITP);                            <<00234>>11530000
                DITP.PAIR := 1;                                <<00234>>11535000
             END                                               <<00234>>11540000
          ELSE                                                 <<00234>>11545000
             BEGIN                                             <<00234>>11550000
                IF DTYPEPL.TTYPE=HP2631B THEN                  <<01469>>11555000
                  BEGIN  << STATUS REQUEST TIMED OUT >>        <<01469>>11560000
                  IF NOT IOMESSAGE (1,NOTRDYMSG, %10000,       <<01469>>11565000
                  DITP(DLDEV).DLDEVN,,,,,OPCONSOLE) THEN       <<01469>>11570000
                  BEGIN   END; << NO SYSTEM MESSAGE BUFF >>    <<01469>>11575000
                  REQSTAT := 0;                                <<01469>>11580000
                  DRQSTP.STATDONE := 0;                        <<01469>>11585000
                  GOTO DISCNCTL;                               <<01469>>11590000
                  END;                                         <<01469>>11595000
                DITP.ENQACKWAIT := 0;                          <<00234>>11600000
                MPXWRITE(NULL,DITP); <<SEND SYNC CHAR TO GET   <<00234>>11605000
                                     <<WRITE OPERATION GOING>> <<00234>>11610000
             END;                                              <<00234>>11615000
      END;                                                              11620000
                                                                        11625000
    GOTO AGAIN;                                                         11630000
                                                                        11635000
                                                                        11640000
                                                                        11645000
  <<----- INITWAIT, SPEED TIMEOUT AND HANGUP SERVICE ---------->>       11650000
                                                                        11655000
HANGUPTOL:                                                              11660000
    STOPTIMEOUT(HANGUPTO,DITP);                                         11665000
    IF DITP(DSAVE).HSTATE=HANGUPTURN THEN                               11670000
      GOTO HANGUPDSET  << 202 TURN TO READ COMPLETED >>                 11675000
        ELSE GOTO INITCHAN;  << HANG UP WAIT COMPLETED >>               11680000
                                                                        11685000
                                                                        11690000
   <<------- READ OPERATION TIMED OUT SERVICE --------->>               11695000
                                                                        11700000
READTOL:                                                                11705000
    STOPTIMEOUT(READTIMEOUT,DITP);                                      11710000
    DISABLE;                                                            11715000
    DITP(DRTMAX) := 0;  <<  CLEAR TIME OUT REQUEST FLAG >>              11720000
    STOPREAD(READTOSTOP);                                               11725000
    GOTO AGAIN;                                                         11730000
                                                                        11735000
BLOCKTOL:                                                      <<02004>>11740000
    STOPTIMEOUT(BLOCKTIMEOUT, DITP);                           <<02004>>11745000
    DISABLE;                                                   <<02004>>11750000
    DMODEMPL.RDCOUNTED := 0;                                   <<02004>>11755000
    IF <> THEN                                                 <<02004>>11760000
       RDCOUNTER := RDCOUNTER - 1;                             <<02004>>11765000
    STOPREAD(BLOCKTOSTOP);                                     <<02004>>11770000
    GO TO AGAIN;                                               <<02004>>11775000
                                                                        11780000
    <<-------- CARRIER FAILED TIME OUT SERVICE ---------->>             11785000
                                                                        11790000
CFAILTOL:                                                               11795000
    STOPTIMEOUT(CFAILTO,DITP);                                          11800000
                                                                        11805000
    IF NOT DMODEMPL&CSL(M202) THEN GOTO DISCNCTL;              <<00.02>>11810000
                                                               <<00.02>>11815000
    IF DMODEMPL.CB THEN  << CHECK FOR SB >>                    <<00.02>>11820000
      BEGIN IF NOT DMODEMPL.SB THEN GOTO DISCNCTL; END         <<00.02>>11825000
    ELSE IF NOT DMODEMPL.CF THEN GOTO DISCNCTL;                <<00.02>>11830000
                                                               <<00.02>>11835000
    DISABLE;                                                   <<00.02>>11840000
    READABORTED;  << ABORT READ IF REQUESTED >>                <<00.02>>11845000
    ENABLE;                                                    <<00.02>>11850000
                                                               <<00.02>>11855000
    IF DITP.DSTATE=TURN202 THEN  << TRY TO TURN AGAIN >>       <<00.02>>11860000
      BEGIN                                                    <<00.02>>11865000
        DSETCONTROL(TRANSMIT,DITP);  << RAISE CF AT TERMINAL >><<00.02>>11870000
        DELAY( 2000 D );  << WAIT FOR CF TO RAISE >>           <<00.02>>11875000
        MPXWRITE(NULL,DITP);                                   <<00.02>>11880000
      END;                                                     <<00.02>>11885000
                                                               <<00.02>>11890000
    GOTO AGAIN;                                                <<00.02>>11895000
$PAGE                                                                   11900000
                                                                        11905000
           <<-------- DISCONNECT AND HANG UP ---------->>               11910000
                                                                        11915000
LOGONTOL:                                                               11920000
    STOPTIMEOUT(LOGONTO,DITP);                                          11925000
                                                               <<02859>>11930000
                                                               <<02859>>11935000
                                                                        11940000
DISCNCTL:                                                               11945000
                                                               <<02859>>11950000
                                                               <<02859>>11955000
    IF DITP(DSAVE).HSTATE>=HANGUPTURN THEN                              11960000
      GOTO AGAIN;    << CURRENTLY IN A HANGUP SEQUENCE >>               11965000
                                                                        11970000
    DISABLE;                                                   <<00.02>>11975000
    TOS := DITPL LAND %176200;                                 <<01.02>>11980000
    TOS.PAIR := 1;   << RESTORE PAIR FOR NO READING FLAG >>    <<01.02>>11985000
    DITP := TOS;                                               <<01.02>>11990000
    DTYPEP.PAIRCODE := NOTREADING;                             <<01.02>>11995000
    CLEANUP;                                                            12000000
                                                                        12005000
    X := DITP(DRPTR);                                                   12010000
    WHILE <> DO   << RETURN ANY SAVED TBUFS >>                          12015000
      BEGIN                                                             12020000
        TOS := X;   << GET POINTER FOR RETURNTBUF >>                    12025000
        X := WA0(X);     << GET LINK TO NEXT TBUF >>                    12030000
        RETURNTBUF( * );                                                12035000
      END;                                                              12040000
    DITP(DRPTR) := 0;                                                   12045000
                                                                        12050000
    DISABLE;                                                            12055000
    DITP(DLDEV).FLUSH := 0;                                             12060000
                                                                        12065000
    TOS := DSPEEDP;                                                     12070000
    TOS.TAPEMODE := 0;      TOS.ECHO := 1;                              12075000
    TOS.SSBRKOK := 0;       TOS.BRKOK := 0;                             12080000
    DSPEEDP := TOS;                                                     12085000
    DITP(DMONTR).XONWAIT := 0;                                 <<01468>>12090000
                                                                        12095000
    TOS := LPDTD(LDEV);                                                 12100000
    TOS := TOS LAND %173017; << CLEAR EOF,(SS)BRK,& LOGON >>   <<02859>>12105000
    LPDTD(X) := TOS;                                                    12110000
    ENABLE;                                                             12115000
                                                                        12120000
    IF DITP(DSAVE).HSTATE <> CLOSED AND                        <<01132>>12125000
       DITP(DMONTR).LOGONTYPE <> NULL THEN                     <<02859>>12130000
      BEGIN       << KILL MAIN >>                              <<01132>>12135000
        X := PINWORD.MAINPIN*PCBSIZE;                                   12140000
        IF <> THEN    << KILL MAIN PROCESS >>                           12145000
          BEGIN                                                         12150000
            DISABLE;                                                    12155000
            IF PCB(X:=X+PCB9)<0 THEN  << ALIVE >>                       12160000
      << CHANGE FROM SETING SOFTKILL BIT TO ABORTING JOB >>    <<01470>>12165000
      << WILL ABORT ALL I/O ASSOCIATED WITH PROCESS AND  >>    <<01470>>12170000
      << THEN SOFT KILL PROCESS.   3/80 >>                     <<01470>>12175000
              Begin                                            <<01470>>12180000
              Enable;                                          <<01470>>12185000
              TOS := Getsir (JMATsir);                         <<01470>>12190000
              ResetDB (-1);                                    <<01470>>12195000
              TOS := ExchangeDB (JMATdst);                     <<01470>>12200000
              Abortjob (X/PCBsize);                            <<01470>>12205000
              Assemble (ZERO,XCH);                             <<01470>>12210000
              TOS := ExchangeDB (*);                           <<01470>>12215000
              Assemble (PCAL SETSYSDB);                        <<01470>>12220000
              TOS := JMATsir;                                  <<01470>>12225000
              Assemble (DELB,XCH);                             <<01470>>12230000
              Relsir (*,*);                                    <<01470>>12235000
              End;                                             <<01470>>12240000
          END;                                                          12245000
      END;                                                              12250000
                                                                        12255000
    DISABLE;                                                   <<00163>>12260000
    DITP(DMONTR).LOGONTYPE := 0;  <<CLEAR LOGONTYPE  >>        <<00163>>12265000
                                                               <<00163>>12270000
    DITP.UP := 0;                                                       12275000
    IF LDEV=CONSLDEV THEN GO TO INITCHAN1;<<AVOID HANGUP ON CON<<00552>>12280000
                                                                        12285000
    IF (DMODEMP.MTYPE).(14:2)<>0 THEN  << HANG UP DATA PHONE >><<01.01>>12290000
      BEGIN                                                             12295000
        IF DMODEMPL&CSL(M202) THEN                                      12300000
          BEGIN                                                         12305000
            DSETCONTROL(READING,DITP);    << SET 202 TO READ STATE >>   12310000
            TOS := HANGUPTURN;                                          12315000
          END                                                           12320000
        ELSE                                                            12325000
          BEGIN                                                         12330000
                                                                        12335000
HANGUPDSET:                                                             12340000
            DSETCONTROL(HANGUP,DITP);  << HANGUP DSET,CLEAR CD & SA >>  12345000
            TOS := HANGINGUP;                                           12350000
          END;                                                          12355000
                                                                        12360000
        DITP(DSAVE).HSTATE := TOS;                                      12365000
        STARTTIMEOUT(HANGUPTO,DITP);                                    12370000
        GOTO AGAIN;                                                     12375000
      END;                                                              12380000
                                                                        12385000
INITCHAN:                                                               12390000
    DISABLE;                                                            12395000
INITCHAN1:                                                     <<00552>>12400000
    DITP(DMONTR).CFAILCNT := 0; << RESET CARRIER FAILURE COUNTER 01.01>>12405000
    DMODEMP := DMODEMPL LAND %077000;                                   12410000
    << CLEAR PREMPT,NOSYNC,RDCOUNTED,WRTCOUNTED,PRIMED,TMODE,LPLEVEL >> 12415000
    DITP(DSAVE) := 0;  << CLEAR HSTATE >>                               12420000
    DSPEEDP := (DLASTP.TERMSPEED+%140)&LSL(6);  <<SET ECHO & SPD SNS >> 12425000
    IF DMODEMP.MTYPE>3 THEN << NO SPEED SENSING >>             <<01.01>>12430000
      BEGIN                                                    <<01.01>>12435000
        DSPEEDP.SPDSENSING := 0;                               <<01.01>>12440000
        DSPEEDP.INSPEED := DSPEEDP.OUTSPEED;                   <<01.01>>12445000
      END;                                                     <<01.01>>12450000
    IF  DITP(DLDEV).NOPTY <> 0 THEN                            <<AMS00>>12455000
      DCNTRLP.PARITYBITS := 0   <<GENERATE NO PARITY>>         <<AMS00>>12460000
      ELSE                                                     <<AMS00>>12465000
     DCNTRLP.(7:1):= 1;                                        <<AMS00>>12470000
    DTYPEP.TTYPE := DLASTP.TERMINALTYPE;                       <<00.06>>12475000
    ENABLE;                                                             12480000
                                                                        12485000
    X := INITTO;                                                        12490000
    DO STOPTIMEOUT(X,DITP) UNTIL DXBZ; << CLEAN UP ANY TIME OUTS >>     12495000
    INITCHANNEL(DITP);  << INITIALIZE CHANNEL >>                        12500000
    GOTO AGAIN;                                                         12505000
$PAGE                                                                   12510000
                                                                        12515000
   <<----------- INITIATE PTAPE READS ------------>>                    12520000
                                                                        12525000
PTAPEL:                                                                 12530000
    DITPD(DTBF2) := IOQPD(QP1D);    << MOVE DISC BUFFER ADDRESSES >>    12535000
    TOS := @SBUF + IOQP(QADDR);    << POINTER TO 1ST SBUF >>            12540000
    TOS := @SBUF + SBUF(IOQP(X)-1);  << FORM ADDRESS OF 2ND SYSBUF >>   12545000
    DITPD(DTBUFD) := TOS;                                               12550000
                                                                        12555000
    GOTO READSTART;                                                     12560000
                                                                        12565000
                                                                        12570000
   <<---------SPOOLING COMPLETED SERVICE ----------->>                  12575000
                                                                        12580000
SPOOLENDL:                                                              12585000
    X := @IOQP;                                                <<00.05>>12590000
    IF = THEN GOTO AGAIN;  << NO USER REQUEST >>               <<00.05>>12595000
                                                               <<00.05>>12600000
    WRTSPOOLBUF(DITP(DCNT));                                  <<00.06>> 12605000
    QWBCTP := 0;                                               <<00.05>>12610000
    GOTO READDONE1;                                            <<00.05>>12615000
                                                               <<00.05>>12620000
                                                               <<00.05>>12625000
   <<--------- SPOOL BUFFER WRITE OUT SERVICE --------->>      <<00.05>>12630000
                                                               <<00.05>>12635000
SPOOLSWL:                                                      <<00.05>>12640000
    X := @IOQP;                                                <<00.05>>12645000
    IF <> THEN WRTSPOOLBUF(DITP(DHEAD));                       <<00.05>>12650000
    GOTO AGAIN;                                                <<00.05>>12655000
                                                                        12660000
  END;   << TERMIOM >>                                                  12665000
$PAGE "DRIVER LINKAGE AREA"                                             12670000
                                                                        12675000
ASMB(                                                                   12680000
  PCAL TERMIOM;   << MONITOR PLABEL >>                                  12685000
  PCAL HELP;      << NO INITIATOR >>                                    12690000
  CON  0;         << NO COMPLETOR >>                                    12695000
  CON  0;         << USE SYSTEM I/O PROCESS >>                          12700000
                                                                        12705000
  PCAL TERMINIT;  << TERMINAL INITIALIZATION  >>                        12710000
                                                                        12715000
  CON  3;         << THREE INTERRUPT HANDLERS >>                        12720000
  PCAL TIP;                                                             12725000
  PCAL DSET1;                                                           12730000
  PCAL DSET2 );                                                         12735000
                                                                        12740000
                                                                        12745000
END.   << TERMINAL MONITOR CODE SEGMENT >>                              12750000
