<< LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION>>               00005000
$CONTROL MAP,CODE,USLINIT                                               00010000
<< MEASIO - MODULE 88 >>                                                00015000
<< HP32033C 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
$CONTROL  LIST, SEGMENT=MIO'SEGMENT                                     00055000
                                                                        00060000
                                                                        00065000
<<**********************************************************************00070000
                                                                        00075000
             Measurement I/O System                                     00080000
                                                                        00085000
                                                                        00090000
                                                                        00095000
Declaration:                                                            00100000
                                                                        00105000
   INTEGER PROCEDURE MEASIO(LDEV,FCODE,BANK,ADDR,COUNT);                00110000
      VALUE LDEV, FCODE, BANK, ADDR, COUNT;                             00115000
      INTEGER LDEV, FCODE, BANK, ADDR, COUNT;                           00120000
      OPTION PRIVILEGED, UNCALLABLE, EXTERNAL;                          00125000
                                                                        00130000
                                                                        00135000
Function:                                                               00140000
                                                                        00145000
   MEASIO is a self contained, core resident I/O system used by         00150000
   various performance measurement subsystems (Monitor, Sampler,        00155000
   Tracer, etc.) to write data to magnetic tape.  Generally speak-      00160000
   ing, it is independent of, and unknown to MPE in order to min-       00165000
   imize the effects of the measurement subsystems on the system's      00170000
   operation.                                                           00175000
                                                                        00180000
                                                                        00185000
Parameters:                                                             00190000
                                                                        00195000
   LDEV     The logical device number of the tape drive.                00200000
                                                                        00205000
   FCODE    The function to be performed:                               00210000
                                                                        00215000
            0 -- Read Status                                            00220000
            1 -- Write Data                                             00225000
            2 -- Write File Mark                                        00230000
            3 -- Rewind                                                 00235000
            4 -- Rewind/unload                                          00240000
                                                                        00245000
   BANK     The bank number of the data to be written.                  00250000
                                                                        00255000
   ADDR     The absolute address of the data to be written.             00260000
                                                                        00265000
   COUNT    The amount of data to be written:                           00270000
            >0 => Word count     <0 => Byte count                       00275000
            The maximum count allowed is 16383 words or 32766 bytes.    00280000
                                                                        00285000
                                                                        00290000
Condition Codes and Returned Values:                                    00295000
                                                                        00300000
   CCE      Condition code CCE indicates that the previous request      00305000
            (if any) has been completed successfully and the cur-       00310000
            rent request has been started.  The returned value will     00315000
            be zero for all functions except Read Status which will     00320000
            return the following information obtained from the hard-    00325000
            ware status word:                                           00330000
                                                                        00335000
             Bits     Meaning                                           00340000
                                                                        00345000
            (0:12) -- Not Used                                          00350000
            (12:1) -- End of Tape (EOT)                                 00355000
            (13:1) -- Write Protect                                     00360000
            (14:1) -- Ready (On Line)                                   00365000
            (15:1) -- Load Point (BOT)                                  00370000
                                                                        00375000
   CCG      Condition code CCG is identical to CCE except that it       00380000
            also indicates that the tape's EOT reflective spot has      00385000
            been passed.                                                00390000
                                                                        00395000
   CCL      Condition code CCL indicates that an error has occured.     00400000
            The returned value indicates the type of error:             00405000
                                                                        00410000
            1 -- LDEV is invalid or not enabled.                        00415000
            2 -- FCODE is invalid or COUNT is too large.                00420000
            3 -- An irrecoverable error has occured.                    00425000
            4 -- FCODE is something other than Read Status but the      00430000
                 tape drive is not ready.                               00435000
            5 -- FCODE is Write Data or Write File Mark but there       00440000
                 is no write ring.                                      00445000
                                                                        00450000
            Error codes 1 and 2 indicate an invalid parameter; the      00455000
            status of the previous request has not been checked         00460000
            and the current request is rejected.  Error code 3          00465000
            indicates that an irrecoverable error has occured on a      00470000
            previous request; the current request was not started.      00475000
            Once an irrecoverable error has occured, the only fun-      00480000
            tions that will be accepted are Read Status and Rewind      00485000
            unload.  A successful Rewind & Reset request will clear     00490000
            the irrecoverable error.  A new tape should be mounted      00495000
            and the drive made ready.  Error codes 4 and 5 indicate     00500000
            that the previous request has been completed successfully   00505000
            but the current request was not started.                    00510000
                                                                        00515000
                                                                        00520000
