$CONTROL MAP,CODE,USLINIT                                               00010000
<<IOTAPE0 - MODULE 18>>                                                 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
$CONTROL MAIN=IOTAPE0                                                   00060000
$CONTROL PRIVILEGED,UNCALLABLE                                          00065000
$THIRTY                                                                 00070000
$TITLE "7970A/B/E MAGNETIC TAPE DRIVER"                                 00075000
                                                                        00080000
DRIVER REQUEST CODES:                                                   00085000
                                                                        00090000
    0 - READ                                                            00095000
        P1(13:3) - END OF FILE SPECIFICATION                            00100000
    1 - WRITE                                                           00105000
        P2(15:1) - IF SET THEN WRITE PAST END OF TAPE MARK              00110000
                   IF CLEAR THEN RETURN ERROR IF EOT HAS BEEN DETECTED  00115000
    2 - OPEN FILE (NO OPERATION)                                        00120000
    3 - CLOSE FILE (RESET EOF FLAGS IN LPDT)                            00125000
    4 - CLOSE DEVICE (RESET EOF FLAGS AND REWIND TAPE)                  00130000
    5 - REWIND                                                          00135000
    6 - WRITE TAPE MARK                                                 00140000
    7 - FORWARD SPACE FILE                                              00145000
    8 - BACKSPACE FILE                                                  00150000
    9 - REWIND AND UNLOAD                                               00155000
   10 - GAP                                                             00160000
   11 - FORWARD SPACE RECORD                                            00165000
   12 - BACKSPACE RECORD                                                00170000
                                                                        00175000
COUNT - WORD/BYTE COUNT. NOTE THAT ALTHOUGH THE BYTE COUNT RETURNED     00180000
        WILL REFLECT THE TRUE INFORMATION TRANSFER, AN EVEN NUMBER OF   00185000
        BYTES WILL ALWAYS BE PHYSICALLY TRANSFERRED.                    00190000
                                                                        00195000
DRIVER RETURN CODES:                                                    00200000
                                                                        00205000
  GENERAL STATUS (13:3)       QUALIFING STATUS (8:5)       OVERALL (8:8)00210000
                                                                        00215000
  0 - PENDING                 1 - WAITING FOR COMPLETION   %10          00220000
                              2 - DOING ERROR RECOVERY     %20          00225000
                              3 - NOT READY WAIT           %30          00230000
                              4 - NO WRITE RING WAIT       %40          00235000
                                                                        00240000
  1 - SUCCESSFUL              0 - NO ERRORS                  1          00245000
                              2 - RETRY WAS NECESSARY      %21          00250000
                              3 - EOT AFTER WRITE          %31          00255000
                                                                        00260000
  2 - END OF FILE             1 - A TAPE MARK WAS READ OR  %12          00265000
                                  P1 WAS NONZERO AND THE                00270000
                                  LAST RECORD READ WAS A                00275000
                                  TAPE MARK                             00280000
                          2 - 7   THE DATA DEPENDENT EOF                00285000
                                  CONDITION AS SPECIFIED                00290000
                                  BY EOFCHECK                           00295000
                                                                        00300000
  3 - UNUSUAL CONDITION       3 - REQUEST ABORTED          %33          00305000
                              6 - POWERFAIL ABORT          %63          00310000
                              7 - BOT AND BACKSPACE REQ.   %73          00315000
                             10 - TAPE RUNAWAY             %103         00320000
                            %11 - EOT AND WRITE REQ.       %113         00325000
  4 - IRRECOVERABLE ERROR     0 - INVALID REQUEST            4          00330000
                              1 - TRANSMISSION ERROR       %14          00335000
                              3 - TIMING ERROR             %34          00340000
                              4 - SIO FAILURE              %44          00345000
                              5 - UNIT FAILURE             %54          00350000
                              7 - TAPE PARITY ERROR        %74          00355000
                            %12 - SYSTEM ERROR             %124         00360000
                                                                        00365000
                                                                        00370000
TAPE CONTROLLER STATUS                                                  00375000
   BITS       USE                                                       00380000
                                                                        00385000
      0       SIO OK                                                    00390000
      1       ODD BYTE READ                                             00395000
      2       INTERRUPT REQUEST                                         00400000
   3- 4       UNIT NUMBER                                               00405000
      5       END OF TAPE                                               00410000
      6       WRITE PROTECTED                                           00415000
      7       UNIT READY                                                00420000
      8       BEGINNING OF TAPE                                         00425000
      9       800/1600 CPI DRIVE                                        00430000
     10       LAST OPERATION WAS A WRITE                                00435000
     11       END OF FILE MARK DETECTED                                 00440000
  12-14       ENCODED ERROR STATUS                                      00445000
     15       9/7 TRACK DRIVE (ALWAYS 0)                                00450000
                                                                        00455000
   ENCODED ERROR STATUS                                                 00460000
                                                                        00465000
      000   UNIT READY                                                  00470000
      001   TRANSFER ERROR                                              00475000
      010   COMMAND REJECTED                                            00480000
      011   TAPE RUNAWAY                                                00485000
      100   TIMING ERROR                                                00490000
      101   TAPE ERROR                                                  00495000
      110   UNUSED                                                      00500000
      111   NO ERROR ENCOUNTERED                                        00505000
