;*************************** AMUS Program Label ******************************
; Filename: P.M68                                           Date: 10/31/91
; Category: UTIL         Hash Code: XXX-XXX-XXX-XXX      Version: 1.0(100)
; Initials: ULTR/US      Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION                   Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOSL 1.0/AMOS32 1.0          Expertise Level: INT
; Special: To assemble: .M68 P
; Description: Like PRINT/PRNT; figures out which spooler type is running.
;*****************************************************************************

;****************************************************************************
;*                                                                          *
;*                                    P                                     *
;*    Performs functions of PRINT and PRNT - works with either spooler      *
;*                                                                          *
;****************************************************************************
;[100] 31 October 1991 21:33    Edited by David Pallmann
;       Created.

;version number

       VMAJOR  =1
       VMINOR  =0
       VSUB    =0
       VEDIT   =100.
       VWHO    =0

;universals

       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  TRM

;***********
;*  START  *
;***********
;initialization

START:  PHDR    -1,0,PH$REE!PH$REU      ; program header
       GETIMP  200.,A5                 ; get command line buffer

;************
;*  BRANCH  *
;************
;determine printer type and branch to appropriate handerl

BRANCH: TST     LPTQUE                  ; is memory-based spooler in use?
       BEQ     TASK.MANAGER            ;   no - task manager spooler

;******************
;*  MEMORY.BASED  *
;******************
;for memory based spooler we use the PRINT command

MEMORY.BASED:
       MOV     A5,A0                   ; begin setting up command line
       MOVB    #'P,(A0)+               ;
       MOVB    #'R,(A0)+               ;
       MOVB    #'I,(A0)+               ;
       MOVB    #'N,(A0)+               ;
       MOVB    #'T,(A0)+               ;
       MOVB    #40,(A0)+               ;
       BR      FINISH.COMMAND.LINE     ; go copy rest of command line

;******************
;*  TASK.MANAGER  *
;******************
;for task manager spooler we use the PRNT command

TASK.MANAGER:
       MOV     A5,A0                   ; begin setting up command line
       MOVB    #'P,(A0)+               ;
       MOVB    #'R,(A0)+               ;
       MOVB    #'N,(A0)+               ;
       MOVB    #'T,(A0)+               ;
       MOVB    #40,(A0)+               ; go copy rest of command line

;*************************
;*  FINISH.COMMAND.LINE  *
;*************************
;Finish command line currently indexed by A0
;Copy command line to terminal input line buffer
;Execute PRINT or PRNT command that we have constructed and exit

FINISH.COMMAND.LINE:
10$:    MOVB    (A2)+,(A0)+             ; copy command line character
       BNE     10$                     ;   loop until null encountered
       JOBIDX  A3                      ; index job control block
       MOV     JOBTRM(A3),A4           ; index terminal control block
       MOV     T.ILB(A4),A2            ; index terminal input line buffer
       MOV     A5,A0                   ; index our command line
20$:    MOVB    (A0)+,(A2)+             ; set command line
       BNE     20$                     ;   into terminal input buffer
       MOV     T.ILB(A4),A2            ; index command to execute with A2
       AMOS                            ; go execute it
       EXIT                            ; exit to AMOS command level

       END