Comments:                                                               00525000
                                                                        00530000
   MEASIO must be called with DB set to SYSDB.                          00535000
                                                                        00540000
   For Write Data requests, it is the caller's responsibility to        00545000
   freeze the data.  The data must not be altered or unfrozen           00550000
   until a subsequent request indicates that the I/O has been           00555000
   completed successfully or an irrecoverable error has occured.        00560000
                                                                        00565000
   MEASIO requires the exclusive use of the specified tape drive        00570000
   and its controller.  In order to avoid conflicts with MPE, it        00575000
   must be enabled with a console command that puts all drives on       00580000
   the controller (including MEASIO's drive) in the DOWN state and      00585000
   properly initializes the DRT, DIT, and SIO Program area.  An-        00590000
   other console command is used to disable MEASIO and reset the        00595000
   tables for normal MPE operation.                                     00600000
                                                                        00605000
   Since Read Status requests require running an SIO program, they      00610000
   should not be issued capriciously.  In most applications, the        00615000
   status is only checked before the first I/O request and after        00620000
   a new tape is mounted.                                               00625000
                                                                        00630000
   For a variety of performance related reasons, it is preferable       00635000
   to call MEASIO with the interrupt system enabled.  It may, how-      00640000
   ever, be called with the interrupt system enabled or disabled.       00645000
   MEASIO will not enable the interrupt system if it was called         00650000
   while the system was disabled.                                       00655000
                                                                        00660000
NOTE:  If MEASIO is called from an interrupt processor, the inter-      00665000
   rupt system should be disabled.  Otherwise, MEASIO could loop,       00670000
   waiting for an interrupt, at a time when the interrupt priority      00675000
   poll prevents the tape controller from interrupting.                 00680000
                                                                        00685000
**********************************************************************>>00690000
$PAGE "     MEASUREMENT I/O SYSTEM -- OPERATION ON THE SERIES 33"       00695000
<<**********************************************************************00700000
                                                                        00705000
             Operation on the Series 33                                 00710000
                                                                        00715000
                                                                        00720000
                                                                        00725000
   MEASIO uses a portion of its tape drive's DIT and SIO Program        00730000
   area for global data; the words used, their significance, and        00735000
   their initial values are:                                            00740000
                                                                        00745000
   MIO'ENABLE  DIT(8)   A flag word containing "OK" (%47513) to         00750000
                        indicate that MEASIO is enabled for some        00755000
                        unit on this controller.                        00760000
                                                                        00765000
   MIO'STATE   DIT(9)   Current device state:                           00770000
                       -1 -- Irrecoverable Error                        00775000
                        0 -- No Activity                                00780000
                        1 -- I/O in Progress                            00785000
                        2 -- Backspace Record for Retry                 00790000
                        3 -- Tape Gap for Retry                         00795000
                        4 -- Wait for Rewind Completion                 00800000
                        Initialized to zero.                            00805000
                                                                        00810000
   MIO'RETRY   DIT(10)  Number of retries for this request.             00815000
                        Initialized to zero.                            00820000
                                                                        00825000
   MIO'LDEV    SIO(75).(0:4)  DOWNed unit flags.                        00830000
                      .(8:8)  The logical device number that            00835000
                              has been enabled for MEASIO.              00840000
                                                                        00845000
   MIO'UNIT    SIO(95)  The Unit Number + 1 of the MEASIO tape          00850000
                                                                        00855000
   MIO'STATUS  SIO(99)  Last known hardware status.                     00860000
                        Initialized to zero.                            00865000
                                                                        00870000
   MIO'FCODE   SIO(101) /                                               00875000
                        |                                               00880000
   MIO'BANK    SIO(102) |  Saved parameters for retry.                  00885000
                        |                                               00890000
   MIO'ADDR    SIO(103) |  Uninitialized.                               00895000
                        |                                               00900000
   MIO'COUNT   SIO(104) \                                               00905000
                                                                        00910000
                                                                        00915000
   In addition to MEASIO, the measurement I/O system includes five      00920000
   supporting procedures:                                               00925000
                                                                        00930000
   MIO'INITIATOR -- This procedure builds and starts the necessary      00935000
                    SIO programs and updates MIO'STATE.                 00940000
                                                                        00945000
   MIO'COMPLETOR -- This procedure checks the I/O completion status     00950000
                    and updates MIO'STATE.  If necessary, it calls      00955000
                    MIO'INITIATOR to start a retry.                     00960000
                                                                        00965000
   MIO'INTRPT'PROC -- This is the interrupt processor.  When an in-     00970000
                      terrupt is received from the MEASIO tape con-     00975000
                      troller, it saves the hardware status and         00980000
                      calls MIO'COMPLETOR.                              00985000
                                                                        00990000
   MIO'INIT -- This procedure initializes the DRT, DIT, and SIO         00995000
               program area as required by the 3000 Series 33           01000000
               Measurement I/O system.  This procedure also halts the   01005000
               mag tape's Idle Channel Program.                         01010000
                                                                        01015000
   MIO'RESET -- This procedure resets the DRT, DIT, and SIO program     01020000
                area for normal use by the Series 33 I/O system and     01025000
                it starts an Idle Channel Program for the mag tape      01030000
                driver.                                                 01035000
                                                                        01040000
                                                                        01045000
   Each time MEASIO is called, it verifies that the logical device      01050000
   is valid and enabled and that the function is valid.  It then        01055000
   checks the previous request and waits for completion.  If MEASIO     01060000
   was called with the interrupt system enabled, the wait loop is       01065000
   simply a test of MIO'STATE; otherwise, the wait loop checks the      01070000
   DRT to test for SIO Ready, followed by a call to MIO'COMPLETOR.      01075000
                                                                        01080000
   After waiting for the completion of any previous request, MEASIO     01085000
   disables the interrupt system in order to prevent any recursive      01090000
   calls while the current request is being processed.  If the cur-     01095000
   rent request is Read Status, the hardware status is read and re-     01100000
   turned to the caller.  Otherwise, the previous request is check-     01105000
   ed for an irrecoverable error.  If there has been no error,          01110000
   MEASIO verifies the unit ready and write enable status and calls     01115000
   MIO'INITIATOR to start the current request.                          01120000
                                                                        01125000
                                                                        01130000
7970E HP-IB Mag Tape Controller Status                                  01135000
                                                                        01140000
  Bits       Meaning                                                    01145000
                                                                        01150000
    0    End of File                                                    01155000
                                                                        01160000
    1    Beginning of Tape                                              01165000
    2    End of Tape                                                    01170000
    3    Single Track Error                                             01175000
                                                                        01180000
    4    Command Reject                                                 01185000
    5    File Protect                                                   01190000
    6    Multiple Track Error                                           01195000
                                                                        01200000
    7    Unit Online                                                    01205000
    8    (not used)                                                     01210000
    9    Unit number (MSB)                                              01215000
                                                                        01220000
   10    Unit number (LSB)                                              01225000
   11    Timing Error                                                   01230000
   12    Tape Error                                                     01235000
                                                                        01240000
   13    Rewinding                                                      01245000
   14    Unit Busy                                                      01250000
   15    Interface Busy                                                 01255000
                                                                        01260000
**********************************************************************>>01265000
$PAGE "     MEASUREMENT I/O SYSTEM -- CHANNEL PROGRAM"                  01270000
<<*************************************************************<<04118>>01275000
*                                                             *<<04118>>01280000
*                                                             *<<04118>>01285000
***************************************************************<<04118>>01290000
<<                                                                      01295000
                 7970E HP-IB Channel Program                            01300000
                                                                        01305000
The following is a listing of the 3000 Series 33 Mag Tape Driver        01310000
Channel Program for the 7970E HP-IB Magnetic Tape.  If any changes      01315000
are made to the mag tape driver's channel program, appropriate          01320000
changes must be made to the MEASIO procedures.  The comments shown      01325000
are for the MEASIO usage of the Channel Program.                        01330000
                                                                        01335000
                                                                        01340000
( 0)  WRITE COMMAND     %2001,   Select Unit Command                    01345000
( 1)                        1,                                          01350000
( 2)                        0,                                          01355000
( 3)                   %42000,                                          01360000
( 4)                        0,                                          01365000
                                                                        01370000
( 5)  WAIT              %1000,   Wait for Command Completion            01375000
( 6)                        0,                                          01380000
                                                                        01385000
( 7)  DSJ               %2401,   Check Mag Tape's Condition             01390000
( 8)                        0,                                          01395000
( 9)  DSJ'CMDJMP            0,   JMP*+0/50, MIN CMD/RD XFER CNT         01400000
(10)                       43,   JMP *+43, Read Status                  01405000
                                                                        01410000
(11)  WRITE COMMAND     %2001,   Issue Motion Command                   01415000
(12)                        1,                                          01420000
(13)                        0,                                          01425000
(14)                   %42000,                                          01430000
(15)                        0,                                          01435000
                                                                        01440000
(16)  WAIT              %1000,   Wait for Command Completion            01445000
(17)                        0,                                          01450000
                                                                        01455000
(18)  DSJ               %2401,   Check Mag Tape's Condition             01460000
(19)                        0,                                          01465000
(20)                        0,   JMP*+0/25, RD/WRT DATA BYPASS          01470000
(21)                       32,   JMP *+32, Read Status                  01475000
                                                                        01480000
(22)  READ/WRITE DATA     %20,   Read/Write Record Command              01485000
(23)  BYTECNT               0,                                          01490000
(24)  TDBL              %2000,   TERMINATION DISP. *+4                  01495000
(25)  MEMX            %000000,   RECORD MODE                            01500000
(26)  BADDR                 0,                                          01505000
(27)  JUMP                  0,   EOI RECEIVED - XFER COMPLETED          01510000
(28)  EOI'JMP               2,     JMP *+2/12, READ/WRITE COMPLETION    01515000
(29)  JMP                   0,   Burst Completion Exit                  01520000
(30)                      -15,     JMP *-15 TO WAIT INSTRUCTION         01525000
(31)  WRITE END         %2007,   ISSUE STOP POLLING FOR DATA            01530000
                                                                        01535000
(32)                        1,                                          01540000
(33)                        0,                                          01545000
                                                                        01550000
(34)                   %42000,                                          01555000
(35)                        0,                                          01560000
                                                                        01565000
(36)  READ COUNT        %1402,   READ TRANSFER COUNT TO                 01570000
(37)                        2,   PROVIDED DELAY NEEDED                  01575000
(38)                        0,   FOR READS - KLUDGE                     01580000
(39)                    %2000,                                          01585000
(40)                        0,                                          01590000
                                                                        01595000
(41)  WAIT              %1000,   WAIT FOR OPERATION COMPLETION          01600000
(42)                        0,                                          01605000
(43)  DSJ               %2401,   CHECK MAG TAPE'S CONDITION             01610000
(44)                        0,                                          01615000
(45)                        0,   JMP *+0, UNIT OK                       01620000
                                                                        01625000
(46)                        7,   JMP *+7, READ STATUS                   01630000
(47)  READ STATUS       %1401,   READ STATUS BYTE                       01635000
                                                                        01640000
(48)                        3,                                          01645000
(49)                        0,                                          01650000
(50)                    %2000,                                          01655000
(51)                        0,                                          01660000
                                                                        01665000
(52)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =0            01670000
(53)                        0,   STATUS CHECK NOT REQUIRED              01675000
(54)  READ STATUS       %1401,   READ STATUS BYTES                      01680000
(55)                        3,                                          01685000
(56)                        0,                                          01690000
                                                                        01695000
(57)                    %2000,                                          01700000
(58)                        0,                                          01705000
                                                                        01710000
(59)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =1            01715000
(60)                        1,   STATUS CHECK REQUIRED                  01720000
(61)  READ COUNT        %1402,   READ TRANSFER COUNT                    01725000
(62)                        2,                                          01730000
(63)                        0,                                          01735000
                                                                        01740000
(64)  MEMX'RC           %2000,                                          01745000
(65)                        0,                                          01750000
                                                                        01755000
(66)  JMP                   0,   JUMP BACK TO DSJ INSTRUCTION           01760000
(67)                      -25,                                          01765000
(68)  WRITE END         %2007,   ISSUE END COMMAND                      01770000
(69)                        1,   IDLE CHANNEL PROGRAM                   01775000
(70)                        0,                                          01780000
                                                                        01785000
(71)                   %42000,                                          01790000
(72)                        0,                                          01795000
                                                                        01800000
                                                                        01805000
                                                                        01810000
(73)  WAIT              %1000,   WAIT FOR MT TO POLL                    01815000
(74)                        0,                                          01820000
(75)  DSJ               %2400,   CLEAR ANY PENDING DSJ'S                01825000
(76)                        0,                                          01830000
(77)                        0,                                          01835000
                                                                        01840000
(78)  READ STATUS       %1401,   READ STATUS TO ILT                     01845000
(79)                        3,                                          01850000
                                                                        01855000
(80)                        0,                                          01860000
(81)                    %2000,                                          01865000
(82)                        0,                                          01870000
                                                                        01875000
(83)  INT/HLT            %601,   INTERUPT/HALT, HALT CODE =0            01880000
(84)                        0,                                          01885000
(85)  WRITE END         %2007,   ISSUE END COMMAND                      01890000
(86)                        1,                                          01895000
(87)                        0,                                          01900000
                                                                        01905000
(88)                   %42000,                                          01910000
(89)                        0,                                          01915000
                                                                        01920000
                                                                        01925000
(90)  DSJ               %2400,   CLEAR ANY PENDING DSJ'S                01930000
(91)                        0,                                          01935000
(92)                        0,                                          01940000
(93)  INT/HLT            %601,                                          01945000
(94)                        0,                                          01950000
(95)  STORAGE(SCLTUNIT)     0,   SELECT COMMAND UNIT NUMBER             01955000
(96)  CMDWORD               0,   MOTION COMMAND WORD                    01960000
(97)                      %23,   STOP POLLING FOR DATA COMMAND          01965000
(98)                      %25,   END COMMAND                            01970000
(99)                        0,   STATUS BUFFER AREA                     01975000
(100)                       0,                                          01980000
(101)                       0,   6 BYTE SHORT READ BUFFER               01985000
(102)                       0,                                          01990000
(103)                       0,                                          01995000
(104)                       0,   DUMMY BUFFER                           02000000
(105)                     %63;   ABORT END COMMAND                      02005000
                                                                        02010000
***************************************************************<<04118>>02015000
*************************************************************>><<04118>>02020000
$PAGE "     MEASUREMENT I/O SYSTEM -- MEASIO"                           02025000
BEGIN                                                                   02030000
    << MEASIO GLOBAL EQUATES AND DEFINES >>                             02035000
                                                                        02040000
EQUATE                                                                  02045000
  CCG         =     0,  << GREATER THAN CONDITION CODE >>               02050000
  CCL         =     1,  << LESS THAN CODITION CODE >>                   02055000
  CCE         =     2,  << EQUALS CONDITION CODE >>                     02060000
  CMDWORD     =    96,   << SIOP, MOTION COMMAND WORD >>       <<04118>>02065000
  DILTP       =     5,  << DIT, INTERRUPT LINKAGE TABLE POINTER >>      02070000
  DLDEV       =    10,   <<DIT,CONTAINS CONTROLLER UNIT NUMBER>><<MPEV>>02075000
  DRTSIZE     =     4,  << LENGTH OF DRT ENTRY >>                       02080000
  DSJ'CMDJMP  =     9,  << SIO, COMMAND SWITCH >>                       02085000
  DSJ'RWJMP   =    20,  << SIO, WRITE DATA BYPASS SWITCH >>             02090000
  ICNTRL      =     7,  << ILT, CONTAINS DRT NUMBER IN BITS 8:8 >>      02095000
  IDITP0      =    14,  << ILT, POINTER TO DIT 0 >>                     02100000
  IFLAG       =    13,  << ILT, FLAG WORD >>                            02105000
  ISIOP       =     8,  << ILT, CHANNEL PROGRAM AREA POINTER >>         02110000
  LR          =    17,   << STORAGE FOR INTERRUPT INTERVAL >>  <<01185>>02115000
  SYSDB       = %1000,  << LOCATION OF SYSDB >>                         02120000
ENDEQ         =     0;                                                  02125000
                                                                        02130000
  EQUATE   LPDT'ENT'SIZE = 4 ,                                  <<MPEV>>02135000
           DIT'OFFSET    = 2 ;                                  <<MPEV>>02140000
                                                                        02145000
DEFINE                                                                  02150000
  ASMB        = ASSEMBLE#,                                              02155000
  DISABLE     = ASMB(SED 1)#,                                           02160000
  IDRTN       = ( 7:9)#,   << 9 BIT DRT NUMBER IN ILT >>       <<04850>>02165000
  ENABLE      = ASMB(SED 0)#,                                           02170000
  SIOPG       = CON %20302;CON 0#,                                      02175000
  CC          = STATUS.(6:2)#,                                 <<01185>>02180000
  IGNOREHI    = ( 2:1)#,   << ILT, IGNORE INTERRUPT FLAG >>             02185000
  EOT         = ( 2:1)#,   << END OF TAPE STATUS BIT >>                 02190000
  FILEPRTCT   = ( 5:1)#,   << FILE PROTECT STATUS BIT >>                02195000
  LDPOINT     = ( 1:1)#,   << LOAD POINT STATUS BIT >>                  02200000
  ONLINE      = ( 7:1)#,   << ONLINE STATUS BIT >>                      02205000
  UNIT'FIELD  = ( 8:8)#,   << UNIT FIELD IN DIT >>              <<MPEV>>02210000
  LMIO'STATUS = LOGICAL(SIOP(99))#,                            <<04118>>02215000
  MIO'ADDR    = SIOP(103)#,<< STORAGE OF USER BUFFER ADDRESS >><<04118>>02220000
  MIO'BANK    = SIOP(102)#,<< STORAGE OF USER BANK ADDRESS >>  <<04118>>02225000
  MIO'COUNT   = SIOP(104)#,<< STORAGE OF BUFFER LENGTH >>      <<04118>>02230000
  MIO'ENABLE  = DITP(8)#,  << MEASIO FLAG WORD >>                       02235000
  MIO'FCODE   = SIOP(101)#,<< FUNCTION REQUEST CODE >>         <<04118>>02240000
  MIO'LDEV    = SIOP(65)#, << LOGICAL DEVICE NUMBER >>         <<04118>>02245000
  MIO'RETRY   = DITP(10)#, << RETRY COUNTER >>                          02250000
  MIO'STATE   = DITP(9)#,  << CURRENT PROCESS STATE >>                  02255000
  MIO'STATUS  = SIOP(99)#, << CURRENT MAG TAPE STATUS >>       <<04118>>02260000
  MIO'UNIT    = SIOP(95)#, << MAG TAPE UNIT NUMBER PLUS ONE >> <<04118>>02265000
  ABS         = ABSOLUTE#,                                     <<01185>>02270000
  TRAPOFF     = PUSH(STATUS);                                  <<01185>>02275000
                TOS.(2:1) := 0;                                <<01185>>02280000
                SET(STATUS)#,                                  <<01185>>02285000
  PDISABLE    = ASMB(PSDB)#,                                   <<01185>>02290000
  PENABLE     = ASMB(PSEB)#,                                   <<01185>>02295000
  WAITPROG    = ( 1:1)#,   << WAIT PGM RUNNING FLAG IN ILT >>  <<04850>>02300000
ENDDEF        = 0#;                                                     02305000
                                                                        02310000
  INTEGER STATUS=Q-1, S0=S-0, X=X;                             <<01185>>02315000
  INTEGER POINTER CSTI=1, DSTI=2, LPDT=DB+%10;                 <<01185>>02320000
$PAGE                                                                   02325000
     << PROCEDURE DECLARATIONS >>                                       02330000
                                                               <<04850>>02335000
PROCEDURE AWAKEIO(DITP,FLAGS);                                 <<04850>>02340000
  VALUE FLAGS;                                                 <<04850>>02345000
  ARRAY DITP;                                                  <<04850>>02350000
  LOGICAL FLAGS;                                               <<04850>>02355000
  OPTION EXTERNAL;                                             <<04850>>02360000
                                                                        02365000
                                                               <<04850>>02370000
INTEGER PROCEDURE GETDRT(DRTN,OFFSET);                         <<04850>>02375000
  VALUE DRTN,OFFSET;                                           <<04850>>02380000
  INTEGER DRTN,OFFSET;                                         <<04850>>02385000
  OPTION EXTERNAL;                                             <<04850>>02390000
                                                                        02395000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCODE,BANK,ADDR,COUNT);           02400000
  VALUE  DRT, DITP, SIOP, FCODE, BANK, ADDR, COUNT;                     02405000
  INTEGER  DRT, FCODE, BANK, ADDR, COUNT;                               02410000
  INTEGER POINTER  DITP, SIOP;                                          02415000
  OPTION  FORWARD;                                                      02420000
                                                                        02425000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 02430000
  VALUE  DRT, DITP, SIOP;                                               02435000
  INTEGER  DRT;                                                         02440000
  INTEGER POINTER  DITP, SIOP;                                          02445000
  OPTION  FORWARD;                                                      02450000
                                                                        02455000