$PAGE                                                                   00510000
BEGIN                                                                   00515000
EQUATE                                                                  00520000
   ABORTIO     = %33,      << I/O ABORTED RETURN STATUS >>              00525000
   BACK'       = 1,        << BACKSPACE RECOVERY BIT OF QMISC >>        00530000
   BOTBACK     = %73,      << BACKSPACE ERROR STATUS RETURN >>          00535000
   BSFILE      = %13,                                                   00540000
   BSRECORD    = %12,                                                   00545000
   BSRF        = 12,                                           <<00.05>>00550000
   CLOSE       = 3,                                                     00555000
   CONSOLE     = 0,        << MESSAGE REQUEST >>                        00560000
   DCLOSEF     = 4,                                                     00565000
   DDFLAG      = 9,       <<DIT REWIND FLAG>>                  <<00.05>>00570000
   DLDEV       = 3,        << DIT LDEV INDEX >>                         00575000
   DLOGERROR   = 11,       << DIT ERROR LOG STATUS >>          <<01338>>00580000
   DSERR       = 7,        << DIT ERROR STATUS INDEX >>                 00585000
   DSTAT       = 6,        << DIT DEVICE STATUS INDEX >>                00590000
   DTIME       = 8,       <<DIT TIMEOUT COMPLETED INDICATOR>>  <<00.05>>00595000
   DTRLX       = 10,      <<DIT TIMEOUT DELAY DTRLX>>          <<00.05>>00600000
   ENDINT      = %034000,                                               00605000
   EOFB'       = 4,       << END OF FILE BACKSPACE BIT OF QMISC >>      00610000
   FORSP'      = 2,       << FORWARD SPACE RECOVERY BIT OF QMISC >>     00615000
   FSFILE      = %17,                                                   00620000
   FSRECORD    = 7,                                                     00625000
   FSRF        = 11,                                           <<00.05>>00630000
   GAPF        = 10,                                                    00635000
   GOODEOT     = %31,      << EOT AFTER WRITE RETURN STATUS >>          00640000
   GOODRETRY   = %21,      << RETRY NECESSARY FOR SUCCESS RETURN STAT >>00645000
   GOODSTAT    = 1,        << REQUEST SUCCESSFUL STATUS RETURN >>       00650000
   INVFUNC     = 4,        << INVALID FUNCTION STATUS RETURN >>         00655000
   NOERR       = 7,        << NO ERROR ENCODED STATUS RETURN >>         00660000
   NOTRDYMSG   = 11,       << NOT READY MSG CAT INDEX >>                00665000
   NOWRITERING = 220,      << NO WRITE RING MSG CAT INDEX >>            00670000
   OPEN'       = 7,        << Avail bit in QMISC >>            <<02629>>00675000
   PFABORT     = %63,      << POWER FAIL ABORT STATUS RETURN >>         00680000
   QFUNC       = 6,        << IOQ FUNCTION INDEX >>                     00685000
   QMISC       = 3,        << IOQ ERROR WORD INDEX >>                   00690000
   QPAR1       = 8,        << IOQ PARAMETER INDEX >>                    00695000
   QPAR2       = 9,                                                     00700000
   QSTAT       = 10,       << STATUS RETURN WORD OF IOQ >>              00705000
   QWBCT       = 7,        << IOQ XFER CNT INDEX >>                     00710000
   RDYWAIT     = %30,      << NOT READY WAIT STATUS RETURN >>           00715000
   READCON     = 6,                                                     00720000
   READF       = 0,                                                     00725000
   RESETIF     = %100000,                                               00730000
   RESIDUE     = %010000,                                               00735000
   RETRY'      = 0,         << RETRY BIT OF QMISC >>                    00740000
   RETRYWAIT   = %20,      << RETRY WAIT STATUS RETURN >>               00745000
   RETRYSTAT   = %21,      << RETRY NECESSARY STATUS RETURN >>          00750000
   REWF        = 5,                                                     00755000
   REWINDC     = %10,                                                   00760000
   REWULDF     = 9,                                                     00765000
   REWUNLOAD   = %11,                                                   00770000
   RINGWAIT    = %40,      << NO WRITE RING WAIT RETURN STATUS >>       00775000
   SHORT'      = 5,       << SHORT READ BIT OF QMISC >>                 00780000
   SIOFAIL     = %44,      << SIO FAIL STATUS RETURN >>                 00785000
   SYSDB       = %1000,                                                 00790000
   SYSERROR    = %124,     << SYSTEM ERROR STATUS RETURN >>             00795000
   SYSLPDT     = %10,      << LPDT POINTER INDEX >>                     00800000
   SYSSBUF     = 6,        << SYS BUF TABLE POINTER INDEX >>            00805000
   TAPEERR     = %74,      << TAPE ERROR STATUS RETURN >>               00810000
   TAPEGAP     = 5,                                                     00815000
   TAPEMARK    = %15,                                                   00820000
   TAPERUN     = %103,     << TAPE RUNAWAY STATUS RETURN >>             00825000
   TIMINGERR   = %34,      << TIMING ERROR STATUS RETURN >>             00830000
   TGAP'       = 3,       << GAP SPACE RECOVERY BIT OF QMISC >>         00835000
   UNITFAIL    = %54,      << UNIT FAIL STATUS RETURN >>                00840000
   WAIT        = %10,      << WAIT FOR COMPLETION STATUS RETURN >>      00845000
   WRITEF      = 1,                                                     00850000
   WRITECON    = 4,                                                     00855000
   WRTEOT      = %113,     << REQUEST WRITE AFTER EOT STATUS RETURN >>  00860000
   WRTMKF      = 6,                                                     00865000
   XFERERR     = %14;      << TRANSFER ERROR STATUS RETURN >>           00870000
