
Get_Time      IDNT                            ; Title Get Absolute Time.

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

***************************************************************************
*   Get Time                                     Rev.   5-MAY-1992        *
*                                                                         *
***************************************************************************


***************************************************************************
*                                                                         *
*  Clear the error flag.  This flag will be set to a non-zero value if    *
*  any of the read Absolute Time VME cycles time out and the bus error    *
*  exception handler is called.                                           *
*                                                                         *
*  Change the Bus Error Vector to point to our own Bus Error exception    *
*  handler.   This routing starts at BUSEREXHD.                           *
*                                                                         *
*  The location in the L1 Data Block where the Absolute Time data is to   *
*  be stored is passed to this routine in register A0.                    *
***************************************************************************

Begin_Get_Time    CLR.L  GetTimeError           ; Clear the Initialize Time
                                                ; Error Flag.  If this flag
                                                ; .NEQ. zero than there has
                                                ; been a read Time error.

       MOVE.L   #BUSEREXHD,$00000008            ; Point the Bus Error vector
                                                ; to our exception handler.

*****************************************************************************
*                                                                           *
*  Do the work to read the Absolute Time from the Front-End crate.          *
*                                                                           *
*****************************************************************************

       Move.L   RdTimeBA,D1                  ; Read the two longwords
       Move.L   RdTimeBA+4,D2                ; of Absolute Time data.


*****************************************************************************
*                                                                           *
*  We are finished reading the time so restore the normal 133A Bug          *
*  Bus Error Vector.                                                        *
*****************************************************************************

       MOVE.L  #$FFF149E2,$00000008          ; Restore normal 133A Bug
                                             ;  Bus Error vector.

*****************************************************************************
*                                                                           *
*  Now put the Absolute Time data into the L1 Trigger Data Block.           *
*                                                                           *
*****************************************************************************

       Swap     D1                           ; Build the Absolute Time data
       Swap     D2                           ; that is in the proper byte
                                             ; order for Fritz Bartlett's time
                                             ; conversion routines on either
                                             ; VMS or ELN VAX's.   i.e. Swap
                                             ; the words in each longword.

       Move.L    D1,(A0)+                    ; Store the Absolute Time
       Move.L    D2,(A0)                     ; in the L1 Data Block.


       RTS                                   ; Now return from the
                                             ; Initialize Time Routine.


*************************************************************************
*  Bus Error Exception Handler for Initialize Time.                     *
*                                                                       *
*  Mask the rerun bit in the Special Status Word,  then set the Time    *
*  Error Flag,  and then Return.                                        *
*************************************************************************

BUSEREXHD  MOVE.W  (SP)+,D0                ; pull the Status Register
           MOVE.L  (SP)+,D1                ; pull the Program Counter
           MOVE.W  (SP)+,D2                ; pull the Format - Vector Offset
           MOVE.W  (SP)+,D3                ; pull the Internal Register
           MOVE.W  (SP)+,D4                ; pull the Special Status Register

           ANDI.W  #$FEFF,D4               ; Mask the rerun bus cycle bit

           MOVE.W  D4,-(SP)                ; push the Special Status Register
           MOVE.W  D3,-(SP)                ; push the Internal Register
           MOVE.W  D2,-(SP)                ; push the Format - Vector Offset
           MOVE.L  D1,-(SP)                ; push the Program Counter
           MOVE.W  D0,-(SP)                ; push the Status Register

           MOVE.L  #$FF,GetTimeError       ; Set the Time Error Flag.

           CLR.L   D1                      ; Zero both longwords of
           CLR.L   D2                      ; Absolute Time data.


           RTE                             ; Return to the calling routine.


***************************************************************************
*                                                                         *
*   Constants Section for  Get Time                                       *
*                                                                         *
***************************************************************************

       XDEF   Begin_Get_Time                  ; Export this symbol
                                              ; to other modules.

       XREF   GetTimeError                    ; Import these symbols from
       XREF   RdTimeBA                        ; the main symbol include file.


                 END