PROCEDURE MIO'INTRPT'PROC;                                              02460000
  OPTION  FORWARD;                                                      02465000
                                                                        02470000
PROCEDURE MIO'INIT(LDEV);                                               02475000
  VALUE  LDEV;                                                          02480000
  INTEGER  LDEV;                                                        02485000
  OPTION  FORWARD;                                                      02490000
                                                                        02495000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      02500000
  VALUE  LDEV;                                                          02505000
  INTEGER  LDEV;                                                        02510000
  OPTION  FORWARD;                                                      02515000
                                                                        02520000
PROCEDURE GIP'HPIB;                                            <<01301>>02525000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             02530000
                                                                        02535000
PROCEDURE IOFAILURE(DRT,DITP);                                          02540000
  VALUE  DRT, DITP;                                                     02545000
  INTEGER  DRT;                                                         02550000
  INTEGER POINTER  DITP;                                                02555000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             02560000
                                                                        02565000
PROCEDURE PUTDRT(DRTN,OFFSET,DTA);                             <<04850>>02570000
  VALUE DRTN,OFFSET,DTA;                                       <<04850>>02575000
  INTEGER DRTN,OFFSET;                                         <<04850>>02580000
  LOGICAL DTA;                                                 <<04850>>02585000
  OPTION EXTERNAL;                                             <<04850>>02590000
                                                               <<04850>>02595000