DEFINE                                                                  00875000
   ABS         = ABSOLUTE#,                                             00880000
   ASMB        = ASSEMBLE#,                                             00885000
   BACK        = (BACK':1)#,                                            00890000
   DUPLICATE   = ASSEMBLE(DUP)#,                                        00895000
   EOF         = (7:3)#,   << EOF FIELD OF LPDT >>                      00900000
   EOFB        = (EOFB':1)#,                                            00905000
   EOFBIT      = (11:1)#,  << EOF ENCOUNTERED BIT IN TAPE STATUS >>     00910000
   EOT         = (5:1)#,   << EOT BIT IN TAPE STATUS >>                 00915000
   EOTFLAG     = (13:1)#,  << READ PAST EOT BIT IN QPAR2 >>             00920000
   ERRCODE     = (12:3)#,  << ENCODED ERROR FIELD IN TAPE STATUS >>     00925000
   ERRCNT      = (12:4)#,  << RETRY COUNT FIELD OF QMISC  >>   <<02629>>00930000
   FORSP       = (FORSP':1)#,                                           00935000
   FUNC        = (8:8)#,   << FILE PROTECTED BIT OF TAPE STATUS  >>     00940000
   FILEPROTECT = (6:1)#,   << FILE PROTECTED TAPE STATUS BIT >>         00945000
   LDEV        = (8:8)#,   << LOGICAL DEVICE FIELD OF DIT >>            00950000
   LOADP       = (8:1)#,   << LOAD POINT BIT OF TAPE STATUS >>          00955000
   ODDBYTE     = (1:1)#,   << ODD BYTE XFER BIT OF TAPE STATUS >>       00960000
   PFAILB      = (11:1)#,  << POWER FAIL ABORT BIT OF QFLAGS >>         00965000
   READY       = (7:1)#,   << DRIVE READY BIT OF TAPE STATUS >>         00970000
   RETRY       = (RETRY':1)#,                                           00975000
   REWB4WRITE  = (14:1)#,  <<NEED REWIND TO ASSURE AT LOADP>>  <<00562>>00980000
   REWOUND     = (15:1)#,  <<DRIVE IS REWOUND>>                <<00562>>00985000
   SC          = (8:4)#,   << Space count field of QMISC  >>   <<02629>>00990000
   SFAIL       = (10:1)#,  << GIP FAILED TO START I/O >>                00995000
   SHORT       = (SHORT':1)#,                                           01000000
   STAT        = (8:8)#,   << STATUS FIELD OF QSTAT >>                  01005000
   SYSBUFR     = (3:1)#,   << SYSTEM BUFFER INDICATOR OF QFLAG >>       01010000
   TGAP        = (TGAP':1)#,                                            01015000
   WRTUNLD     = (6:1)#;   << UNLOAD TAPE FOR WRITE RING BIT QMISC >>   01020000
                                                                        01025000
                                                                        01030000
ARRAY INITIAL(0:55)=DB:=  <<INITIAL CONFIGURATION DATA>>       <<01338>>01035000
   %006001,               <<DIT SIZE=12,DVR TYPE=1>>           <<01338>>01040000
         0,                                                             01045000
   %026462,  << UNIT EXTRACT INSTRUCTION >>                             01050000
   [8/20,8/0],  << SIO PROG AREA SIZE(40 WORDS)/2 =  20>>      <<01300>>01055000
        0,    <<DFLAG>>                                        <<01338>>01060000
        0,    <<DLINK>>                                        <<01338>>01065000
        0,    <<DIOQP>>                                        <<01338>>01070000
        0,    <<DLDEV>>                                        <<01338>>01075000
        0,    <<DLTP>>                                         <<01338>>01080000
        0,    <<DILTP>>                                        <<01338>>01085000
        0,    <<DSTAT>>                                        <<01338>>01090000
        0,    <<DSERR>> <<INDEX & COUNT OF HARWARE STATUS>>    <<01338>>01095000
        0,    <<DTIME  TIMEOUT COMPLETED INDICATOR>>           <<01338>>01100000
        0,    <<DDFLAG - REWIND FLAG>>                         <<01338>>01105000
        0,    <<DTRLX - TIMEOUT DELAY>>                        <<01338>>01110000
        0,    <<DLOGERROR>>                                    <<01338>>01115000
   %014000,  << SIO PROG AREA - SET BANK >>                             01120000
         0,                                                             01125000
   %040000,  << CONTROL - UNIT SELECT >>                                01130000
         0,                                                             01135000
   %040000,  << CONTROL - OPERATION >>                                  01140000
         0,                                                             01145000
     34(0);  << REST OF I/O PROGRAM >>                                  01150000
$PAGE                                                                   01155000
PROCEDURE ABORTTIMEREQ(TRLX);                                           01160000
VALUE TRLX; INTEGER TRLX;                                               01165000
OPTION EXTERNAL;                                                        01170000
                                                                        01175000
PROCEDURE CHECKINDEX(INDEX,TABLE);                                      01180000
VALUE INDEX,TABLE;                                                      01185000
INTEGER INDEX;                                                          01190000
INTEGER POINTER TABLE;                                                  01195000
OPTION EXTERNAL;                                                        01200000
                                                                        01205000
                                                                        01210000
PROCEDURE EOFCHECK(IOQP,BUF,CNT,HCHK);                                  01215000
VALUE IOQP,BUF,CNT,HCHK;                                                01220000
POINTER IOQP;                                                           01225000
DOUBLE BUF;                                                             01230000
INTEGER CNT,HCHK;                                                       01235000
OPTION EXTERNAL;                                                        01240000
                                                                        01245000
                                                                        01250000
PROCEDURE GIP;                                                          01255000
OPTION EXTERNAL;                                                        01260000
                                                                        01265000
INTEGER PROCEDURE TIMEREQ(CODE,REQ,TIME);                               01270000
VALUE CODE,REQ,TIME;                                                    01275000
INTEGER CODE,REQ; DOUBLE TIME;                                          01280000
OPTION EXTERNAL;                                                        01285000
                                                                        01290000
PROCEDURE HELP;                                                         01295000
OPTION EXTERNAL;                                                        01300000
                                                                        01305000
                                                                        01310000
LOGICAL PROCEDURE IOMESSAGE(SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,   <<0U.EB>>01315000
   DEST,REPLY,OFFSET,DITP,IOTYPE);                             <<0U.EB>>01320000
VALUE SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,DEST,REPLY,OFFSET,DITP,  <<0U.EB>>01325000
   IOTYPE;                                                     <<0U.EB>>01330000
INTEGER SETNO,MSGNO,MASK,P1,P2,P3,P4,P5,DEST,REPLY,OFFSET,     <<0U.EB>>01335000
   IOTYPE;                                                     <<0U.EB>>01340000
INTEGER POINTER DITP;                                          <<0U.EB>>01345000
OPTION VARIABLE,EXTERNAL;                                      <<0U.EB>>01350000
                                                               <<0U.EB>>01355000
PROCEDURE LDEVNOTRDY(DITP);                                    <<0U.EB>>01360000
   VALUE DITP; POINTER DITP; OPTION EXTERNAL;                  <<0U.EB>>01365000
                                                                        01370000
                                                                        01375000
PROCEDURE MASTERCLEAR(DITP);                                            01380000
VALUE DITP;                                                             01385000
INTEGER POINTER DITP;                                                   01390000
OPTION EXTERNAL;                                                        01395000
                                                                        01400000
                                                                        01405000
PROCEDURE SIODM(A,B);                                                   01410000
VALUE A,B;                                                              01415000
INTEGER POINTER A;                                                      01420000
LOGICAL B;                                                              01425000
OPTION EXTERNAL;                                                        01430000
                                                                        01435000
                                                                        01440000
PROCEDURE STARTIO(A,B,C);                                               01445000
VALUE A,B,C;                                                            01450000
INTEGER POINTER A,B;                                                    01455000
LOGICAL C;                                                              01460000
OPTION EXTERNAL;                                                        01465000
$PAGE                                                                   01470000
INTEGER PROCEDURE MTAPEDVR(IOQP,DITP,BANK,BUFADR,SIOP,DRTN);            01475000
VALUE IOQP,DITP,BANK,BUFADR,SIOP,DRTN;                                  01480000
INTEGER BANK,BUFADR,DRTN;                                               01485000
INTEGER POINTER IOQP,DITP,SIOP;                                         01490000
OPTION PRIVILEGED,UNCALLABLE;                                           01495000
BEGIN                                                                   01500000
                                                                        01505000
                                                                        01510000
DOUBLE                                                                  01515000
   ABSADR      = BANK,                                                  01520000
   DXFERORDER  = BANK;                                                  01525000
DOUBLE POINTER                                                          01530000
   DSIOP       = SIOP,                                                  01535000
   LPDTD       = DB + SYSLPDT;                                          01540000
LOGICAL                                                                 01545000
   STATUS      = Q+2,                                                   01550000
   XFERORDER   = BANK;                                                  01555000
LOGICAL POINTER                                                         01560000
   DITPL       = DITP,                                                  01565000
   IOQPL       = IOQP;                                                  01570000
INTEGER                                                                 01575000
   FCODE       = Q+3,                                                   01580000
   I           = Q+1,                                                   01585000
   MSTATE      = MTAPEDVR,                                              01590000
   S0          = S-0,                                                   01595000
   S3          = S-3,                                                   01600000
   X           = X,                                                     01605000
   XD          = Q+4,                                                   01610000
   XFERCNT     = Q+5;                                                   01615000
INTEGER POINTER                                                         01620000
   SBUF        = DB + SYSSBUF;                                          01625000
                                                                        01630000
<<This subroutine returns a TRUE condition if the conditions >><<02680>>01635000
<<are such that a write after encountering EOT is NOT allowed>><<02680>>01640000
logical subroutine CHECK'WRITE'AFTER'EOT;                      <<02680>>01645000
begin                                                          <<02680>>01650000
                                                               <<02680>>01655000
if STATUS.EOT                   <<EOT has been passed on tape>><<02680>>01660000
   and not IOQPL(QPAR2).EOTFLAG <<wrt after EOT flag not set>> <<02680>>01665000
   and IOQP(QMISC) >= 0 then    <<not in RETRY mode>>          <<02680>>01670000
  CHECK'WRITE'AFTER'EOT := true;                               <<02680>>01675000
                                                               <<02680>>01680000
end;                                                           <<02680>>01685000
                                                                        01690000
   TOS := IOQP;                                                         01695000
   DEL;                                                                 01700000
   IF < THEN                                                            01705000
   BEGIN << I/O HAS BEEN ABORTED >>                                     01710000
      IF MSTATE = 3 THEN MASTERCLEAR(DITP); << STOP I/O IF MINE >>      01715000
      IF IOQPL.PFAILB THEN TOS := PFABORT ELSE TOS := ABORTIO;          01720000
      DITPL(DDFLAG).REWB4WRITE := FALSE; <<ABORT AUTO REWIND>> <<00668>>01725000
      GO TO BADEND;                                                     01730000
   END;                                                                 01735000
   TOS := 3; << SET I >>                                                01740000
   TOS := DITP(DSTAT); << SET STATUS >>                                 01745000
   TOS := IOQP(QFUNC).FUNC; << SET FCODE >>                             01750000
   TOS := 0;  << XD >>                                                  01755000
   TOS := IOQP(QWBCT);                                                  01760000
   IF < THEN TOS := -(TOS&ASR(1)); << SET XFERCNT >>                    01765000
                                                                        01770000
IF DITP(DTIME).(0:1)=1 THEN                                    <<00.05>>01775000
BEGIN      <<TIMEOUT HAS ELAPSED>>                             <<00.05>>01780000
    ABORTTIMEREQ(DITP(DTRLX));                                 <<00.05>>01785000
    IOQP(QMISC).WRTUNLD:=1;   <<UNLOAD TAPE FOR INSTALLING>>   <<00.05>>01790000
    DITP(DTIME):=0;                        <<WRITE RING>>      <<00.05>>01795000
    TOS:=REWUNLOAD;                                            <<00.05>>01800000
    GOTO CONTROLCONT;                                          <<00.05>>01805000
END;                                                           <<00.05>>01810000
   IF MSTATE = 2 THEN                                                   01815000
   BEGIN << START REQUEST - INITIATOR SECTION >>                        01820000
      IF FCODE > 12 THEN                                                01825000
      BEGIN << INVALID REQUEST >>                                       01830000
INVALIDFUNC:                                                            01835000
         TOS := INVFUNC;                                                01840000
         GO TO BADEND;                                                  01845000
      END;                                                              01850000
      X := FCODE; << SWITCH ON REQUEST CODE >>                          01855000
      ASSEMBLE(LOAD SWI,X; ADAX; BR SWI,X;                              01860000
SWI:                                                                    01865000
      CON READ;   CON WRITE;  CON OPEN;   CON FCLOSE; CON DCLOSE;       01870000
      CON REW;    CON WRTMK;  CON FSF;    CON BSF;    CON REWULD;       01875000
      CON GAP;    CON FSR;    CON BSR);                                 01880000
                                                                        01885000
   HELP;                                                                01890000
                                                                        01895000
READ:                                                                   01900000
      EOFCHECK(IOQP,0D,0,0); << CHECK FOR PRE READ EOF >>               01905000
      IF <> THEN                                                        01910000
      BEGIN << EOF FOUND >>                                             01915000
EOFOUT:                                                                 01920000
         MSTATE := 5;                                                   01925000
         RETURN;                                                        01930000
      END;                                                              01935000
      IF XFERCNT = 0 THEN GO FSRPEOF; << READ LENGTH OF ZERO >><<00.06>>01940000
      IF XFERCNT < 3 THEN                                               01945000
      BEGIN << SHORT READ FOR EOFCHECK >>                               01950000
         BANK := 0; << READ 3 WORDS INTO SIO PROG AREA FOR EOFCHECK >>  01955000
         BUFADR := @SIOP(20) + SYSDB;                                   01960000
         IOQP(QMISC).SHORT := 1;                                        01965000
         XFERCNT := 3;                                                  01970000
      END;                                                              01975000
      TOS := %170000; << CHAINED READ OF 4K >>                          01980000
      TOS := READCON;                                                   01985000
WRITECONT:                                                              01990000
      SIOP(5) := TOS; << SET XFER CONTROL ORDER >>                      01995000
      SIOP(1) := BANK; << SET BANK FOR XFER >>                          02000000
      IF IOQPL.SYSBUFR THEN                                             02005000
      BEGIN                                                             02010000
         TOS := TOS + %007600; << SET XFER ORDER TO 256 WORDS >>        02015000
         CHECKINDEX(@SBUF+SYSDB-BUFADR,SBUF);                           02020000
         IF XFERCNT > 1024 THEN GO TO INVALIDFUNC; << XFER TOO BIG >>   02025000
         TOS := 128;                                                    02030000
      END ELSE TOS := 4096;                                             02035000
      XD := TOS; << TRANSFER DELTA >>                                   02040000
      XFERORDER := TOS;                                                 02045000
      TOS := XFERCNT;                                                   02050000
      WHILE S0 > XD DO                                                  02055000
      BEGIN << BUILD CHAINED XFER ORDER >>                              02060000
         TOS := TOS - XD; << DECREMENT REMAINING COUNT >>               02065000
         DSIOP(I) := DXFERORDER;                                        02070000
         TOS := RESIDUE;                                                02075000
         TOS := -XD;                                                    02080000
         DSIOP(X:=X+1) := TOS; << RETURN RESIDUE ORDER >>               02085000
         I := X + 1;                                                    02090000
         IF IOQPL.SYSBUFR THEN                                          02095000
         BEGIN << ADVANCE THE BUFFER ADRESS >>                          02100000
            CHECKINDEX(ABS(BUFADR-1),SBUF);                             02105000
            BUFADR := ABS(X) + @SBUF + SYSDB;                           02110000
         END ELSE BUFADR := BUFADR + XD;                                02115000
      END;                                                              02120000
      ASMB(NEG,DUP; TRBC 3); << BUILD LAST XFER ORDER PAIR >>           02125000
      TOS := TOS LOR XFERORDER;                                         02130000
      ASMB(TRBC 0); << REMOVE DATA CHAINING BIT >>                      02135000
      TOS := BUFADR;                                                    02140000
      DSIOP(I) := TOS;                                                  02145000
      TOS := RESIDUE;                                                   02150000
      ASSEMBLE(XCH,INCX); << ADD RETURN RESIDUE ORDER >>                02155000
      DSIOP(X) := TOS;                                                  02160000
      I := X + 1;                                                       02165000
ENDIO:                                                                  02170000
      TOS := ENDINT;                                                    02175000
      TOS := -1;                                                        02180000
      DSIOP(I) := TOS;                                                  02185000
      TOS := DITPL(DLDEV) LAND %1400; << SET UNIT SELECT CONTROL >>     02190000
      SIOP(3) := TOS;                                                   02195000
      STARTIO(DITP,SIOP,TRUE);                                          02200000
      IF > THEN                                                         02205000
      BEGIN << SIO FAILURE >>                                           02210000
SIOFAILURE:                                                             02215000
         TOS := SIOFAIL;                                                02220000
         GO TO BADEND;                                                  02225000
      END;                                                              02230000
      DITPL(DDFLAG).REWOUND := FALSE;  <<RESET REWOUND>>       <<00562>>02235000
      MSTATE := %13; << SET COMPLETION WAIT >>                          02240000
      TOS := IOQP(QMISC);                                               02245000
      ASMB(TBC EOFB');                                                  02250000
      IF <> THEN RETURN;                                                02255000
      ASMB(TBC RETRY');                                                 02260000
      IF <> THEN  TOS := RETRYWAIT ELSE TOS := WAIT;                    02265000
      GO TO OUT;                                                        02270000
                                                                        02275000
WRITE:                                                                  02280000
      IF DITPL(DDFLAG).REWB4WRITE  THEN <<NEED BE AT LOADP>>   <<00562>>02285000
        IF STATUS.LOADP  <<THEN ALREADY AT LOAD POINT>>        <<00562>>02290000
           THEN DITPL(DDFLAG).REWB4WRITE := FALSE              <<00562>>02295000
           ELSE GO TO REW;  <<GO REWIND THE TAPE>>             <<00562>>02300000
      IF XFERCNT=0  THEN GO TO TESTWRITE;                      <<00668>>02305000
      <<see if write after EOT is allowed>>                    <<02680>>02310000
      if CHECK'WRITE'AFTER'EOT then                            <<02680>>02315000
      BEGIN << ATTEMPTED A WRITE AFTER EOT >>                           02320000
         TOS := WRTEOT;                                                 02325000
         GO TO BADEND;                                                  02330000
      END;                                                              02335000
      TOS := %160000; << CHAINED WRITE OF 4K >>                         02340000
      TOS := WRITECON;                                                  02345000
      GO TO WRITECONT;                                                  02350000
                                                                        02355000
REW:                                                                    02360000
      TOS := REWINDC;                                                   02365000
      IF DITPL(DDFLAG).REWOUND  AND  STATUS.LOADP              <<00562>>02370000
      THEN GO TO GOODEND;<<ALREADY REWOUND>>                   <<01.01>>02375000
CONTROLCONT:                                                            02380000
      SIOP(5) := TOS;                                                   02385000
      GO TO ENDIO;                                                      02390000
                                                                        02395000
WRTMK:                                                                  02400000
      IF DITPL(DDFLAG).REWB4WRITE  THEN <<NEED BE AT LOADP>>   <<00687>>02405000
        IF STATUS.LOADP  <<THEN ALREADY AT LOAD POINT>>        <<00687>>02410000
           THEN DITPL(DDFLAG).REWB4WRITE := FALSE              <<00687>>02415000
           ELSE GO TO REW;  <<GO REWIND THE TAPE>>             <<00687>>02420000
                                                               <<02680>>02425000
      <<see if write after EOT is allowed>>                    <<02680>>02430000
      if CHECK'WRITE'AFTER'EOT then                            <<02680>>02435000
        begin                                                  <<02680>>02440000
        tos := WRTEOT;                                         <<02680>>02445000
        go to BADEND;                                          <<02680>>02450000
        end;                                                   <<02680>>02455000
                                                               <<02680>>02460000
      TOS := TAPEMARK;                                                  02465000
      GO TO CONTROLCONT;                                                02470000
                                                                        02475000
FSF:                                                                    02480000
      TOS := FSFILE;                                                    02485000
      GO TO CONTROLCONT;                                                02490000
                                                                        02495000
BSF:                                                                    02500000
      TOS := BSFILE;                                                    02505000
CHKLOADP:                                                               02510000
      IF STATUS.LOADP THEN                                              02515000
      BEGIN                                                             02520000
         TOS := BOTBACK;                                                02525000
         GO TO BADEND;                                                  02530000
      END;                                                              02535000
      GO TO CONTROLCONT;                                                02540000
                                                                        02545000
DCLOSE:                                                                 02550000
      TOS := LPDTD(DITP(DLDEV).LDEV);                                   02555000
      TOS.EOF := 0; << RESET EOF FIELD IN LPDT >>                       02560000
      LPDTD(X) := TOS;                                                  02565000
                                                                        02570000
REWULD:                                                                 02575000
      TOS := REWUNLOAD;                                                 02580000
      IF DITPL(DDFLAG).REWOUND  AND  NOT STATUS.READY          <<00562>>02585000
         THEN GO TO GOODEND;                                   <<00562>>02590000
      GO TO CONTROLCONT;                                                02595000
GAP:                                                                    02600000
      IF DITPL(DDFLAG).REWB4WRITE  THEN <<NEED BE AT LOADP>>   <<00687>>02605000
        IF STATUS.LOADP  <<THEN ALREADY AT LOAD POINT>>        <<00687>>02610000
           THEN DITPL(DDFLAG).REWB4WRITE := FALSE              <<00687>>02615000
           ELSE GO TO REW;  <<GO REWIND THE TAPE>>             <<00687>>02620000
      TOS := TAPEGAP;                                                   02625000
      GO TO CONTROLCONT;                                                02630000
                                                                        02635000
FSR:                                                                    02640000
     EOFCHECK(IOQP,0D,0,0);                                    <<00.05>>02645000
     IF <> THEN GOTO EOFOUT;                                   <<00.05>>02650000
FSRPEOF:                                                       <<00.06>>02655000
      TOS := FSRECORD;                                                  02660000
      GO TO CONTROLCONT;                                                02665000
                                                                        02670000
BSR:                                                                    02675000
     EOFCHECK(IOQP,0D,0,0);                                    <<00.05>>02680000
     IF <> THEN GOTO EOFOUT;                                   <<00.05>>02685000
BSRPEOF:                                                       <<00.06>>02690000
      TOS := BSRECORD;                                                  02695000
      GO TO CHKLOADP;                                                   02700000
   END ELSE                                                             02705000
   BEGIN << CONTINUATOR SECTION >>                                      02710000
      IF IOQPL.SFAIL THEN GO TO SIOFAILURE;                             02715000
      TOS := IOQP(QMISC); << CHECK FOR RETRY CONDITION >>               02720000
      IF < THEN                                                         02725000
      BEGIN << ERROR RECOVERY IN PROGRESS >>                            02730000
         ASMB(TBC BACK');                                               02735000
         IF <> THEN                                                     02740000
         BEGIN << BACKSPACE RECORD COMPLETED >>                         02745000
            IF STATUS.ERRCODE <> NOERR THEN GO TO FAIL;                 02750000
            if FCODE = WRITEF or FCODE = WRTMKF then           <<02684>>02755000
            BEGIN << WRITE ORDER, SO GAP THE TAPE >>                    02760000
               TOS.BACK := 0;                                           02765000
               TOS.TGAP := 1;                                           02770000
               IOQP(X) := TOS;                                          02775000
               GO TO GAP;                                               02780000
            END;                                                        02785000
            IF STATUS.LOADP THEN GO TO ENDBACK;                         02790000
            tos := tos + %20; <<Inc bwd space cntr>>           <<02629>>02795000
            if S0.SC <> S0.ERRCNT then                         <<02629>>02800000
            BEGIN << BACKSPACE ANOTHER RECORD >>                        02805000
               IOQP(X) := TOS;                                          02810000
               GO BSRPEOF;                                     <<00.06>>02815000
            END;                                                        02820000
            <<perform # of fwd spaces 1 less than bckspcs>>    <<02679>>02825000
ENDBACK:                                                                02830000
            TOS.BACK := 0; << FINISHED BACKSPACE, NOW FORWARD >>        02835000
            TOS.FORSP := 1;                                             02840000
         END;                                                           02845000
         ASMB(TBC FORSP');                                              02850000
         IF <> THEN                                                     02855000
         BEGIN << COMPLETED A FORWARD SPACE RECORD >>                   02860000
            IF STATUS.ERRCODE <> NOERR THEN GO TO FAIL;                 02865000
           if S0.SC > 0 then                                   <<02685>>02870000
            tos := tos - %20;  <<Decrement fwd space ctr>>     <<02679>>02875000
            if S0.SC > 0 then  <<must still space fwd>>        <<02679>>02880000
            BEGIN << FORWARD SPACE ANOTHER RECORD >>                    02885000
               IOQP(X) := TOS;                                          02890000
               GO FSRPEOF;                                     <<00.06>>02895000
            END;                                                        02900000
            S0.SC := 0;     << Reset space count >>            <<02629>>02905000
            TOS.FORSP := 0; << DONE WITH FORWARD SPACE >>               02910000
            IOQP(X) := TOS; << GO READ THE RECORD AGAIN >>              02915000
            GO TO READ;                                                 02920000
         END;                                                           02925000
         TOS.TGAP := 0;                                                 02930000
         IF <> THEN                                                     02935000
         BEGIN << GAP IS COMPLETE, RETRY THE WRITE >>                   02940000
            IF STATUS.ERRCODE <> NOERR THEN GO TO FAIL;                 02945000
            IOQP(X) := TOS;                                             02950000
            if FCODE = WRITEF then                             <<02684>>02955000
               go to WRITE    <<write retry>>                  <<02684>>02960000
            else                                               <<02684>>02965000
               go to WRTMK;   <<write filemark retry>>         <<02684>>02970000
         END;                                                           02975000
      END;                                                              02980000
      ASMB(TBC EOFB');                                                  02985000
      IF <> THEN GO TO EOFOUT;<< BACKSPACE DUE TO DATA EOF, RETURN EOF>>02990000
      X := STATUS.ERRCODE;                                              02995000
      DEL; << SWITCH ON ERROR CONDITION >>                              03000000
      ASMB(LOAD SWC,X; ADAX; BR SWC,X;                                  03005000
SWC:                                                                    03010000
      CON UNITRDY;   CON TRANSFER;  CON REJECT;    CON RUNAWAY;         03015000
      CON TIMING;    CON TAPERROR;  CON RESERVE;   CON NOERROR);        03020000
                                                                        03025000
BADEND:                                                                 03030000
      IOQP(QWBCT) := 0; << ZERO XFER COUNT ON ERROR RETURNS >>          03035000
      DITP(DSERR):= [8/1,8/DLOGERROR];<< LOG COUNT & INDEX>>   <<01338>>03040000
      DITP(DLOGERROR):= STATUS;           <<LOG ERROR>>        <<01338>>03045000
      GO TO UNUSUALEND;                                                 03050000
                                                                        03055000
UNITRDY:                                                                03060000
RESERVE:                                                                03065000
FAIL:                                                                   03070000
      TOS := UNITFAIL;                                                  03075000
      GO TO BADEND;                                                     03080000
                                                                        03085000
RUNAWAY:                                                                03090000
      TOS := TAPERUN;                                                   03095000
      GO TO BADEND;                                                     03100000
                                                                        03105000
TRANSFER:                                                               03110000
      MASTERCLEAR(DITP); << RESET CONTROLLER ON XFER ERROR >>           03115000
      TOS := XFERERR;                                                   03120000
      GO TO SKIP;                                                       03125000
                                                                        03130000
TIMING:                                                                 03135000
      TOS := TIMINGERR;                                                 03140000
      GO TO SKIP;                                                       03145000
                                                                        03150000
TAPERROR:                                                               03155000
      TOS := TAPEERR;                                                   03160000
SKIP:                                                                   03165000
      DITP(DSERR):= [8/1,8/DLOGERROR];<< LOG COUNT & INDEX>>   <<01409>>03170000
      DITP(DLOGERROR):= STATUS;       <<SET ERROR STATUS>>     <<01409>>03175000
      IF (FCODE=WRITEF OR FCODE=WRTMKF OR FCODE=GAPF)          <<00847>>03180000
        AND STATUS.(10:1)=0    <<WRITE STATUS BIT>>            <<00847>>03185000
        THEN GO TO FAIL;  <<WRITE CURRENT DROPPED--UNIT FAIL>> <<00847>>03190000
      if IOQP(QMISC).ERRCNT = 15 then go to BADEND;            <<02629>>03195000
      TOS := IOQP(X) + 1; << INCREMENT RETRY COUNTER >>                 03200000
      TOS.RETRY := 1;                                                   03205000
      TOS.BACK := 1;                                                    03210000
      tos := tos land %177417; <<zero spacing cntr>>           <<02629>>03215000
      IOQP(X) := TOS;                                                   03220000
      if FCODE > WRITEF and FCODE <> WRTMKF then               <<02684>>03225000
        go to BADEND                                           <<02684>>03230000
      else                                                     <<02684>>03235000
        go to BSRPEOF;  <<attempt error recovery>>             <<02684>>03240000
                                                                        03245000
REJECT:                                                                 03250000
      IF FCODE = READF AND STATUS.READY THEN GO TO NOERROR;             03255000
      << SHORT READ CONDITION >>                                        03260000
TESTWRITE:                                                              03265000
      IF NOT STATUS.READY THEN                                          03270000
      BEGIN << DEVICE IS NOT READY >>                                   03275000
         LDEVNOTRDY(DITP);                                     <<0U.EB>>03280000
         IF = THEN                                             <<0U.EB>>03285000
         BEGIN                                                          03290000
            TOS := RDYWAIT;                                             03295000
RESTART:                                                                03300000
            MSTATE := 7;                                                03305000
            GO TO OUT;                                                  03310000
         END;                                                           03315000
SYSERR:                                                                 03320000
         TOS := SYSERROR;                                               03325000
         GO TO BADEND;                                                  03330000
      END;                                                              03335000
      IF FCODE = WRITEF OR FCODE = WRTMKF OR FCODE = GAPF THEN          03340000
      BEGIN << CHECK FOR FILE PROTECT ON WRITE >>                       03345000
         IF STATUS.FILEPROTECT THEN                                     03350000
         BEGIN << NO WRITE RING >>                                      03355000
            IF IOMESSAGE(1,NOWRITERING,%10000,DITP(DLDEV).     <<0U.EB>>03360000
               LDEV,,,,,CONSOLE) THEN                          <<0U.EB>>03365000
            BEGIN                                                       03370000
              DITP(DTIME):=0;                                  <<00.05>>03375000
              DITP(DTRLX):=TIMEREQ(%20,@DITP,1000D);           <<00.05>>03380000
              MSTATE:=%13;                                     <<00.05>>03385000
              RETURN;                                          <<00.05>>03390000
            END;                                                        03395000
            GO TO SYSERR;                                               03400000
         END;                                                           03405000
         IF MSTATE = 2 THEN GO TO GOODEND; << WRITE RING CHECK >>       03410000
         << FOR APPEND ACCESS FROM FILE SYS. - XFERCNT = 0 >>           03415000
      END;                                                              03420000
      GO TO FAIL;                                                       03425000
                                                                        03430000
NOERROR:                                                                03435000
      IOQP(QMISC).WRTUNLD := 0; << RESET UNLOAD BIT >>                  03440000
      IF <> THEN                                                        03445000
      BEGIN << NOW WAIT FOR WRITE RING MOUNT >>                         03450000
         DITPL(DDFLAG).REWB4WRITE := TRUE;  <<ASSURE AT LDPT>> <<00562>>03455000
         TOS := RINGWAIT;                                               03460000
         GO TO RESTART;                                                 03465000
         << THE FOLLOWING SEQUENCE OCCURS AFTER A NO-RING   >> <<00562>>03470000
         << CONDITION IS DETECTED:  FIRST, A DELAY IS       >> <<00562>>03475000
         << REQUESTED (FOR REASONS UNKNOWN).  THEN, AN      >> <<00562>>03480000
         << UNLOAD IS INITIATED, AND IOQP(QMISC).WRTUNLD    >> <<00562>>03485000
         << IS SET.  AFTER ERROR-FREE COMPLETION OF THE     >> <<00562>>03490000
         << UNLOAD, WRTUNLD IS RESET, AND                   >> <<00562>>03495000
         << DITPL(DDFLAG).REWB4WRITE IS SET.  THE LATTER    >> <<00562>>03500000
         << FLAG REQUESTS A REWIND BEFORE THE NEXT WRITE,   >> <<00562>>03505000
         << WHICH PREVENTS THE OPERATOR FROM PUTTING THE    >> <<00562>>03510000
         << TAPE ON-LINE PRIOR TO THE BOT MARKER.  AFTER    >> <<00562>>03515000
         << COMPLETION OF THE REWIND, THE ORIGINAL WRITE    >> <<00562>>03520000
         << IS REINITIATED.  IF THE TAPE IS NOT AT LOAD     >> <<00562>>03525000
         << POINT, THE REWIND-BEFORE-WRITE SEQUENCE WILL    >> <<00562>>03530000
         << OCCUR AGAIN.  IF THERE IS STILL NO WRITE RING   >> <<00562>>03535000
         << ON THE TAPE, THIS ENTIRE CYCLE REPEATS.         >> <<00562>>03540000
      END;                                                              03545000
      IF DITPL(DDFLAG).REWB4WRITE  THEN                        <<00562>>03550000
      BEGIN  <<TAPE PROBABLY AT LOADP--TRY TO WRITE>>          <<00562>>03555000
         MSTATE := 2;  <<STATE = WRITE INITIATOR>>             <<00562>>03560000
         GO TO WRITE;                                          <<00562>>03565000
      END;                                                     <<00562>>03570000
      IF STATUS.EOFBIT THEN                                             03575000
      BEGIN << SET EOF IN LPDT >>                                       03580000
         TOS := LPDTD(DITP(DLDEV).LDEV);                                03585000
         TOS.EOF := 1;                                                  03590000
         LPDTD(X) := TOS;                                               03595000
      END;                                                              03600000
      IF FCODE=FSRF OR FCODE=BSRF THEN                         <<00.05>>03605000
      BEGIN                                                    <<00.05>>03610000
         EOFCHECK(IOQP,ABSADR,0,0);                            <<00.05>>03615000
         IF <> THEN GOTO EOFOUT;                               <<00.05>>03620000
      END ELSE                                                 <<00.05>>03625000
      IF FCODE = REWF OR FCODE = REWULDF OR FCODE = DCLOSEF THEN        03630000
      BEGIN << TAKE CARE OF REWIND TERMINATION >>                       03635000
         DITPL(DDFLAG).REWOUND := TRUE;  <<SET REWOUND FLAG>>  <<00562>>03640000
         IF FCODE <> REWF OR STATUS.LOADP THEN GO TO GOODEND;           03645000
         MSTATE := 7; << RETURN STATE 7 SO THAT REWIND COMPLETION >>    03650000
         RETURN; << WILL NOT TRIGGER DEVREC ON JOB ACCEPT. UNITS >>     03655000
      END;                                                              03660000
      IF FCODE = READF AND XFERCNT <> 0 THEN                            03665000
      BEGIN                                                             03670000
         TOS := SIOP(9);                                                03675000
         WHILE SIOP(X:=X+1) <> ENDINT DO TOS := TOS + SIOP(X:=X+3);     03680000
         IF IOQPL(QMISC).SHORT THEN                                     03685000
         BEGIN << SHORT READ, CHECK INTERNAL BUFFER >>                  03690000
            TOS := TOS + 3; << ACTUAL AMOUNT READ >>                    03695000
            TOS := @IOQP;                                               03700000
            TOS := 0;                                                   03705000
            TOS := @SIOP(20) + SYSDB;                                   03710000
            TOS := S3;                                                  03715000
            EOFCHECK(*,*,*,0);                                          03720000
            IF > THEN GO TO EOFOUT;                                     03725000
            IF < THEN                                                   03730000
            BEGIN << BACKSPACE REQUIRED >>                              03735000
BACKSP:                                                                 03740000
               TOS := IOQP(QMISC);                                      03745000
               TOS.BACK := 1;                                           03750000
               TOS.EOFB := 1;                                           03755000
               IOQP(X) := TOS;                                          03760000
            GO BSRPEOF;                                        <<00.06>>03765000
            END;                                                        03770000
            TOS := ABSADR;                                              03775000
            TOS := SIOP(20);                                            03780000
            IF XFERCNT = 1 THEN ASMB(SSEA) ELSE                         03785000
            BEGIN << GIVE SECOND WORD >>                                03790000
               TOS := SIOP(21);                                         03795000
               ASMB(SDEA);                                              03800000
            END;                                                        03805000
            ASMB(DDEL,DUP);                                             03810000
            IF TOS < XFERCNT THEN XFERCNT := TOS ELSE DEL;              03815000
         END ELSE                                                       03820000
         BEGIN << NORMAL READ >>                                        03825000
            XFERCNT := TOS + XFERCNT; << ACTUAL AMOUNT READ >>          03830000
            EOFCHECK (IOQP,ABSADR,XFERCNT,0);                           03835000
            IF <> THEN                                                  03840000
            BEGIN << EOF FOUND >>                                       03845000
               IF < THEN TOS := TRUE ELSE TOS := FALSE;                 03850000
               << REMEMBER TO BACKSPACE OR NOT >>                       03855000
               X := XFERCNT;                                            03860000
               IF <> THEN                                               03865000
               BEGIN  << ZERO OUT THE USER BUFFER >>                    03870000
                  TOS := ABSADR;                                        03875000
                  TOS := 0;                                             03880000
                  ASMB(SSEA; INCA,DDUP; DECA); << SET MOVE ADR. >>      03885000
                  TOS := X - 1; << SET COUNT >= 127 >>                  03890000
                  TOS := 127;                                           03895000
                  ASMB(DDUP,CMP);                                       03900000
                  IF < THEN ASMB(XCH);                                  03905000
                  DELB;                                                 03910000
                  ASMB(MABS 5);                                         03915000
               END;                                                     03920000
               IF TOS THEN GO TO BACKSP ELSE GO TO EOFOUT;              03925000
            END;                                                        03930000
         END;                                                           03935000
         TOS := XFERCNT;                                                03940000
         TOS := IOQP(QWBCT);                                            03945000
         DEL;                                                           03950000
         IF < THEN                                                      03955000
         BEGIN << BYTE COUNT >>                                         03960000
            TOS := -(TOS&LSL(1));                                       03965000
            IF STATUS.ODDBYTE THEN TOS := TOS + 1;                      03970000
         END;                                                           03975000
         IOQP(X) := TOS; << SET RETURN COUNT >>                         03980000
      END ELSE                                                          03985000
      if STATUS.EOT then    <<we are past the tape EOT>>       <<02679>>03990000
      if FCODE=WRITEF or FCODE=WRTMKF then                     <<02679>>03995000
      BEGIN << SET EOT STATUS RETURN >>                                 04000000
         TOS := GOODEOT;                                                04005000
         GO TO UNUSUALEND;                                              04010000
      END;                                                              04015000
GOODEND:                                                                04020000
OPEN:                                                                   04025000
FCLOSE:                                                                 04030000
      TOS := IOQP(QMISC);                                               04035000
      IF < THEN TOS := GOODRETRY ELSE TOS := GOODSTAT;                  04040000
UNUSUALEND:                                                             04045000
      MSTATE := 5;                                                      04050000
OUT:                                                                    04055000
      IOQP(QSTAT).STAT := TOS;                                          04060000
   END;                                                                 04065000
END;                                                                    04070000
   ASSEMBLE(                                                            04075000
      PCAL SIODM; << MONITOR >>                                         04080000
      PCAL MTAPEDVR; << INITIATOR >>                                    04085000
      PCAL MTAPEDVR; << COMPLETOR >>                                    04090000
      CON 0; << I/O PROCESS PROCEDURE >>                                04095000
      CON 0; << INITIALIZATION PROCEDURE >>                             04100000
      CON 1; << # OF INTERRUPT HANDLERS >>                              04105000
      PCAL GIP); << INTERRUPT HANDLER >>                                04110000
END.                                                                    04115000
