;*************************** AMUS Program Label ******************************
; Filename: PROGS.SBR Date: 12/12/90
; Category: UTIL Hash Code: 655-435-373-670 Version: 1.1(101)
; Initials: ULTR/US Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOSL 1.3B/AMOS32 1.0 Expertise Level: BEG
; Special:
; Description: Return program names (and, optionally, job names) to BASIC
!*****************************************************************************
;****************************************************************************
;* *
;* PROGS.SBR *
;* AlphaBASIC XCALL to return program names of all jobs on the system *
;* *
;****************************************************************************
;Copyright (C) 1990 UltraSoft Corporation. All Rights Reserved.
;
; MAP1 JOB'COUNT, F, 6
; MAP1 PROG'NAME(x), S, 6
; MAP1 JOB'NAME(x), S, 6 <- optional
; ...
; XCALL PROGS, JOB'COUNT, PROG'NAME(1) {,JOB'NAME(1)}
;
; sets JOB'COUNT to the number of jobs on the system
; returns PROG'NAME(1) through PROG'NAME(JOB'COUNT) with program names
;
; if specified, JOB'NAME(1) through JOB'NAME(JOB'COUNT) receives the
; name of each job. This third parameter is optional.
;
;Written by: David Pallmann
;
;Edit History:
;1.0(100) 29-Aug-90 created. /DFP
;1.1(101) 12-Dec-90 add optional third argument to return job names. /DFP
CHECK: CMPW X.ARGS(A3),#2 ; 2 or more arguments supplied? [101]
JLO CNTERR ; no - error [101]
CMPW X.TYP1(A3),#X.FLT ; arg 1 floating point?
JNE TYPERR ; no - error
MOVW X.TYP2(A3),D7 ; get 2nd argument type
ANDW #^C<X.ARY>,D7 ; clear array bit
CMPW D7,#X.STR ; arg 2 string?
JNE TYPERR ; no - error
CMPW X.ARGS(A3),#3 ; are there 3 arguments?
BLO 10$ ; no
MOVW X.TYP3(A3),D7 ; get 3rd argument type
ANDW #^C<X.ARY>,D7 ; clear array bit
CMPW D7,#X.STR ; arg 3 string?
JNE TYPERR ; no - error
MOV X.ADR3(A3),A4 ; set index A4
;index job table, initialize job count, and set index to array
10$: MOV JOBTBL,A0 ; index jobn table
CLR D5 ; clear job count
MOV X.ADR2(A3),A2 ; index return array
;main loop of program
LOOP: MOV (A0)+,D7 ; get next JCB address
BEQ LOOP ; deallocated job
CMP D7,#-1 ; end of job table?
JEQ RETURN ; yes
MOV D7,A6 ;
INC D5 ; update job count
;check for job at AMOS command level
MOV A6,D4 ; save JCB address for later
MOVW JOBSTS(A6),D6 ; get job status
ANDW #J.MON,D6 ; at AMOS command level?
BNE CLRPRG ; yes - return empty string
;convert program name to ASCII
LEA A1,JOBPRG(A6) ; index program name
UNPACK ; return
UNPACK ; program name
CALL TRIM ; remove trailing spaces [101]
BR CHKJOB ; [101]
SAVE A2 ; save registers [101]
MOV A4,A2 ; set-up A2 for UNPACKing [101]
MOV D4,A6 ; restore JCB address [101]
LEA A1,JOBNAM(A6) ; index program name [101]
UNPACK ; return [101]
UNPACK ; program name [101]
CALL TRIM ; remove trailing spaces [101]
MOV A2,A4 ; put back in A4 so we remember [101]
REST A2 ; restore registers [101]