PROCEDURE START'HPIB(DITP,SIOP,QFLAG);                         <<01301>>02600000
  VALUE  DITP, SIOP, QFLAG;                                             02605000
  LOGICAL  QFLAG;                                                       02610000
  INTEGER POINTER  DITP, SIOP;                                          02615000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             02620000
                                                                        02625000
PROCEDURE HALT'HPIB(DITP);                                     <<01301>>02630000
  VALUE  DITP;                                                          02635000
  INTEGER POINTER  DITP;                                                02640000
  OPTION  PRIVILEGED, UNCALLABLE, EXTERNAL;                             02645000
                                                               <<04850>>02650000
PROCEDURE WIOC'HPIB(CMD,CHANNEL,DEVICE);                       <<04850>>02655000
VALUE CMD,CHANNEL,DEVICE;                                      <<04850>>02660000
INTEGER CMD,CHANNEL,DEVICE;                                    <<04850>>02665000
OPTION EXTERNAL;                                               <<04850>>02670000
$PAGE                                                          <<04850>>02675000
<< This procedure gets DRT into a known state >>               <<04850>>02680000
procedure QUIESCE'DRT(DRT);                                    <<04850>>02685000
value DRT;                                                     <<04850>>02690000
integer DRT;                                                   <<04850>>02695000
option internal,privileged;                                    <<04850>>02700000
begin                                                          <<04850>>02705000
                                                               <<04850>>02710000
DISABLE;                                                       <<04850>>02715000
<< First, kill the channel program (if any) >>                 <<04850>>02720000
tos := DRT;                                                    <<04850>>02725000
assemble(con %20302;con %1);  << HIOP instruction >>           <<04850>>02730000
                                                               <<04850>>02735000
