
Cyclic   IDNT                            ; Title of  Cyclic Section

         SECTION   Sect_Cyclic,4,C       ; Declare a noncommon code section.
                                         ; Align to Longwords.

***************************************************************************
*                                                                         *
*   Cyclic   Event by Event Processing               Rev.  23-OCT-1991    *
*                                                                         *
***************************************************************************

***************************************************************************
*                                                                         *
*    Address Map of the Level 1 Trigger VME Crate (133A's view)           *
*                                                                         *
*        0000 0000  through  000F FFFF     133A Module Memory             *
*        0030 0000  through  0030 7FFF     VME 214 Module for Trig Block  *
*        0038 0000  through  003F FFFF     VBD Buffer Memory              *
*                                                                         *
*        FFFF 9000  through  FFFF 97FF     Short 214 IO Space Memory      *
*        FFFF A000  through  FFFF BFFF     VBD Control Memory             *
*        FFFF C000  through  FFFF C0FF     Crate ID Register Card         *
*        FFFF F000  through  FFFF F00F     Ironics 1623 Digital IO Card   *
*                            FFFF ????     Vertical Interconnect Reg.     *
*                                                                         *
*                                                                         *
*  The following is a list of the memory locations that will be used in   *
*  the VME-214 Memory module.   Recall that this module lives in VME      *
*  addresses $00300000  through  $00307FFF.                               *
*                                                                         *
*      VME Address Range                     Contents                     *
*  ---------------------------      --------------------------------      *
*  $00300000 through $00300FFF       Current Beam Crossing Data           *
*  $00301000 through $00301FFF       Previous Beam Crossing Data          *
*                                                                         *
*  $00301FB8 through $00302          Specific Trigger Programming vs      *
*                                    Ref Sets and Spec Trigs Fired Data.  *
*                                                                         *
*  $00304000 through $003040FF       Central Detector Pulser Data         *
*  $00304100 through $003041FF       Calorimeter Pulser Data              *
*  $00304400 through $003047FF       CAMAC Data                           *
*                                                                         *
*  $00305000 through $0030501F       Crate Header data 5 longwords        *
*                                                                         *
*  $00306000 through $003069FF       The VBD reads the Current Beam       *
*                                    Crossing CTFE Data from here.        *
*  $00307000 through $003079FF       The VBD reads the Previous Beam      *
*                                    Crossing CTFE Data from here.        *
*                                                                         *
*  $00306B00 through $00306C03       EM Et Jet List stored here           *
*                                    for the VBD to read.                 *
*  $00306D00 through $00306E03       Total Et Jet List stored here        *
*                                    for the VBD to read.                 *
*                                                                         *
*                                                                         *
*         List of VBD DMA sections used to build the data block           *
*                                                                         *
*  Length in Bytes    VME Starting                                        *
*  Decimal    Hex      Address Hex            Contents                    *
*  ---------------    ------------    ---------------------------------   *
*    1064    $428        $300004      Current Framework, Cal Trig Final   *
*                                     Sums, L0 Vertex, and L1.5  data     *
*                                                                         *
*    2560    $A00        $306000      Current Cal Trig EM Et and HD Et    *
*                                                                         *
*    1064    $428        $301004      Previous Framework, Cal Trg Final   *
*                                     Sums, L0 Vertex, and L1.5  data     *
*                                                                         *
*    2560    $A00        $307000      Previous Cal Trig EM Et and HD Et   *
*                                                                         *
*     260    $104        $306B00      EM Jet List                         *
*                                                                         *
*     260    $104        $306D00      Total Et Jet List                   *
*                                                                         *
*    1280    $500        $300830      Mask of Jet Patterns  "Jet Mask"    *
*                                                                         *
*     640    $280        $301E74      TRD Hot Tower Table Information     *
*                                                                         *
*     100     $64        $301FB8      Specific Trigger Programming Infrm  *
*                                                                         *
*     512    $200        $304000      Pulser Programming Data, 2 groups   *
*                                     of 64 longwords each, transported   *
*                                     by but not part of the L1 Trigger   *
*                                     Data Block. Central and Calorimeter *
*                                                                         *
*     256    $100        $304400      CAMAC Data about less then 100      *
*                                     longwords.  Transported by but not  *
*                                     part of the L1 Trigger Data Block.  *
***************************************************************************


***************************************************************************
*                                                                         *
*  Cyclic Operation section.                                              *
*     Zero the loop counter that times the wait for Slave Ready.          *
*     Wait for the Slave Ready signal from the COMINT and verify          *
*        that Slave Ready is HIGH.  If it takes too long (e.g.            *
*        > 2 min) then: pulse Data Cable Driver Finished to               *
*        "clear" the COMINT card, Set the TWB that says no Slave          *
*        Ready seen, and put a warning message on the 68k console.        *
*        While waiting for Slave Ready pulse the 68k running OK line      *
*        to keep the VME NOT Running TWB from becoming active.            *
*     Once Slave Ready is received:                                       *
*     Increment the Buffer Select Counter so that the least               *
*        recently used VBD Buffer will be tested first to see             *
*        if it is free.                                                   *
*     Read the Specific Triggers Fired and make a Specific Triggers       *
*        Fired list in a longword. Based on which Spec Trig's have        *
*        fired this is either a Monitor Data Only Event or else it is     *
*        a "Normal" event.                                                *
*     If this event is only a monitor Specific Trigger then:              *
*        Send a monitor data only message to the 68020 terminal.          *
*        Send the Data Cable Driver Finished signal to the COMINT.        *
*        Wait for the COMINT Slave Ready signal to fall.                  *
*        Drop the Data Cable Driver Finished signal.                      *
*        Clear the TWB's that say that "No Slave Readies Seen" and        *
*        "VME is Not Running".  Return to waiting for another Slave       *
*        Ready.                                                           *
*     If this event is any combination of Specific Triggers that          *
*        includes at least one "normal" Specific Trigger then:            *
*        Make a 16 bit Event Number for the VBD to read and save          *
*           information to display the Sync Bits if there is time.        *
*        Build the Crate Header words #1 (the sync word) and Crate        *
*           Header word #5 (the list of Specific Triggers Fired).         *
*        Call the routine to move the CTFE Et data to where the           *
*           VBD will read it from.                                        *
*        Call the routine to build the lists of which Spec Trig's         *
*           were programmed to use which Ref Sets AND fired for           *
*           this event.                                                   *
*        Call the routine to build the EM Jet List.                       *
*        Call the routine to build the Total Et Jet List.                 *
*        Call the Subroutine to read the Calorimeter Pulser Programming   *
*           Data and the Central Detector Pulser Programming Data.        *
*        Call the routine to read the CAMAC data.                         *
*                                                                         *
*        Initialize the maximum wait counter to time how long is          *
*           required to find a free VBD Buffer.                           *
*        Examine the VBD Buffer Select Counter to learn which             *
*           VBD Buffer should be tested first.  If the first one          *
*           tested is not available then test the other one.              *
*           A VBD Buffer is free and ready to be used for this event      *
*           if both its CSR Port Status and DMA bits are zero.            *
*        Check for (and wait for) a free  VBD Buffer.                     *
*        If neither Buffer becomes available with in the maximum          *
*           wait then, send an message to the console, pulse the          *
*           Data Cable Driver Finished line, Set the Can NOT Transfer     *
*           to L2 Trouble Warning Bit,  and return to waiting for a       *
*           Slave Ready signal.                                           *
*        Finding a free VBD Buffer within maximum wait time then:         *
*        Tell the selected free VBD Buffer to run the DMA list.           *
*        Send to the 68020 terminal either a "0" or a "1".                *
*        Zero the DMA time out counter.                                   *
*        Wait for the DMA to finish; increment the DMA time out           *
*           counter with each loop of testing the DMA status.             *
*        If the DMA times out then send a message to the 68020            *
*           terminal and continue. If it does not time out then           *
*           when the DMA is finished just continue from here.             *
*        Send the Data Cable Driver Finished signal to the COMINT.        *
*        Wait for the COMINT Slave Ready signal to fall.                  *
*        Drop the Data Cable Driver Finished signal.                      *
*        Clear the Slave Ready Not Seen, clear the Can't Transfer to      *
*           L2, and clear the VME Not Running Trouble Warning Bits.       *
*        If the wait to receive the Slave Ready for this event            *
*           was longer than SRMINDISP then the current event rate         *
*           is low enough to take the time to display a message.          *
*           If it was a short wait then move on with no message.          *
*           If it was a long wait then display on the 68020 a message     *
*              which gives details about this event and this transfer     *
*              to Level 2.                                                *
*        Return to the start of the cyclic section.                       *
*           (wait for Slave Ready).                                       *
*                                                                         *
*                                                                         *
*  Control of the Trouble Warning Bits                                    *
*                                                                         *
*     During the period while waiting for the Slave Ready signal:         *
*        In every cycle of the loop testing for Slave Ready, cycle the    *
*           VME Transfer Program Running TWB (bit #1)  Low-High-Low.      *
*        If Slave Ready is not seen with in the max wait time then set    *
*           the Slave Ready Not Seen TWB (bit #4) High.                   *
*     In the monitor data only events routine Clear the No Slave          *
*        Readies Seen and the VME Not Running Trouble Warning Bits.       *
*     In the normal exit from the normal events routine Clear the: No     *
*        Slave Readies Seen, the Can't Transfer to L2, and the VME Not    *
*        Running Trouble Warning Bits.                                    *
*     In the can't find a free VBD Buffer to transfer a normal event      *
*        routine Set the Can't Transfer to L2 Trouble Warning Bit.        *
*                                                                         *
***************************************************************************


*************************************************************************
*       This section defines program-specific macros:                   *
*                                                                       *
*            RDIO:  Read bit from IRONICS I/O card and returns state    *
*            WRIO:  Write bit(s) to the IRONICS I/O card                *
*            SOFTWAIT:  Software delay timer for short waits            *
*                                                                       *
*************************************************************************

RDIO    MACRO                                 ; read byte from I/O port.
        CMPI.B  #BIT1HIGH,\1                  ; is selected line high?
        ENDM                                  ; set Z on result.

WRIO    MACRO                                 ; write byte to I/O port.
        NOT.B   \1                            ; complement input.
        MOVE.B  \1,\2                         ; and send to port.
        ENDM

SOFTWAIT   MACRO                              ; Software timer loop.
           LOCAL    WAITMORE                  ; Define a local symbol.
           MOVE.L   \1,D4                     ; Load delay time into D4.
WAITMORE   SUBI.L   #1,D4                     ; Decrement loop counter.
           BNE      WAITMORE                  ; Test for end of delay.
           ENDM                               ; Called with an argument
                                              ; of $1000 causes a delay
                                              ; of about 3 mill seconds.


*************************************************************************
*  Cyclic Section:                                                      *
*                                                                       *
*  Wait for a L1 trigger and for the COMINT Data Block Builder to       *
*  finish building a new L1 Data Block.   When COMINT is finished       *
*  building a Data Block it sets the Slave Ready signal High.           *
*                                                                       *
*  Count how long we have waited for Slave Ready to go High in the      *
*  location SRLOOPCNT.   This size of this count will let us know how   *
*  long of an information message can be sent to the 68k terminal after *
*  the transfer to the VBD and also let us know if there has not been   *
*  a Slave Ready signal in a very long time and thus we should pulse    *
*  the Data Cable Driver Finished line to clear something in COMINT.    *
*  After finding a Slave Ready, store the wait for Slave Ready count.   *
*                                                                       *
*  Each time going around the loop waiting for Slave Ready pulse the    *
*  VME Transfer Program Running bit in the Trouble Warning Bits low-    *
*  high-low to indicate that the VME Transfer Program is running.       *
*                                                                       *
*  If Slave Ready is not seen within the SRMaxWait number of loops      *
*  execute the STUCK routine to try to free up the COMINT card.  In     *
*  the STUCK routine pulse the Data Cable Driver Finished line, send a  *
*  message to the 68k console, and set the No Slave Readies Seen bit    *
*  in the Trouble Warning Bits.                                         *
*                                                                       *
*  When Slave Ready goes high then jump to the routine PROCEVT  i.e.    *
*  process the event.                                                   *
*                                                                       *
*************************************************************************

               ALIGN   4               ; Align to Longword Address.

Begin_Cyclic   CLR.L   D1              ; Starting the wait for Slv Rdy so
                                       ;   zero the loop counter.

TESTSR  MOVE.B  TWBData,D0             ; Pulse the Trouble Warning Bit #0,
        MOVE.B  D0,D7                  ; the VME Transfer Program Running
        ORI.B   #$01,D0                ; bit, low-high-low to flag that
        WRIO    D0,TWBPortAdrs         ; the VME Transfer Program is
        ANDI.B  #$FE,D7                ; Running OK.
        WRIO    D7,TWBPortAdrs

        RDIO    SlvRdy                 ; Look for the Slave Ready  HI.
        BEQ     VERFSR                 ; If high, then verify that it is HI.
        ADD.L   #$1,D1                 ; Increment the wait for Slv Rdy count.
        CMP.L   SRMaxWait,D1           ; Test to see if it has been the max
        BEQ     STUCK                  ;   wait.  If so pulse the  Finished
                                       ;   line to wake up the COMINT.
        JMP     TESTSR                 ; Wait for the Slave Ready.


VERFSR  RDIO    SlvRdy                 ; Look for the Slave Ready  HI.
        BEQ     PROCEVT                ; If still high, then process the event.
        JMP     TESTSR                 ; Back to waiting for the Slave Ready.


STUCK   MOVE.B  #Bit1High,D0           ; Send a Data Cable Driver
        WRIO    D0,DCDrFin             ;   Finished signal to COMINT.
        SOFTWAIT  #$1000               ; Wait about 4 mill seconds.
        MOVE.B  #AllBitsLow,D0         ; Drop the Data Cable Driver
        WRIO    D0,DCDrFin             ;   Finished signal.

        PEA.L   SRWaitMsg1             ; Send a message saying that SR not
        JSR     ChrStrgOut             ;   seen within Max Wait.
        PEA.L   SRWaitMsg2             ; Pulsing Data Cable Driver Finished
        JSR     ChrStrgOut             ;   to free up the COMINT card.

        MOVE.B  TWBData,D0             ; Set the No Slave Readies Seen bit
        ORI.B   #$08,D0                ;   in the Trouble Warning Bits to
        MOVE.B  D0,TWBData             ;   flag the problem for monitoring.
        WRIO    D0,TWBPortAdrs         ;   Send the new TWB's out their port.

        JMP     Begin_CYCLIC           ; Start looking for Slave Ready
                                       ;   again.  Zero the SR wait counter.


*************************************************************************
*  Cyclic Section:                         Begining of Process Event    *
*                                                                       *
*  Slave Ready has gone high and been verified as being high.  Store    *
*  the counter that shows how long we waited for the Slave Ready to go  *
*  high and then increment BUFSELECT to alternate which of the VBD      *
*  buffers will be used for this event.                                 *
*                                                                       *
*  Call the Spec_Trig_Prog_Fired routine.  This routine will build the  *
*  a long word which shows which Spec Trigs fired for this event and    *
*  it will store this information at location TrgsFired and return it   *
*  in data register D1.  This routine also builds the 8 lists which     *
*  show for each Reference Set which Spec Trigs were both programmed    *
*  to use a given Reference Set and fired on this event.                *
*                                                                       *
*  AND the Specific Triggers Fired list with the mask of monitor data   *
*  only Specific Triggers.                                              *
*                                                                       *
*  If just a monitor Specific Trigger (e.g. #31) fired then this event  *
*  is only L1 monitor data and it should NOT be sent to the VBD or L2.  *
*  If any other Specific Trigger(s), besides the monitor data only      *
*  Specific Trigger(s), fired then send this L1 Data Block to the VBD   *
*  and L2.                                                              *
*************************************************************************

                ALIGN   4              ; Align to Longword Address.

PROCEVT ADD.L   #$1,BufSelect          ; Alternate which VBD buffer is used.
        MOVE.L  D1,SRLoopCnt           ; Store the count of how long we have
                                       ;   waited for a Slave Ready.

        JSR  Begin_Spec_Trig_Prog_Fire      ; Call to build list of Spec Trigs
                                            ; fired and 8 lists of Spec Trigs
                                            ; that depended on a given Ref Set
                                            ; AND fired on this event.

        AND.L   MskMonSpTrg,D1              ; Test for Spec Trigs besides
                                            ;   just Monitor Spec Triggers.
        BEQ     ONLYMON                     ; Branch to service Monitor data
                                            ;   only "events".
        JMP     OTHERTRGS                   ; Jump to service events that have
                                            ;   a Spec Trig besides Mon trigs.

*************************************************************************
*  Cyclic Section:    START of service for Monitor Data only "events".  *
*                                                                       *
*  Service events in which only Monitor Specific Triggers have          *
*  fired.  This implies --> monitor data only events.                   *
*                                                                       *
*  Send a message to the 68k termanal that this is monitor data only.   *
*                                                                       *
*************************************************************************

ONLYMON  PEA.L    MonMessage                ; Push monitor data only message
         JSR      ChrStrgOut                ; on the stack and send it out.

*************************************************************************
*  Cyclic Section:                 Monitor Data only "events"           *
*                                                                       *
*  Tell COMINT that the VBD is finished and wait for SLV Ready to drop. *
*                                                                       *
*************************************************************************

        MOVE.B  #Bit1High,D0                ; Send a Data Cable Driver
        WRIO    D0,DCDrFin                  ;   Finished signal to COMINT.

StilHi  RDIO    SlvRdy                      ; Look for the Slave Ready.
        BEQ     StilHi                      ; If it is still high then keep
                                            ;   waiting until it drops then.

        MOVE.B  #AllBitsLow,D0              ; Drop the Data Cable Driver
        WRIO    D0,DCDrFin                  ;   Finished signal.

*************************************************************************
*  Cyclic Section:      END of service for Monitor Data only "events".  *
*                                                                       *
*  Update the Trouble Warning Bits.                                     *
*  Return to the begining of the Cyclic Section.                        *
*************************************************************************

        MOVE.B  TWBData,D0             ; The VME processor must be receiving
        ANDI.B  #$F6,D0                ; Slave Readies for the program to get
        MOVE.B  D0,TWBData             ; here so, Clear the No Slave Readies
        WRIO    D0,TWBPortAdrs         ; and the VME Not Running  Trouble
                                       ; Warning Bits.

        JMP     Begin_CYCLIC                 ; Return to the start of the
                                             ;   cyclic section.


*************************************************************************
*  Cyclic Section:          START of service for normal events.         *
*                                                                       *
*  Service events in which some combination of normal (non-Monitor)     *
*  Specific Triggers have fired.  In addition some Monitor Specific     *
*  Triggers may have fired.                                             *
*                                                                       *
*  Start by making a copy of the low order 16 bits of the Event         *
*  Number.   Put this 16 bit Event Number in Short IO Address Space     *
*  where the VBD can read it.  Also store it in TRGNUMSTORE.            *
*                                                                       *
*  Recall the format of the Event Number as written in VME memory       *
*  with VMX address line MDA01 inverted.  TrgNum is the symbol for      *
*  the address of the first long word that hold Event Number data.      *
*                                                                       *
*               3     2 2     1 1                                       *
*               1     4 3     6 5     8 7     0                         *
*    TrgNum    ---------------------------------                        *
*    $300284   |       | 2nd B |       | 1st B |      Bytes of the      *
*              ---------------------------------      Event Number      *
*                                                                       *
*************************************************************************

           ALIGN   4                     ; Align to Longword Address.

OTHERTRGS  CLR.L   D0                    ; Clear Data Register 0.
           MOVE.L  TrgNum,D1             ; Get 2nd and 1st bytes of Event Num.
           Swap    D1                    ; Swap words of raw event number.
           MOVE.B  D1,D0                 ; Get Event Number 2nd byte into D0.
           LSL.L   #$8,D0                ; Shift it up into place.
           Swap    D1                    ; Swap words of raw event number.
           MOVE.B  D1,D0                 ; Get Event Number 1st byte into D0.
                                         ; D0 now holds the 16 bit Event
                                         ; Number in its least significnt word.

           MOVE.W  D0,EvtNmbAdr133       ; Store the 16 bit Evt Num in the
                                         ;   Short IO Address memory space
                                         ;   for the VBD to read.

           MOVE.L  D0,TrgNumStore        ; Store the 16 bit trigger number
                                         ;   in a longword.

*****************************************************************************
*                                                                           *
*  Cyclic Section:            Service Data Block for Normal Events          *
*                                                                           *
*  Build the words #1 and #5 of the Crate Header.                           *
*  Words #2, #3, and #4 of the Crate Header are event to event static       *
*  and have been built and stored in the Initialization Section above.      *
*                                                                           *
*    Crate Header Word 1   Sync Word   2 MSByts Evt Num  2 LSByts of F's    *
*    Crate Header Word 2   Controller Word  MSByte is the low byte Crate ID *
*    Crate Header Word 3   Version Number  4-JAN-1990 Document definition   *
*    Crate Header Word 4   Rivision Number   defined in D0 Note #967        *
*    Crate Header Word 5   Specific Triggers Fired list    32 bits          *
*                                                                           *
*****************************************************************************

                                         ; D0 still holds the 16 bit Evt Num.
        SWAP    D0                       ; Move the 16 bit Evt Num into
                                         ;   the high order 16 bits.
        MOVE.W  #$FFFF,D0                ; Pad the Sync Word with F's.
        MOVE.L  D0,CrtHDWord1            ; Store the Sync Word in the
                                         ;   first word of the Crate Header.

        MOVE.L  TrgsFired,CrtHDWord5     ; Store the Specific Triggers Fired
                                         ;   list in the 5th word of the
                                         ;   Crate Header.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to move the EM and HD CTFE Et data from where    *
*  the COMINT has written it to where the VBD will read it.             *
*************************************************************************

        JSR  Begin_Move_Data    ; Subroutine call to move CTFE Et data.


*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to build the EM Jet List.                        *
*************************************************************************

        JSR  Begin_EM_Jet_List     ; Subroutine call to build the EM Jet List.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to build the Total Et Jet List.                  *
*************************************************************************

        JSR  Begin_TEt_Jet_List                  ; Subroutine call to build
                                                 ; the Total Et Jet List.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to read the Central Detector Pulser Programming  *
*  Data via the Vertical Interconnect.  The starting location to store  *
*  this data in MVME-214 memory is passed to the routine in Reg A0.     *
*************************************************************************

        MOVEA.L    BAPulser,A0      ; Give Get_CD_Pulser the address where
                                    ; it should store the CD Pulser data.

        JSR  Begin_Get_CD_Pulser    ; Subroutine call to get CD Pulser Data.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to read the Calorimeter Pulser Programming       *
*  Data via the Vertical Interconnect.  The starting location to store  *
*  this data in MVME-214 memory is passed to the routine in Reg A0.     *
*************************************************************************

       MOVEA.L   BAPulser,A0         ; Give Get_Calo_Pulser the address where
       ADD.L     #$100,A0            ; it should store the Calo Pulser data.

       JSR  Begin_Get_Calo_Pulser    ; Subroutine call to get Cal Pulser Data.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  Call the subroutine to read the CAMAC Data.                          *
*************************************************************************

        MOVEA.L    BACAMAC,A0       ; Give Get_CAMAC the address where
                                    ; it should store the CAMAC data.

        JSR  Begin_Get_CAMAC        ; Subroutine call to get the CAMAC Data.

*************************************************************************
*                                                                       *
*  Cyclic Section:            Service Data Block for Normal Events      *
*                                                                       *
*  All of the data and headers are now ready to be read by the VBD.     *
*  Examine BUFSELECT to determine which of the two buffers (0 or 1)     *
*  on the VBD should be used to DMA read this data.  The buffers are    *
*  used on alternate events.                                            *
*  Initialize the maximum wait time counter for finding a free buffer.  *
*************************************************************************

        MOVE.L  BBSMaxWait,D4               ; Load the maximum wait (times
                                            ; tested) to find a free Buffer.

        MOVE.L  BufSelect,D0                ; Move Buffer Select into D0.
        ANDI.L  #$00000001,D0               ; Mask all but the lowest bit
                                            ;   of the Buffer Select.
        BEQ     USEBUF0                     ; Bufselect even - use Buffer 0.
        JMP     USEBUF1                     ; Bufselect odd  - use Buffer 1.

*************************************************************************
*                                                                       *
*  Cyclic Section:  Service Data Block for Normal Events, use Buffer 0  *
*                                                             --------  *
*  If VBD buffer 0 has been selected for the transfer of this event     *
*  then this section takes care of testing that buffer 0 is connected   *
*  to the VME port and that it is not currently running a DMA cycle.    *
*  If everything is OK then a DMA cycle will be started to move VME     *
*  data into buffer 0.                                                  *
*                                                                       *
*  If it is found that buffer 0 is either connected to the external     *
*  port or that buffer 0 is already doing a DMA cycle then the program  *
*  will jump to test the status of buffer 1 and try to use it.  If the  *
*  program has already tested both buffers many times ( > BBSMAXWAIT )  *
*  and has not found a free buffer, then it will branch to BBSTMOUT.    *
*                                                                       *
*  Once the DMA operation is started on buffer 0, a short message,      *
*  "0", will be sent to the 68020 console.                              *
*                                                                       *
*  Next the program will test for the completion of the DMA cycle on    *
*  buffer 0.  If the DMA cycle completes in less than about 1/2 second  *
*  then everything is normal and execution proceeds to the NCYCEXIT     *
*  section.  If the DMA cycle does not complete within the 1/2 second   *
*  then an error message is displayed and then execution proceeds to    *
*  the NCYCEXIT section.                                                *
*                                                                       *
*************************************************************************

          ALIGN   4                       ; Align to Longword Address.

USEBUF0   CLR.L   D0                      ; Clear all bits in data reg 0.
          MOVE.W  VBDCSR2,D0              ; Move the VBD CSR2 into D0.
          AND.L   MskBuf0Sta,D0           ; Mask all but the Buf 0 DMA and
                                          ;   Buf 0 port status bits.
          BEQ     BUF0RDY                 ; If both CSR bits are 0 then,
                                          ;   Buffer 0 is ready to use.
                                          ; Else
          SUBI.L  #$1,D4                  ; Decrement the max wait counter
                                          ;   for finding a free VBD buffer.
          BEQ     BBSTMOUT                ; If time is up and no free buffer
                                          ;   found then branch to time out.
                                          ; If max wait is not used up then
          JMP     USEBUF1                 ; Try to use buffer 1 it may
                                          ;   be free.

BUF0RDY   MOVE.W  Buf0DMAGo,VBDCSR0       ; Start the DMA running into Buf 0.

                                            ; Send out the one character
Chk30TxRDY    Move.B   AdrTxStat,D4         ; message "0"  --> VBD buffer #0.
              ANDI.L   #$00000080,D4        ; Read MFP Transmitter Status Reg.
              IF.B  D4 <NE> #$80  THEN.S    ; Mask all but Tx Buffr Empty Bit.
                JMP  Chk30TxRDY             ; Test if Buffer Empty bit is set,
              ENDI                          ; i.e. ready to send next charctr?
              Move.B   #$30,AdrTxBufr       ; Keep testing as needed.   Load
                                            ; character "0" into Tx Buffer.

        MOVE.L  WaitDMA,D4                ; Initialize the register to wait
                                          ;  for the DMA cycle to finish.

         CLR.L   D0                       ; Clear all bits in data reg 0.
CHKDMA0  MOVE.W  VBDCSR2,D0               ; Move the VBD CSR2 into D0.
         AND.L   MskBuf0DMA,D0            ; Mask all but the Buf 0 DMA status.

        BEQ     NCYCEXIT                  ; If DMA status is zero then the
                                          ;   Buffer 0 DMA cycle has finished.
                                          ;   Jump to the exit processing for
                                          ;   normal events.

        SUBI.L  #$1,D4                    ; DMA cycle has not finished.
                                          ;   Decrement its time out counter.
        BNE     CHKDMA0                   ; Not timed out, check status again.
        PEA.L   GiveUp0                   ; Timed out, Push message on stack.
        JSR     ChrStrgOut                ; Display Buf 0 DMA time out message
        JMP     NCYCEXIT                  ; Jump to the exit processing for
                                          ;   normal events.


*************************************************************************
*                                                                       *
*  Cyclic Section:  Service Data Block for Normal Events, use Buffer 1  *
*                                                             --------  *
*  If VBD buffer 1 has been selected for the transfer of this event     *
*  then this section takes care of testing that buffer 1 is connected   *
*  to the VME port and that it is not currently running a DMA cycle.    *
*  If everything is OK then a DMA cycle will be started to move VME     *
*  data into buffer 1.                                                  *
*                                                                       *
*  If it is found that buffer 1 is either connected to the external     *
*  port or that buffer 1 is already doing a DMA cycle then the program  *
*  will jump to test the status of buffer 0 and try to use it.  If the  *
*  program has already tested both buffers many times ( > BBSMAXWAIT )  *
*  and has not found a free buffer, then it will branch to BBSTMOUT.    *
*                                                                       *
*  Once the DMA operation is started on buffer 1, a short message,      *
*  "1", will be sent to the 68020 console.                              *
*                                                                       *
*  Next the program will test for the completion of the DMA cycle on    *
*  buffer 1.  If the DMA cycle completes in less than about 1/2 second  *
*  then everything is normal and execution proceeds to the NCYCEXIT     *
*  section.  If the DMA cycle does not complete within the 1/2 second   *
*  then an error message is displayed and then execution proceeds to    *
*  the NCYCEXIT section.                                                *
*                                                                       *
*************************************************************************

          ALIGN   4                       ; Align to Longword Address.

USEBUF1   CLR.L  D0                       ; Clear all bits in data reg 0.
          MOVE.W  VBDCSR2,D0              ; Move the VBD CSR2 into D0.
          AND.L   MskBuf1Sta,D0           ; Mask all but the Buf 1 DMA and
                                          ;   Buf 1 port status bits.
          BEQ     BUF1RDY                 ; If both CSR bits are 0 then,
                                          ;   Buffer 1 is ready to use.
                                          ; Else
          SUBI.L  #$1,D4                  ; Decrement the max wait counter
                                          ;   for finding a free VBD buffer.
          BEQ     BBSTMOUT                ; If time is up and no free buffer
                                          ;   found then branch to time out.
                                          ; If max wait is not used up then
          JMP     USEBUF0                 ; Try to use buffer 0 it may
                                          ;   be free.

BUF1RDY   MOVE.W  Buf1DMAGo,VBDCSR0       ; Start the DMA running into Buf 1.

                                            ; Send out the one character
Chk31TxRDY    Move.B   AdrTxStat,D4         ; message "1"  --> VBD buffer #1.
              ANDI.L   #$00000080,D4        ; Read MFP Transmitter Status Reg.
              IF.B  D4 <NE> #$80  THEN.S    ; Mask all but Tx Buffr Empty Bit.
                JMP  Chk31TxRDY             ; Test if Buffer Empty bit is set,
              ENDI                          ; i.e. ready to send next charctr?
              Move.B   #$31,AdrTxBufr       ; Keep testing as needed.   Load
                                            ; character "1" into Tx Buffer.

        MOVE.L  WaitDMA,D4                ; Initialize the register to wait
                                          ;  for the DMA cycle to finish.

         CLR.L  D0                        ; Clear all bits in data reg 0.
CHKDMA1  MOVE.W  VBDCSR2,D0               ; Move the VBD CSR2 into D0.
         AND.L   MskBuf1DMA,D0            ; Mask all but the Buf 1 DMA status.

        BEQ     NCYCEXIT                  ; If DMA status is zero then the
                                          ;   Buffer 1 DMA cycle has finished.
                                          ;   Jump to the exit processing for
                                          ;   normal events.

        SUBI.L  #$1,D4                    ; DMA cycle has not finished.
                                          ;   Decrement its time out counter.
        BNE     CHKDMA1                   ; Not timed out, check status again.
        PEA.L   GiveUp1                   ; Timed out, Push message on stack.
        JSR     ChrStrgOut                ; Display Buf 1 DMA time out message
        JMP     NCYCEXIT                  ; Jump to the exit processing for
                                          ;   normal events.

*************************************************************************
*  Cyclic Section:          END of service for normal events.           *
*                                                                       *
*  The VBD DMA cycle has finished  (or timed out).  The VBD may still   *
*  be doing the transfer to L2 but, COMINT may access the MVME-214      *
*  memory again when it is ready to.                                    *
*                                                                       *
*  Because the VBD DMA operation has finished,  send a Data Cable       *
*  Driver Finished signal to the COMINT.                                *
*                                                                       *
*  If the program gets here then it is not stuck waiting for a Slave    *
*  Ready and it did find a VBD buffer to use to transfer the L1 Data    *
*  Block to Level 2,  thus we need to clear the No Slave Readies Seen   *
*  bit and the Can Not Transfer to L2 Because Both VBD Buffers Stuck    *
*  bit from the byte of Trouble Warning Bits.                           *
*                                                                       *
*  If there has been a long time since the last event (i.e. transfer    *
*  to Level 2) then this section will send a detailed message to the    *
*  68k's terminal screen.                                               *
*                                                                       *
*  Return to the begining of the Cyclic Section.                        *
*                                                                       *
*************************************************************************

          ALIGN   4                         ; Align to Longword Address.

NCYCEXIT  MOVE.B  #Bit1High,D0              ; Send a Data Cable Driver
          WRIO    D0,DCDrFin                ;   Finished signal to COMINT.

HISTIL  RDIO    SlvRdy                      ; Look for the Slave Ready.
        BEQ     HISTIL                      ; If it is still high then keep
                                            ;   waiting until it drops then.

        MOVE.B  #AllBitsLow,D0              ; Drop the Data Cable Driver
        WRIO    D0,DCDrFin                  ;   Finished signal.

        MOVE.B  TWBData,D0             ; Clear the No Slave Readies Seen bit,
        ANDI.B  #$F2,D0                ;   the Can Not Transfer to Level 2
        MOVE.B  D0,TWBData             ;   bit, and the VME Not Running bit
        WRIO    D0,TWBPortAdrs         ;   in the Trouble Warning Bits.
                                       ;   Send the new TWB's out their port.

        MOVE.L  SRLoopCnt,D0                ; Move loop count of how long of
                                            ;   a wait for Slave Ready to D0.
        SUB.L   SRMinDisp,D0                ; Subtract the minimum wait for a
                                            ;   full display from the wait.
        BMI     Begin_CYCLIC                ; The result is negative --> not a
                                            ;   long enough wait for Sl Rdy -->
                                            ;   high transfer rate --> no time
                                            ;   to send full display --> start
                                            ;   waiting for the next Slave Rdy.

                                            ; The transfer rate is low so there
                                            ;   is enough time to send a full
                                            ;   display.

        PEA.L   TransInfo1                  ; The first part of the Transfer
        JSR     ChrWrtOut                   ; Information message.

        MOVE.L  TrgNumStore,D0              ; Recall the 16 bit trigger number.
        AND.L   Low4Long,D0                 ; Mask off the part of the Evt Num
        Move.L  D0,-(A7)                    ; that is not sync bits.  Push it.
        JSR     BinASCII                    ; Convert to ASCII and send it out.

        PEA.L   TransInfo2                  ; The second part of the Transfer
        JSR     ChrWrtOut                   ; Information message

        MOVE.L  TrgsFired,D0                ; Get the Spec Trig's Fired data.

        FOR.L  TransInfo5 = #1 TO #8  DO.S    ; Loop for all 8 characters of
           ROL.L   #4,D0                      ; the Spec Trig Fired.  Rotate
           Move.L  D0,-(A7)                   ; left into position and push.
           JSR     BinASCII                   ; Convert to ASCII and send out.
        ENDF

        PEA.L   TransInfo3                  ; The third and last part of msg.
        JSR     ChrStrgOut                  ; System Call, write data message.


        IF.L  GetCAMACError <EQ> #0  THEN.S  ; Display a message to indicate if
           PEA.L  MsgCAMACOK                 ; the CAMAC read went OK.   If the
           JSR    ChrStrgOut                 ; flag  GetCAMACError  is zero
        ELSE                                 ; then the CAMAC read had no bus
           PEA.L  MsgCAMACBad                ; errors.  If the flag is non-zero
           JSR    ChrStrgOut                 ; then there was a bus error
        ENDI                                 ; during the CAMAC read.


        IF.L  GetCentPulsEr <NE> #0  THEN.S  ; If neither bus error flag was
           JMP CEPPR                         ; set while reading the Pulser
        ENDI                                 ; Programing Data then send a
                                             ; pulser data OK message.
        IF.L  GetCalPulsErr <NE> #0  THEN.S  ; Check the Central Detector
           JMP CEPPR                         ; flag and then the Calorimeter
        ENDI                                 ; detector flag.

        PEA.L  MsgPulserOK                   ; Pulser programming data
        JSR    ChrStrgOut                    ; read OK message.

CEPPR   IF.L  GetCentPulsEr <NE> #0  THEN.S  ; There was a bus error while
           PEA.L  MsgCentErr                 ; reading Central Detector Pulser
           JSR    ChrStrgOut                 ; Programming Data so send out
        ENDI                                 ; an error message.

        IF.L  GetCalPulsErr <NE> #0  THEN.S  ; There was a bus error while
           PEA.L  MsgCalPErr                 ; reading the Calorimeter Pulser
           JSR    ChrStrgOut                 ; Programming Data so send out
        ENDI                                 ; an error message.


        PEA.L   DCDFHI                      ; Push Transfer Finished on stack.
        JSR     ChrStrgOut                  ; System Call, write message.

        JMP     Begin_CYCLIC                ; Return to the start of the
                                            ;   cyclic section.

***************************************************************************
*  Cyclic Section:   END because of time out looking for a free buffer.   *
*                                                                         *
*  A free VBD Buffer was not found within the maximum wait time (number   *
*  of test loops).  Both buffers must be stuck waiting to transfer on     *
*  the Data Cable.                                                        *
*    Send a warning - status message to the 68020 console.                *
*    Send a Data Cable Driver Finished signal to the COMINT card.         *
*    Set the bit in the Trouble Warning Bits that indicates to            *
*      monitoring that L1 can not transfer Data Blocks to Level 2         *
*      because both of the VBD buffers are stuck.                         *
*  Then return to the begining of the cyclic section.                     *
*                                                                         *
***************************************************************************

          ALIGN   4                         ; Align to Longword Address.

BBSTMOUT  PEA.L    BBSTMMSG1                ; push message 1 address on stack.
          JSR      ChrStrgOut               ; and send it out.
          PEA.L    BBSTMMSG2                ; push message 2 address on stack.
          JSR      ChrStrgOut               ; and send it out.

        MOVE.B  #Bit1High,D0                ; Send a Data Cable Driver
        WRIO    D0,DCDrFin                  ;   Finished signal to COMINT.

LTSRHI  RDIO    SlvRdy                      ; Look for the Slave Ready.
        BEQ     LTSRHI                      ; If it is still high then keep
                                            ;   waiting until it drops then.

        MOVE.B  #AllBitsLow,D0              ; Drop the Data Cable Driver
        WRIO    D0,DCDrFin                  ;   Finished signal.

        MOVE.B  TWBData,D0             ; Set the Can Not Transfer to Level 2
        ORI.B   #$04,D0                ;   bit in the Trouble Warning Bits to
        MOVE.B  D0,TWBData             ;   flag the problem for monitoring.
        WRIO    D0,TWBPortAdrs         ;   Send the new TWB's out their port.

        JMP     Begin_CYCLIC                ; Return to the start of the
                                            ;   cyclic section.
                                            ; End of cyclic processing routine.



***************************************************************************
*   This routine is used to output a character string WITH carriage       *
*   return line feed through the MVME133A-20  front panel debug port.     *
*                                                                         *
*                                                          17-SEPT-1991   *
*                                                                         *
*   This routine sends an ASCII character string out through the          *
*   MVME133A-20  RS-232 front panel debug port.  A carriage return and    *
*   line feed is inserted at the end of the string.   This routine is     *
*   the same as the 133A Bug Monitor  WRITELN routine.                    *
*                                                                         *
*   The begining address of the character string is passed to this        *
*   routine on the stack.  The first byte is this string shows the        *
*   the number of caracters to be printed as a binary number 0...255.     *
*   This first byte is not sent out the debug port. To call this routine  *
*   first push the character string's starting address onto the stack as  *
*   a long word.  All working registers used by this routine are saved    *
*   and restored before the routine exits.  The parameter that is passed  *
*   to this routine on the stack is pulled off of the stack before this   *
*   routine exits.                                                        *
***************************************************************************

            Align 4

ChrStrgOut  Move.L  A5,-(A7)             ; Store the contents of register A5.
            Move.L  A6,-(A7)             ; Store the contents of register A6.
            Move.L  D0,-(A7)             ; Store the contents of register D0.

            MoveA.L  16(A7),A5           ; Load the starting address into A5.
            MoveA.L  A5,A6               ; Copy the starting address into A6.
            CLR.L    D0                  ; Clear Data Register D0.
            Move.B   (A5)+,D0            ; Get the Number of Characters in D0.
            AddA.L   D0,A6               ; Add the string length to reg A6.
                                         ; A6 now points to the last character.
            CLR.L    D0                  ; Clear Data Register D0.

ChkLstChar   IF.L  A5 <LE> A6  THEN.S         ; If past last character,.. quit
               Move.B  (A5)+,D0               ; Get the character into reg D0.
               Move.L  D0,-(A7)               ; Push contents on D0 onto stack.
               JSR     SendCharP1             ; Call routine to send character.
               JMP     ChkLstChar             ; Check for the last character.
             ENDI

            Move.B  #$0D,D0              ; Load the carriage return character
            Move.L  D0,-(A7)             ; into D0 and push D0 onto the stack.
            JSR     SendCharP1           ; Call routine to send character.

            Move.B  #$0A,D0              ; Load the line feed character
            Move.L  D0,-(A7)             ; into D0 and push D0 onto the stack.
            JSR     SendCharP1           ; Call routine to send character.

            Move.L  (A7)+,D0            ; Restore the contents of register D0.
            Move.L  (A7)+,A6            ; Restore the contents of register A6.
            Move.L  (A7)+,A5            ; Restore the contents of register A5.

            Move.L  (A7),4(A7)          ; Move the RTS return pointer.
            AddQ.L  #4,A7               ; Adjust the stack position.
            RTS                         ; Return to the calling routine.


***************************************************************************
*   This routine is used to output a character string withOUT carriage    *
*   return line feed through the MVME133A-20  front panel debug port.     *
*                                                                         *
*                                                           23-OCT-1991   *
*                                                                         *
*   This routine sends an ASCII character string out through the          *
*   MVME133A-20  RS-232 front panel debug port.  This routine is the      *
*   same as the 133A Bug Monitor  WRITE routine.                          *
*                                                                         *
*   The begining address of the character string is passed to this        *
*   routine on the stack.  The first byte is this string shows the        *
*   the number of caracters to be printed as a binary number 0...255.     *
*   This first byte is not sent out the debug port. To call this routine  *
*   first push the character string's starting address onto the stack as  *
*   a long word.  All working registers used by this routine are saved    *
*   and restored before the routine exits.  The parameter that is passed  *
*   to this routine on the stack is pulled off of the stack before this   *
*   routine exits.                                                        *
***************************************************************************

            Align 4

ChrWrtOut   Move.L  A5,-(A7)             ; Store the contents of register A5.
            Move.L  A6,-(A7)             ; Store the contents of register A6.
            Move.L  D0,-(A7)             ; Store the contents of register D0.

            MoveA.L  16(A7),A5           ; Load the starting address into A5.
            MoveA.L  A5,A6               ; Copy the starting address into A6.
            CLR.L    D0                  ; Clear Data Register D0.
            Move.B   (A5)+,D0            ; Get the Number of Characters in D0.
            AddA.L   D0,A6               ; Add the string length to reg A6.
                                         ; A6 now points to the last character.
            CLR.L    D0                  ; Clear Data Register D0.

ChkLstWrt    IF.L  A5 <LE> A6  THEN.S         ; If past last character,.. quit
               Move.B  (A5)+,D0               ; Get the character into reg D0.
               Move.L  D0,-(A7)               ; Push contents on D0 onto stack.
               JSR     SendCharP1             ; Call routine to send character.
               JMP     ChkLstWrt              ; Check for the last character.
             ENDI

            Move.L  (A7)+,D0            ; Restore the contents of register D0.
            Move.L  (A7)+,A6            ; Restore the contents of register A6.
            Move.L  (A7)+,A5            ; Restore the contents of register A5.

            Move.L  (A7),4(A7)          ; Move the RTS return pointer.
            AddQ.L  #4,A7               ; Adjust the stack position.
            RTS                         ; Return to the calling routine.



***************************************************************************
*    This routine outputs a character through the front debug port.       *
*                                                           16-SEPT-1991  *
*                                                                         *
*    This routine sends an ASCII character out through the MVME133A-20    *
*    RS-232 front panel debug port.  The ASCII character is to be in      *
*    the LSB of a long word on the stack just above the return address.   *
*    This routine assumes that the MVME133A-20  MFP  MC68901 has already  *
*    been setup as required.  This routine is similar to the 133A Bug     *
*    Monitor OUTCHR routine.                                              *
*                                                                         *
*    All working registers are saved and have been restored before this   *
*    routine exits.  The long word passed to this routine is pulled from  *
*    the stack before this routine exits.                                 *
***************************************************************************

            Align 4

SendCharP1  Move.L   D1,-(A7)           ! Store the contents of register D1.

ChkTxRDY    Move.B   AdrTxStat,D1       ! Read the MFP Transmitter Status Reg.
            ANDI.L   #$00000080,D1      ! Mask all but the Buffer Empty Bit.

            IF.B  D1 <NE> #$80  THEN.S   ! Test if the Buffer Empty bit is set,
              JMP  ChkTxRDY              ! i.e.  is it ready to send the next
            ENDI                         ! character.  Keep testing as needed.

            Move.L   8(A7),D1           ! Get the character from the stack.
            Move.B   D1,AdrTxBufr       ! Load the character into Tx Buffer.

            Move.L   (A7)+,D1           ! Restore the contents of register D1.
            Move.L   (A7),4(A7)         ! Move the RTS return pointer.
            AddQ.L   #4,A7              ! Adjust the stack position.
            RTS                         ! Return to the calling routine.

            Align 4

AdrTxStat   EQU  $FFF8002D       ! Address of the MFP Transmitter Status Reg.
AdrTxBufr   EQU  $FFF8002F       ! Address of the MFP Transmitter Buffer Reg.



***************************************************************************
*   This routine is used to convert a 4 bit hex digit into ASCII and to   *
*   send it out through the MVME133A-20  front panel debug port.          *
*                                                                         *
*                                                           23-OCT-1991   *
*                                                                         *
*   This routine receives a longword on the stack.  It converts the least *
*   significant 4 bits into an ASCII character and sends this out through *
*   the front panel RS232 port withOUT a carriage return line feed.       *
*   All registers used are saved and restored before exit.  The longword  *
*   that this routine receives is pulled from the stack before exiting.   *
***************************************************************************

            Align 4

BinASCII    Move.L   D1,-(A7)           ! Store the contents of register D1.

            Move.L   8(A7),D1           ! Get the longword from the stack.
            AND.L    Low4Long,D1        ! Mask off all but the lowest 4 bits.

            IF.L  D1 <EQ> #$00000000  Then.S   ; Test for "zero".
                 Move.L   #$00000030,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000001  Then.S   ; Test for "one".
                 Move.L   #$00000031,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000002  Then.S   ; Test for "two".
                 Move.L   #$00000032,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000003  Then.S   ; Test for "three".
                 Move.L   #$00000033,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000004  Then.S   ; Test for "four".
                 Move.L   #$00000034,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000005  Then.S   ; Test for "five".
                 Move.L   #$00000035,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000006  Then.S   ; Test for "six".
                 Move.L   #$00000036,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000007  Then.S   ; Test for "seven".
                 Move.L   #$00000037,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000008  Then.S   ; Test for "eight".
                 Move.L   #$00000038,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$00000009  Then.S   ; Test for "nine".
                 Move.L   #$00000039,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000A  Then.S   ; Test for "A".
                 Move.L   #$00000041,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000B  Then.S   ; Test for "B".
                 Move.L   #$00000042,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000C  Then.S   ; Test for "C".
                 Move.L   #$00000043,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000D  Then.S   ; Test for "D".
                 Move.L   #$00000044,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000E  Then.S   ; Test for "E".
                 Move.L   #$00000045,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            IF.L  D1 <EQ> #$0000000F  Then.S   ; Test for "F".
                 Move.L   #$00000046,D1        ; Convert to ASCII.
                 JMP      ItHBCnvr             ; Send it out.
            ENDI                               ; Ready for next test.

            JMP   VSNAN                        ; Very Strange Not a Number.

ItHBCnvr    Move.L  D1,-(A7)             ; Push contents on D1 onto stack.
            JSR     SendCharP1           ; Call routine to send character.

VSNAN       Move.L   (A7)+,D1           ! Restore the contents of register D1.
            Move.L   (A7),4(A7)         ! Move the RTS return pointer.
            AddQ.L   #4,A7              ! Adjust the stack position.
            RTS                         ! Return to the calling routine.
                                        ! END of the BinASCII routine.


*************************************************************************
*  Define Constants:                                                    *
*                                                                       *
*  Data used to send messages to the 68k terminal screen.               *
*                                                                       *
*************************************************************************

              ALIGN   4                ; Align to Longword Address.

SRWaitMsg1    DC.B    43,$0D,$0A,'Slave Ready not seen within the max wait.'
SRWaitMsg2    DC.B    46,'Pulse the Data Cable Driver Finished signal.',$0D,$0A

MonMessage  DC.B  51,$0D,$0A,'Data Block with only Monitor Data not transfered.'

GiveUp0     DC.B    44,$0D,$0A,'The VBD Buffer 0 DMA cycle has timed out.',$0A
GiveUp1     DC.B    44,$0D,$0A,'The VBD Buffer 1 DMA cycle has timed out.',$0A

BBSTMMSG1     DC.B    36,$0D,$0A,'Both VBD Buffers are stuck waiting'
BBSTMMSG2     DC.B    31,'to transfer on the Data Cable.',$0A

TransInfo1    DC.B    14,$0D,$0A,'SYNC BITS = '
TransInfo2    DC.B    20,'  SPEC TRIG FIRED = '
TransInfo3    DC.B    2,'  '

              Align 4

TransInfo5    DS.L    1

DCDFHI        DC.B    19,'Transfer Finished',$0D,$0A

MsgCAMACOK    DC.B   13,'CAMAC Read OK'
MsgCAMACBad   DC.B   17,'CAMAC Read Failed'

MsgPulserOK   DC.B   14,'Pulser Read OK'
MsgCentErr    DC.B   25,'Central Pulser Read Error'
MsgCalPErr    DC.B   29,'Calorimeter Pulser Read Error'

*************************************************************************
*  Define Constants:                 External References                *
*                                                                       *
*************************************************************************

       XDEF   Begin_Cyclic                          ; Export this symbol
                                                    ; to other modules.

       XREF   SlvRdy,SRMaxWait,Bit1High,DCDrFin     ; Symbols referenced
       XREF   AllBitsLow,BufSelect,SRLoopCnt        ; in this program
       XREF   TrgFire,TrgsFired,MskMonSpTrg         ; module but defined
       XREF   TrgNum,EvtNmbAdr133,TrgNumStore       ; in another module
       XREF   CrtHDWord1,CrtHDWord5                 ; Main_Symbols.Include
       XREF   BBSMaxWait,MskBuf0Sta,MskBuf1Sta
       XREF   VBDCSR0,VBDCSR2,WaitDMA
       XREF   MskBuf0DMA,MskBuf1DMA
       XREF   Buf0DMAGo,Buf1DMAGo
       XREF   SRMinDisp,Low4Long
       XREF   Begin_Move_Data,Begin_Spec_Trig_Prog_Fire
       XREF   Begin_EM_Jet_List,Begin_TEt_Jet_List
       XREF   Begin_Get_CD_Pulser,Begin_Get_Calo_Pulser
       XREF   Begin_Get_CAMAC
       XREF   BAPulser,BACAMAC,GetCAMACError
       XREF   GetCentPulsEr,GetCalPulsErr
       XREF   TWBData,TWBPortAdrs

       END