<< Loop until it actually stops >>                             <<04850>>02740000
Loop:                                                          <<04850>>02745000
                                                               <<04850>>02750000
if GETDRT(DRT,3) <> 0 then                                     <<04850>>02755000
  go to Loop;                                                  <<04850>>02760000
                                                               <<04850>>02765000
<< Clear any pending interrupts on device >>                   <<04850>>02770000
tos := %006000;   << Write register "C" on GIC >>              <<04850>>02775000
tos := DRT;                                                    <<04850>>02780000
tos := logical(DRT) land %7;  << Device number >>              <<04850>>02785000
WIOC'HPIB(*,*,*);   << issue command >>                        <<04850>>02790000
                                                               <<04850>>02795000
end;                                                           <<04850>>02800000
$PAGE                                                                   02805000
INTEGER PROCEDURE MEASIO(LDEV,FCODE,BANK,ADDR,COUNT);                   02810000
  VALUE  LDEV, FCODE, BANK, ADDR, COUNT;                                02815000
  INTEGER  LDEV, FCODE, BANK, ADDR, COUNT;                              02820000
  OPTION  PRIVILEGED, UNCALLABLE;                                       02825000
BEGIN                                                                   02830000
                                                                        02835000
  INTEGER  RTNSTAT=Q-1;                                                 02840000
  INTEGER CPU'NUMBER, DRT, S0=S-0;                             <<04850>>02845000
  DOUBLE COUNTER,OLDDB;                                        <<04850>>02850000
  INTEGER POINTER  DITP, SIOP, ILTP;                                    02855000
  DEFINE  INTRPTS'ENABLED = LOGICAL(TOS.(1:1))#;                        02860000
  EQUATE  MAXCOUNT = 32766;                                             02865000
                                                                        02870000
                                                                        02875000
                                                                        02880000
  SUBROUTINE WAIT'FOR'IO;                                               02885000
    BEGIN                                                               02890000
      WHILE MIO'STATE>0 DO                                              02895000
        BEGIN                                                           02900000
          PUSH(STATUS);                                                 02905000
          IF INTRPTS'ENABLED THEN   << SIT TIGHT >>                     02910000
          ELSE                                                          02915000
            BEGIN                                                       02920000
                                                               <<04850>>02925000
              TOS := GETDRT(DRT,3);  << GET 4TH WORD OF DRT >> <<04850>>02930000
                                                               <<04850>>02935000
              IF TOS.(0:2)=0 THEN   << I/O PROGRAM COMPLETED >>         02940000
                MIO'COMPLETOR(DRT,DITP,SIOP);  << CALL COMPLETOR >>     02945000
            END;                                                        02950000
        END;                                                            02955000
    END;                                                                02960000
                                                                        02965000
                                                                        02970000
                                                                        02975000
     << PROCEDURE ENTRY POINT >>                                        02980000
                                                               <<04850>>02985000
  << SET DB TO SYSDB >>                                        <<04850>>02990000
  PDISABLE;                                                    <<04850>>02995000
  TOS := 0;                                                    <<04850>>03000000
  TOS := SYSDB;                                                <<04850>>03005000
  ASMB(XCHD);                                                  <<04850>>03010000
  OLDDB := TOS;                                                <<04850>>03015000
                                                                        03020000
  IF NOT (1 <= LDEV <= LPDT(0)) THEN    << BAD LDEV >>          <<MPEV>>03025000
BAD'LDEV:                                                               03030000
    BEGIN                                                               03035000
      MEASIO := 1;   << RETURN INVALID LDEV INDICATOR >>                03040000
BAD'EXIT:                                                               03045000
      TOS := OLDDB;                                            <<04850>>03050000
      ASMB(XCHD);                                              <<04850>>03055000
      PENABLE;                                                 <<04850>>03060000
      CC := CCL;    << SET RETURN CONDITION CODE TO FAILURE >> <<01185>>03065000
      RETURN;                                                           03070000
    END;                                                                03075000
                                                                        03080000
  @DITP := LPDT (( LDEV*LPDT'ENT'SIZE)+DIT'OFFSET);<<DIT PTR>>  <<MPEV>>03085000
  IF < THEN GOTO BAD'LDEV;                                              03090000
                                                                        03095000
  @ILTP := DITP(DILTP);    << SETUP ILT POINTER >>                      03100000
  @SIOP := ILTP(ISIOP);    << SETUP SIO POINTER >>                      03105000
                                                                        03110000
  IF MIO'ENABLE <> "OK" OR    << CHECK FOR MEASIO ENABLED >>            03115000
    LDEV <> MIO'LDEV.(8:8) THEN GOTO BAD'LDEV;                          03120000
                                                                        03125000
  IF NOT (0 <= FCODE <= 4) THEN   << BAD FUNCTION CODE >>               03130000
    BEGIN                                                               03135000
      MEASIO := 2;   << RETURN BAD FUNCTION CODE INDICATOR>>            03140000
      GOTO BAD'EXIT;                                                    03145000
    END;                                                                03150000
                                                                        03155000
  DRT := ILTP(ICNTRL).IDRTN;  << EXTRACT DRT NUMBER FROM ILT >><<04850>>03160000
                                                                        03165000
  WAIT'FOR'IO;       << COMPLETE PREVIOUS I/O >>                        03170000
                                                                        03175000
  DISABLE;                                                              03180000
                                                                        03185000
  IF FCODE=0 OR MIO'STATUS=0 THEN  << GET UNIT'S STATUS >>              03190000
    BEGIN                                                               03195000
      ILTP(IFLAG).IGNOREHI := 1;  << SET IGNORE INTERRUPT FLAG >>       03200000
      SIOP(DSJ'CMDJMP) := 36;     << SET UP CMD JMP SWITCH >>  <<04118>>03205000
      << GET CPU NUMBER >>                                     <<04850>>03210000
      ASSEMBLE(PCN);                                           <<04850>>03215000
      CPU'NUMBER := TOS;   << SAVE CPU NUMBER >>               <<04850>>03220000
                                                               <<04850>>03225000
      << FIGURE DELAY ACCORDING TO CPU TYPE >>                 <<04850>>03230000
      IF CPU'NUMBER = 4 THEN                                   <<04850>>03235000
        TOS := 256000D         << Series/64 >>                 <<04850>>03240000
      ELSE IF CPU'NUMBER = 3 THEN                              <<04850>>03245000
        TOS := 128000D         << Series/44 >>                 <<04850>>03250000
      ELSE TOS := 32000D;      << Series/33 >>                 <<04850>>03255000
                                                               <<04850>>03260000
      COUNTER := TOS;                                          <<04850>>03265000
                                                               <<04850>>03270000
      QUIESCE'DRT(DRT);                                        <<04850>>03275000
      TOS := DRT;                                                       03280000
      TOS := @SIOP+SYSDB;                                               03285000
      ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                          03290000
WAITLOOP:                                                               03295000
                                                               <<04850>>03300000
      TOS := GETDRT(DRT,3);  << GET 4TH WORD OF DRT >>         <<04850>>03305000
                                                               <<04850>>03310000
      IF TOS.(0:2) <> 0 THEN   << I/O PROGRAM NOT DONE >>               03315000
        BEGIN                                                           03320000
          IF (COUNTER:=COUNTER+1D)= 0D THEN                    <<04850>>03325000
            MIO'STATE := -1   << FATAL ERROR >>                <<04850>>03330000
          ELSE                                                 <<04850>>03335000
            GO TO WAITLOOP;                                    <<04850>>03340000
        END;                                                            03345000
    END;                                                                03350000
                                                                        03355000
                                                                        03360000
  IF FCODE = 0 AND MIO'STATE <> -1 THEN << RET. HDWE STATUS >> <<04850>>03365000
    BEGIN                                                               03370000
      TOS := 0;                                                         03375000
      IF LMIO'STATUS.EOT THEN TOS.(12:1) := 1;  << EOT >>               03380000
      IF LMIO'STATUS.FILEPRTCT THEN TOS.(13:1) := 1;  << FILE PROTECT >>03385000
      IF LMIO'STATUS.ONLINE THEN TOS.(14:1) := 1;  << UNIT ONLINE >>    03390000
      IF LMIO'STATUS.LDPOINT THEN TOS.(15:1) := 1;  << LOAD POINT >>    03395000
      MEASIO := TOS;    << RETURN ENCODED STATUS >>                     03400000
      GOTO GOOD'EXIT;                                                   03405000
    END;                                                                03410000
                                                                        03415000
  IF MIO'STATE=-1 AND FCODE<4 THEN  << IRRECOVERABLE ERROR STATE >>     03420000
    BEGIN                                                               03425000
      MEASIO := 3;  << RETURN IRRECOVERABLE ERROR INDICATOR >>          03430000
      GOTO BAD'EXIT;                                                    03435000
    END;                                                                03440000
                                                                        03445000
  IF NOT LMIO'STATUS.ONLINE THEN  << UNIT NOT READY >>                  03450000
    BEGIN                                                               03455000
      MEASIO := 4;   << RETURN UNIT NOT READY INDICATOR >>              03460000
      GOTO BAD'EXIT;                                                    03465000
    END;                                                                03470000
                                                                        03475000
  IF LMIO'STATUS.FILEPRTCT AND FCODE<3 THEN  << FILE PROTECT ERROR >>   03480000
    BEGIN                                                               03485000
      MEASIO := 5;   << RETURN FILE PROTECT INDICATOR >>                03490000
      GOTO BAD'EXIT;                                                    03495000
    END;                                                                03500000
                                                                        03505000
  MEASIO := 0;                                                          03510000
                                                                        03515000
  IF FCODE=1 THEN   << PERFORM COUNT CHECKS >>                          03520000
    BEGIN                                                               03525000
      IF COUNT<0 THEN COUNT := -COUNT    << SETUP COUNT AS >>           03530000
      ELSE COUNT := COUNT&LSL(1);        << POSITIVE BYTES >>  <<04850>>03535000
      IF COUNT=0 THEN GOTO GOOD'EXIT;                                   03540000
      IF COUNT>MAXCOUNT THEN                                            03545000
        BEGIN                                                           03550000
          MEASIO := 2;   << RETURN INVALID COUNT INDICATOR >>           03555000
          GOTO BAD'EXIT;                                                03560000
        END;                                                            03565000
    END;                                                                03570000
                                                                        03575000
  MIO'FCODE := FCODE;    << SAVE PARAMETERS FOR RETRY >>                03580000
  MIO'BANK := BANK;                                                     03585000
  MIO'ADDR := ADDR;                                                     03590000
  MIO'COUNT := COUNT;                                                   03595000
  MIO'RETRY := 0;                                                       03600000
                                                                        03605000
  MIO'INITIATOR(DRT,DITP,SIOP,FCODE,   << START CURRENT REQUEST >>      03610000
                BANK,ADDR,COUNT);                                       03615000
                                                                        03620000
GOOD'EXIT:                                                              03625000
  TOS := OLDDB;                                                <<04850>>03630000
  ASMB(XCHD);                                                  <<04850>>03635000
  PENABLE;                                                     <<04850>>03640000
  CC := IF LMIO'STATUS.EOT  THEN  CCG  ELSE  CCE;              <<01185>>03645000
END;                                                                    03650000
$PAGE "     MEASUREMENT I/O SYSTEM -- INITIATOR"                        03655000
PROCEDURE MIO'INITIATOR(DRT,DITP,SIOP,FCODE,BANK,ADDR,COUNT);           03660000
  VALUE  DRT, DITP, SIOP, FCODE, BANK, ADDR, COUNT;                     03665000
  INTEGER  DRT, FCODE, BANK, ADDR, COUNT;                               03670000
  INTEGER POINTER  DITP, SIOP;                                          03675000
  OPTION  PRIVILEGED, UNCALLABLE, INTERNAL;                             03680000
BEGIN                                                                   03685000
                                                                        03690000
  EQUATE                                                                03695000
    BSRECORDCMD = %12,                                                  03700000
    REWINDCMD   = %15,                                                  03705000
    REWUNLDCMD  = %16,                                                  03710000
    TAPEGAPCMD  =   7,                                                  03715000
    WRITECMD    =   5,                                                  03720000
    WRTFMARKCMD =   6,                                                  03725000
                                                                        03730000
    BADDR1      =  26,                                                  03735000
    BYTECNT1    =  23,                                                  03740000
    BYTECNT2    =  28,                                                  03745000
    CMDWORD     =  96,                                         <<04118>>03750000
    MEMX1       =  25,                                                  03755000
    MEMX2       =  30,                                                  03760000
    RWDATA      =  22,                                                  03765000
    TDBL1       =  24,                                                  03770000
    TDBL2       =  29;                                                  03775000
                                                                        03780000
  SWITCH SW := BSRECORD,READSTAT,WRITEREC,WRITEFMARK,REWIND,RWDUNLOAD;  03785000
                                                                        03790000
  IF NOT (-1 <= FCODE <= 4) THEN RETURN;   << INVALID FUNCTION CODE >>  03795000
                                                                        03800000
  DISABLE;                                                              03805000
                                                               <<04850>>03810000
  << GET INTO KNOWN STATE BEFORE MODIFYING CHANNEL PGM >>      <<04850>>03815000
  QUIESCE'DRT(DRT);                                            <<04850>>03820000
                                                                        03825000
  GOTO SW(FCODE+1);   << BRANCH TO LABEL >>                             03830000
                                                                        03835000
WRITEREC:                                                               03840000
  SIOP(RWDATA) := %2000;          << WRITE COMMAND >>                   03845000
  SIOP(BYTECNT1) := COUNT;        << BYTE COUNT >>                      03850000
  IF COUNT = 0 THEN ASSEMBLE ( HALT);                                   03855000
  SIOP(TDBL1) := 0;               << TERM DISP >>              <<04118>>03860000
  SIOP(MEMX1) := BANK + %20000;   << BURST MODE/NO EOT/BANK >> <<04118>>03865000
  SIOP(BADDR1) := ADDR;           << BUFFER ADDRESS >>                  03870000
  SIOP(BYTECNT2) := 12;           << SETUP EOI EXIT JUMP >>    <<04118>>03875000
  SIOP(TDBL2) := 0;               << SETUP BURST COMPLETION >>          03880000
  SIOP(MEMX2) := -15;             <<   RETURN JUMP          >>          03885000
  SIOP(DSJ'RWJMP) := 0;           << SET SWITCH TO WRITE BRANCH >>      03890000
  TOS := WRITECMD;       << WRITE MOTION COMMAND >>                     03895000
                                                                        03900000
INITIO:                                                                 03905000
  SIOP(CMDWORD) := TOS;   << SETUP MOTION COMMAND >>                    03910000
  SIOP(DSJ'CMDJMP) := 0;  << SET SWITCH TO MOTION COMMAND BRANCH >>     03915000
                                                                        03920000
  TOS := DRT;             << START CHANNEL PROGRAM >>                   03925000
  TOS := @SIOP+SYSDB;                                                   03930000
  ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                              03935000
  MIO'STATE := IF FCODE>=0 THEN 1 ELSE 2;   << SET PROCESS STATE >>     03940000
                                                                        03945000
READSTAT:                                                               03950000
  RETURN;                                                               03955000
                                                                        03960000
                                                                        03965000
WRITEFMARK:                                                             03970000
  TOS := WRTFMARKCMD;   << WRITE FILE MARK COMMAND >>                   03975000
                                                                        03980000
CONTROLCONT:                                                            03985000
  SIOP(DSJ'RWJMP) := 25;   << BRANCH AROUND WRITE LOGIC >>     <<04118>>03990000
  GOTO INITIO;                                                          03995000
                                                                        04000000
                                                                        04005000
BSRECORD:                                                               04010000
  TOS := BSRECORDCMD;   << BACKSPACE RECORD COMMAND >>                  04015000
  GOTO CONTROLCONT;                                                     04020000
                                                                        04025000
                                                                        04030000
REWIND:                                                                 04035000
  IF LMIO'STATUS.LDPOINT THEN  << ALREADY AT LOADPOINT >>               04040000
    BEGIN                                                               04045000
      MIO'STATE := 0;   << INDICATE COMPLETION >>                       04050000
      RETURN;                                                           04055000
    END;                                                                04060000
  TOS := REWINDCMD;   << REWIND COMMAND >>                              04065000
  GOTO CONTROLCONT;                                                     04070000
                                                                        04075000
RWDUNLOAD:                                                              04080000
  TOS := REWUNLDCMD;   << REWIND/UNLOAD COMMAND >>                      04085000
  GOTO CONTROLCONT;                                                     04090000
                                                                        04095000
END;                                                                    04100000
$PAGE "     MEASUREMENT I/O SYSTEM -- COMPLETOR"                        04105000
PROCEDURE MIO'COMPLETOR(DRT,DITP,SIOP);                                 04110000
  VALUE  DRT, DITP, SIOP;                                               04115000
  INTEGER  DRT;                                                         04120000
  INTEGER POINTER  DITP, SIOP;                                          04125000
  OPTION  PRIVILEGED, UNCALLABLE, INTERNAL;                             04130000
BEGIN                                                                   04135000
                                                                        04140000
  INTEGER POINTER  ILTP;                                                04145000
  DEFINE  ERRCODE = (0:3)#;                                             04150000
  EQUATE  ERRMASK = %11020,                                             04155000
          FATAL   = %4010,                                              04160000
          TAPEGAPCMD = 7;                                               04165000
                                                                        04170000
                                                                        04175000
  @ILTP := DITP(DILTP);   << SETUP ILT POINTER >>                       04180000
  IF ILTP.ERRCODE > 5 THEN                     << CHAN ERR >>  <<04850>>04185000
    BEGIN                                                               04190000
ERR'EXIT:                                                               04195000
      MIO'STATE := -1;   << RETURN FAILURE INDICATOR >>                 04200000
      RETURN;                                                           04205000
    END;                                                                04210000
                                                               <<04850>>04215000
  QUIESCE'DRT(DRT);                                            <<04850>>04220000
                                                               <<04850>>04225000
  IF (LMIO'STATUS LAND FATAL) <> 0 THEN GOTO ERR'EXIT;                  04230000
                                                                        04235000
  IF MIO'STATE=1 THEN   << I/O IN PROGRESS >>                           04240000
    BEGIN                                                               04245000
      IF (MIO'FCODE=1 OR MIO'FCODE=2) AND                               04250000
         ((LMIO'STATUS LAND ERRMASK) <> 0) THEN   << RETRY >>           04255000
        BEGIN                                                           04260000
        MIO'STATUS := 0;                                       <<04850>>04265000
          IF (MIO'RETRY := MIO'RETRY+1) <= 2 THEN                       04270000
            BEGIN                                                       04275000
              MIO'INITIATOR(DRT,DITP,SIOP,-1,0,0,0);                    04280000
              RETURN;                                                   04285000
            END                                                         04290000
          ELSE                                                          04295000
            GOTO ERR'EXIT;                                              04300000
        END;                                                            04305000
                                                                        04310000
      IF MIO'FCODE=3 THEN   << REWIND OPERATION STARTED >>              04315000
        BEGIN                                                           04320000
          SIOP(DSJ'CMDJMP) := 57;                              <<04118>>04325000
          MIO'STATE := 4;   << REWIND COMPLETION WAIT >>                04330000
          GOTO IOCONT;                                                  04335000
        END;                                                            04340000
                                                                        04345000
      MIO'STATE := 0;   << INDICATE SUCCESSFUL COMPLETION >>            04350000
    END                                                                 04355000
                                                                        04360000
  ELSE IF MIO'STATE=2 THEN   << BACKSPACE RECORD COMPLETED >>           04365000
    BEGIN                                                               04370000
      SIOP(CMDWORD) := TAPEGAPCMD;   << TAPE GAP COMMAND >>             04375000
      MIO'STATE := 3;                                                   04380000
IOCONT:                                                                 04385000
      TOS := DRT;        << START CHANNEL PROGRAM >>                    04390000
      TOS := @SIOP+SYSDB;                                               04395000
      ASMB(DDUP;SIOPG;BL*-3;BE*+2;BR*-5;DDEL);                          04400000
    END                                                                 04405000
                                                                        04410000
  ELSE IF MIO'STATE=3 THEN   << TAPE GAP COMPLETED >>                   04415000
    BEGIN                                                               04420000
      MIO'INITIATOR(DRT,DITP,SIOP,MIO'FCODE,                            04425000
                    MIO'BANK,MIO'ADDR,MIO'COUNT);                       04430000
    END                                                                 04435000
                                                                        04440000
  ELSE IF MIO'STATE=4 THEN   << REWIND COMPLETED >>                     04445000
    BEGIN                                                               04450000
      MIO'STATUS.LDPOINT :=1;                                           04455000
      MIO'STATE := 0;                                                   04460000
    END;                                                                04465000
END;                                                                    04470000
$PAGE "     MEASUREMENT I/O SYSTEM -- INTERRUPT PROCESSOR"              04475000
PROCEDURE MIO'INTRPT'PROC;                                              04480000
  OPTION  PRIVILEGED, UNCALLABLE, INTERRUPT;                            04485000
BEGIN                                                                   04490000
                                                                        04495000
  INTEGER                                                               04500000
    DRT         = Q+3,    << LOCATED AT S-1 WHEN PROCEDURE IS ENTERED >>04505000
    UNIT        = Q+5;    << UNIT NUMBER OF INTERRUPTING MAG TAPE >>    04510000
                                                                        04515000
  INTEGER POINTER                                                       04520000
    SIOP        = Q+4,    << CHANNEL PROGRAM POINTER >>                 04525000
    DITP        = Q+6;    << DIT POINTER >>                             04530000
                                                                        04535000
  INTEGER                                                               04540000
    ILT'SIOP    = DB+ISIOP,  << ILT CHANNEL PROGRAM POINTER >>          04545000
    ILT'FLAG    = DB+IFLAG;  << ILT FLAG WORD >>                        04550000
                                                                        04555000
  INTEGER ARRAY                                                         04560000
    ILT'DITP(*) = DB+IDITP0;  << ILT POINTER FOR DIT 0 >>               04565000
                                                                        04570000
  LOGICAL  LS0=S-0;                                                     04575000
  INTEGER  X=X;                                                         04580000
                                                                        04585000
                                                                        04590000
  TOS := ILT'SIOP;        << SIOP >>                                    04595000
                                                                        04600000
  X := LS0 + SYSDB + 94;                                                04605000
  TOS := ABSOLUTE(X).(9:2);  << UNIT >>                                 04610000
                                                                        04615000
  TOS := ILT'DITP(UNIT);  << DITP >>                                    04620000
  IF <= THEN RETURN;        << UNCONFIGURED UNIT >>                     04625000
                                                                        04630000
                                                               <<04850>>04635000
                                                               <<04850>>04640000
                                                                        04645000
  TOS := 0;                                                             04650000
  TOS := SYSDB;                                                         04655000
  ASMB(XCHD);       << SET DB TO SYSDB >>                               04660000
                                                                        04665000
                                                               <<04850>>04670000
  MIO'COMPLETOR(DRT,DITP,SIOP);    << CALL COMPLETOR >>                 04675000
END;                                                                    04680000
$PAGE "     MEASUREMENT I/O SYSTEM -- DATA INITIALIZATION"              04685000
PROCEDURE MIO'INIT(LDEV);                                               04690000
  VALUE  LDEV;                                                          04695000
  INTEGER  LDEV;                                                        04700000
  OPTION  PRIVILEGED, UNCALLABLE;                                       04705000
BEGIN                                                                   04710000
                                                                        04715000
<<  This procedure intializes the DRT, DIT, and SIO program area  >>    04720000
<<  as required by the Series 33 Measurement I/O System.  It also >>    04725000
<<  halts the 7970E HP-IB Mag Tape Driver's Idle Channel Program. >>    04730000
                                                                        04735000
<<  The parameter, LDEV, is an integer containing the measurement >>    04740000
<<  logical device number in bits (8:8) and a "unit downed" bit   >>    04745000
<<  map in bits(0:4).                                             >>    04750000
                                                                        04755000
  INTEGER  DRT;                                                         04760000
  INTEGER POINTER  DITP, ILTP, SIOP;                                    04765000
                                                                        04770000
                                                                        04775000
  DISABLE;                                                              04780000
  TOS := 0;                                                             04785000
  TOS := SYSDB;                                                         04790000
  ASMB(XCHD);        << SET DB TO SYSDB >>                              04795000
                                                                        04800000
  @DITP := LPDT (( LDEV.(8:8)*LPDT'ENT'SIZE)+DIT'OFFSET);       <<MPEV>>04805000
  @ILTP := DITP(DILTP);                                                 04810000
  @SIOP := ILTP(ISIOP);                                                 04815000
  DRT := ILTP(ICNTRL).IDRTN;                                   <<04850>>04820000
                                                                        04825000
  QUIESCE'DRT(DRT);                                            <<04850>>04830000
                                                               <<04850>>04835000
                                                                        04840000
  MIO'ENABLE := "OK";     << INITIALIZE DIT >>                          04845000
  MIO'STATE  := 0;                                                      04850000
  MIO'RETRY  := 0;                                                      04855000
                                                                        04860000
  MIO'LDEV   := LDEV;     << INITIALIZE SIO AREA >>                     04865000
  MIO'UNIT   := DITP(DLDEV).UNIT'FIELD+1; <<UNIT # FROM DIT+1>><<01430>>04870000
  MIO'STATUS := 0;                                                      04875000
                                                                        04880000
  PUTDRT(DRT,2,@MIO'INTRPT'PROC); << INITIALIZE DRT >>         <<04850>>04885000
                                                               <<04850>>04890000
                                                                        04895000
  ASMB(XCHD);      << RESET DB >>                                       04900000
END;                                                                    04905000
$PAGE "     MEASUREMENT I/O SYSTEM -- RESET DATA"                       04910000
INTEGER PROCEDURE MIO'RESET(LDEV);                                      04915000
  VALUE  LDEV;                                                          04920000
  INTEGER  LDEV;                                                        04925000
  OPTION  PRIVILEGED, UNCALLABLE;                                       04930000
BEGIN                                                                   04935000
                                                                        04940000
<<  This procedure resets the DIT, DRT, and SIO program area for >>     04945000
<<  use by the Series 33 Mag Tape Driver.  It also starts an     >>     04950000
<<  Idle Channel Program for the mag tape controller.            >>     04955000
                                                                        04960000
<<  This procedure returns an integer containing the measurement >>     04965000
<<  logical device number in bits (8:8) and the "unit downed"    >>     04970000
<<  bit map in bits (0:4).                                       >>     04975000
                                                                        04980000
  INTEGER  DRT;                                                         04985000
  INTEGER POINTER  DITP, ILTP, SIOP, IDLESIO;                           04990000
  EQUATE IDLE = 68;                                            <<04850>>04995000
                                                                        05000000
                                                                        05005000
  DISABLE;                                                              05010000
  TOS := 0;                                                             05015000
  TOS := SYSDB;                                                         05020000
  ASMB(XCHD);       << SET DB TO SYSDB >>                               05025000
                                                                        05030000
  @DITP := LPDT (( LDEV.(8:8)*LPDT'ENT'SIZE)+DIT'OFFSET);       <<MPEV>>05035000
  @ILTP := DITP(DILTP);                                                 05040000
  @SIOP := ILTP(ISIOP);                                                 05045000
  @IDLESIO := @SIOP+IDLE;                                               05050000
  DRT := ILTP(ICNTRL).IDRTN;                                   <<04850>>05055000
                                                                        05060000
  MIO'RESET := MIO'LDEV;    << SAVE RETURN VALUE >>                     05065000
                                                                        05070000
  MOVE DITP(8) := (3(0));   << RESET DIT >>                             05075000
  MIO'STATUS   := 0;        << RESET SIO STATUS WORD >>                 05080000
                                                                        05085000
  PUTDRT(DRT,2,@GIP'HPIB); << RESET DRT >>                     <<04850>>05090000
                                                                        05095000
  << TURN OFF BIT INDICATING THAT IDLE CHANNEL PROGRAM IS RUNNI<<04850>>05100000
  ILTP(IFLAG).WAITPROG := 0;                                   <<04850>>05105000
                                                               <<04850>>05110000
  AWAKEIO(DITP,0); << START IDLE CHANP, NO IMPEDE >>           <<04850>>05115000
<< IF < THEN IOFAILURE(DRT,DITP); >>                           <<04850>>05120000
                                                                        05125000
  ASMB(XCHD);     << RESET DB >>                                        05130000
END;                                                                    05135000
$CONTROL SEGMENT=SEG'                                          <<01549>>05140000
END.                                                           <<01549>>05145000
