Trailing-Edge
-
PDP-10 Archives
-
CFS_TSU04_19910205_1of1
-
update/t20src/comand.mac
There are 11 other files named comand.mac in the archive. Click here to see a list.
;GREEN:<ZBRAD.20784>COMAND.MAC.2 9-Jan-86 11:32:46, Edit by MERRILL
;EDIT 41, If user types REENTER, give them a reasonable error message.
TITLE COMAND - COMMAND LINE PROCESSOR
;EDT$COMMAND
;IDENT = 1-005
;
; COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1983, 1988 ALL RIGHTS RESERVED.
;
; THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
; ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE
; INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER
; COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
; OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY
; TRANSFERRED.
;
; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
; AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
; CORPORATION.
;
; DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
;
;++
; FACILITY: EDT -- THE DEC STANDARD EDITOR
;
; ABSTRACT:
;
; This module does the result parsing of the EDIT or EDT command.
;
; ENVIRONMENT: TOPS-20 only
;
; AUTHOR: Chris Gill, Creation date: 24-Jan-1983
;
; MODIFIED BY:
; 1-001 - Original. CJG 24-Jan-1983
; 1-002 - Add fixes for using rescan and recognition. CJG 20-Jun-1983
; 1-003 - Change the way that filespecs are handled. CJG 22-Jun-1983
; 1-004 - Fix parsing of rescan text to allow CREATE etc. CJG 6-Jul-1983
; 1-005 - Fix parsing again because of funny prompting and defaults. CJG 12-Oct-1983
; 1-006 - Make some changes for the TRACE facility. CJG 21-Dec-1983
;--
SUBTTL DECLARATIONS
SALL
LOC 124 ;[41] loc to .JBREN
EXP EDTREN ;[41]
TWOSEG
RELOC 0
;
; TABLE OF CONTENTS:
;
INTERN COMAND
;
; INCLUDE FILES:
;
SEARCH MACSYM
SEARCH MONSYM
;
; MACROS:
;
DEFINE TAB(KEY,VAL<0>)<
[ASCIZ \KEY\],,VAL
>
DEFINE COMND$(ARG)<
MOVEI A,CSB
MOVEI B,FDB'ARG
COMND
ERJMP ERROR
>
;
; EQUATED SYMBOLS:
;
A=1 ;Register names
B=2
C=3
D=4
E=5
F=6
P=17
;
; EXTERNAL REFERENCES:
;
EXTERN INPNAM ;CINP_NAM Input file name pointer
EXTERN OUTNAM ;COUT_NAM Output file name pointer
EXTERN CMDNAM ;CCMD_NAM Command file name pointer
EXTERN JOUNAM ;CJOU_NAM Journal file name pointer
EXTERN OPTION ;OPTIONS Options mask
EXTERN GETFSP ;EDT$$GET_FILESPEC Split filespec
EXTERN GTJBLK ;GETJFN_BLOCK
EXTERN $TRACE ; Trace routines
;
; FLAG DEFINITIONS FOR OPTIONS WORD
;
OP%REC=1B35 ;/RECOVER
OP%COM=1B34 ;/COMMAND
OP%NJO=1B33 ;/NOJOURNAL
OP%NOU=1B32 ;/NOOUTPUT
OP%NCM=1B31 ;/NOCOMMAND
OP%NCR=1B30 ;/NOCREATE
OP%NEW=1B29 ;CREATE command
;
; OFFSETS INTO FILE DESCRIPTOR BLOCKS (SEE EDTREQ.REQ)
;
D$LENG=0
D$ADRS=0
D$JFN=1
D$DEV=2
D$DIR=3
D$NAME=4
D$EXTN=5
;
; OWN STORAGE:
;
; COMMAND STATE BLOCK
CSB:
CM%XIF+REPARS ;Reparse address
.PRIIN,,.PRIOU ;JFN's
0 ;Prompt text pointer
POINT 7,TEXTBF ;Pointer to text buffer
POINT 7,TEXTBF ;Pointer to next segment
TXTBFL ;Length of text buffer
TXTBFL
POINT 7,ATOM ;Pointer to atom buffer
ATOMLN ;Length of atom buffer
GTJBLK ;GTJFN block
;
; FUNCTION BLOCKS
;
FDBINI: FLDDB. .CMINI
FDBCMD: FLDDB. .CMKEY,<CM%SDH>,EDTABL ;Command keyword
FDBCMI: FLDDB. .CMIFI,,,,,FDBCMX ;Input filespec, Output if not found
FDBCMX: FLDDB. .CMOFI ;In case of CREATE
FDBCMN: FLDDB. .CMNOI,,<POINT 7,[ASCIZ /OUTPUT AS/]>
FDBCMO: FLDDB. .CMFIL,,,,,FDBCMS ;Output filespec
FDBCMS: FLDDB. .CMSWI,,SWTABL,,,FDBCMC ;Switches
FDBCMC: FLDDB. .CMCFM,CM%SDH
FDBFIL: FLDDB. .CMFIL,,,,,FDBCMC ;Filespecs in switches
FDBFLD: FLDBK. .CMFLD,,,,,FLDBRK ;Trace routine
FDBCOL: FLDDB. .CMTOK,,<POINT 7,[ASCIZ /:/]>
FDBNUX: FLDDB. .CMNUX,,^D10 ;Number of stack items
FLDBRK: BRMSK. FLDB0.,FLDB1.,FLDB2.,FLDB3.,<%$_>
;
; INITIAL COMMAND TABLE
;
EDTABL: EDTL,,EDTL
TAB <CREATE>,<OP%NEW>
TAB <EDIT>,<0>
TAB <EDT>,<0>
TAB <MAKE>,<OP%NEW> ;Well, you never know!!
EDTL=.-EDTABL-1
;
; SWITCH TABLE
;
SW%FIL==1B19 ;Switch takes a filespec
SW%NOT==1B20 ;'NO' prefix
SW%COM==0 ;/[NO]COMMAND
SW%JOU==1 ;/[NO]JOURNAL
SW%OUT==2 ;/[NO]OUTPUT
SW%REA==3 ;/[NO]READONLY
SW%REC==4 ;/[NO]RECOVER
SW%CRE==5 ;/[NO]CREATE
SW%TRC==6 ;/TRACE
SWTABL: SWTL,,SWTL
TAB <COMMAND>,<SW%FIL+SW%COM>
TAB <CREATE>,<SW%CRE>
TAB <JOURNAL>,<SW%FIL+SW%JOU>
TAB <NOCOMMAND>,<SW%NOT+SW%COM>
TAB <NOCREATE>,<SW%NOT+SW%CRE>
TAB <NOJOURNAL>,<SW%NOT+SW%JOU>
TAB <NOOUTPUT>,<SW%NOT+SW%OUT>
TAB <NOREADONLY>,<SW%NOT+SW%REA>
TAB <NORECOVER>,<SW%NOT+SW%REC>
TAB <OUTPUT>,<SW%FIL+SW%OUT>
TAB <READONLY>,<SW%REA>
TAB <RECOVER>,<SW%REC>
XTRACE,,SW%TRC
SWTL=.-SWTABL-1
XTRACE: CM%FW!CM%INV
ASCIZ /TRACE/
;
; TEXT AND ATOM BUFFERS
;
TEXTBF:
BLOCK ^D40 ;Text buffer
TXTBFL=<.-TEXTBF>*5
ATOM:
BLOCK ^D20 ;Atom buffer
ATOMLN=<.-ATOM>*5
;
; Miscellaneous storage
;
CMDOPT: BLOCK 1 ;Implied options in command
TRACEX: BLOCK 1 ;Set if /TRACE used
TRCSTK: BLOCK 1 ;Set when trace file must be opened
SUBTTL SY%GCO - GET COMMAND LINE
RELOC 400000
;[41] Routine to handle REENTER command
EDTREN: MOVEI 1,.PRIOU ;[41] SEND IT TO TTY
HRROI 2,[ASCIZ/?Cannot REENTER EDT
/] ;[41] PICK UP MESSAGE
SETZ 3, ;[41] TERMINATE ON NULL
SOUT ;[41] TELL USER
HALTF ;[41] HALT US
JRST .-1 ;[41] CONTINUE WILL JUST LOOP TO HALT
;++
; FUNCTIONAL DESCRIPTION:
;
; This routine parses the EDT command line returning the following information:
;
; The input file name.
;
; The output file name.
;
; Whether or not journalling is specified and the explicit name if given.
;
; Whether or not a command file was specified and the specific name if given.
;
; FORMAL PARAMETERS:
;
; NONE
;
; IMPLICIT INPUTS:
;
; NONE
;
; IMPLICIT OUTPUTS:
;
; INPNAM - Input name block
; OUTNAM - Output name block
; CMDNAM - Command name block
; JOUNAM - Journal name block
;
; ROUTINE VALUE
;
; NONE
;
; SIDE EFFECTS:
;
; Implicitly calls other routines in this module.
;
;--
COMAND:
SETZM CMDOPT ;Force all flags off
CALL CMDINI ;Init this routine
SETZM INPNAM+D$JFN
SETZM OUTNAM+D$JFN
SETZM JOUNAM+D$JFN
SETZM CMDNAM+D$JFN
MOVEI A,.RSINI
RSCAN ;Get the rescan buffer
JFCL ; Don't care if empty etc.
JUMPE A,SYG.1 ;If empty then prompt for input
MOVE A,[POINT 7,[0]] ;Set up a dummy ^R pointer
MOVEM A,CSB+.CMRTY ;So that we don't prompt the rescan
COMND$ INI ;Init the COMND JSYS
COMND$ CMD ;Parse the command line
TXNE A,CM%NOP ;If the command didn't parse
JRST SYG.1 ; Then request a filespec
HRRZ B,(B) ;Get flags
MOVEM B,OPTION ;Save the CREATE flag if set
MOVEM B,CMDOPT ;Also save as implied flag
TXNN A,CM%EOC ;If just EDIT or EDT etc.
JRST SYG.2 ; Then prompt normally
SYG.1: ;Prompt for the file specs
MOVE A,[POINT 7,[ASCIZ /File: /]]
MOVEM A,CSB+.CMRTY ;Set up the prompt
COMND$ INI ;Init the COMND JSYS
SYG.2: ;Main loop for files and switches
SKIPE CMDOPT ;If CREATE
JRST [COMND$ CMX ; Then look for an output file
TXNE A,CM%NOP
JRST INVCMD
JRST SYG.3] ;And continue lower down
COMND$ CMI ;Get the input filespec
TXNE A,CM%NOP ;If it didn't parse
JRST INVCMD ; Then tell him
PUSH P,A ;Save for checks
PUSH P,B
MOVEI A,INPNAM
PUSH P,A
CALL GETFSP ;Sort out the filespec
ADJSP P,-2
POP P,A ;Restore the flags
TXNE A,CM%EOC ;If <CR> ended the field
JRST SYG.7 ; Then exit from here
;Look for output filespec or switches
COMND$ CMN ;See if there's a guide word
TXNE A,CM%NOP
JRST INVCMD ; Invalid
CALL SWDF2 ;Set default for output filespec
COMND$ CMO
TXNE A,CM%NOP
JRST INVCMD ; Invalid
HRRZS C ;Get the FDB address
CAIN C,FDBCMC ;Was it confirm?
JRST SYG.7 ; Yes
CAIN C,FDBCMS ;Was it a switch?
JRST SYG.5 ; Yes
SYG.3: ;Here from CREATE parsing
PUSH P,A ;No - output
MOVEI E,SW%FIL+2 ;Pretend it was /OUTPUT:
JRST SYG.6A
SYG.4: ;Loop for switches
COMND$ CMS
TXNE A,CM%NOP
JRST INVCMD ; Invalid
HRRZS C
CAIN C,FDBCMC ;If confirm
JRST SYG.7 ; Then done now
SYG.5: ;Switch found
PUSH P,A ;Save the flags for later
HRRZ E,(B) ;Get the switch flags
CAIN E,SW%TRC ;If /TRACE
JRST SYG.10 ; Then special treatment
TXNN A,CM%SWT ;Was there a colon?
JRST SYG.6 ; No
TRNN E,SW%FIL ;Yes - should there be one?
JRST [POP P,A
JRST INVSWT] ; No - error
MOVE B,E ;Get the switch number
ANDI B,7
CALL @[SWDF0 ;/COMMAND
SWDF1 ;/JOURNAL
SWDF2 ;/OUTPUT
[RET]
[RET] ;Should never get here
[RET]](B)
COMND$ FIL
TXNE A,CM%NOP ;OK?
JRST [POP P,A
JRST INVCMD] ; No
MOVEM A,(P) ;Save the latest flags from COMND
SKIPA ;Don't clear JFN
SYG.6: ;Dispatch to the right routine
SETZ B, ;No JFN if no filespec
SYG.6A:
MOVE A,E ;Copy the flags
ANDI E,7
CALL @[CSWT0 ;/COMMAND
CSWT1 ;/JOURNAL
CSWT2 ;/OUTPUT
CSWT3 ;/READONLY
CSWT4 ;/RECOVER
CSWT5](E) ;/CREATE
ORM F,OPTION ;Save the new option flags
POP P,A ;Restore the flags
JRST SYG.4 ;Loop for more
SYG.7: ;Do final tidy up
SKIPN A,INPNAM ;Any input filespec?
SKIPE CMDOPT ; No - should there be one?
CAIA ; No - OK
JRST SYG.1 ; No - loop to request it.
MOVE C,OPTION ;Pick up the options flags
SKIPE JOUNAM+D$NAME ;Was there a journal filespec?
JRST SYG.8 ; Yes
TXNE C,OP%NJO ;No - should there be one?
JRST SYG.8 ; No
SKIPN CMDOPT ;If CREATE
JRST SYG.7A ;...
PUSH P,OUTNAM+D$DEV ; Then use the output defaults
PUSH P,OUTNAM+D$DIR
PUSH P,OUTNAM+D$NAME
JRST SYG.7B
SYG.7A: PUSH P,INPNAM+D$DEV ;Set the journal file defaults
PUSH P,INPNAM+D$DIR
PUSH P,INPNAM+D$NAME
SYG.7B: POP P,JOUNAM+D$NAME
POP P,JOUNAM+D$DIR
POP P,JOUNAM+D$DEV
MOVE A,[POINT 7,[ASCIZ /JOU/]]
MOVEM A,JOUNAM+D$EXTN
SYG.8: ;Default the output file
SKIPE OUTNAM+D$NAME ;Was there an output file?
JRST SYG.9 ; No
TXNE C,OP%NOU ;Should there be one?
JRST SYG.9 ; No
MOVE A,INPNAM+D$DEV
MOVEM A,OUTNAM+D$DEV
MOVE A,INPNAM+D$DIR
MOVEM A,OUTNAM+D$DIR
MOVE A,INPNAM+D$NAME ;Copy the defaults
MOVEM A,OUTNAM+D$NAME
MOVE A,INPNAM+D$EXTN
MOVEM A,OUTNAM+D$EXTN
SYG.9: ;Default for command set later in EDT
SKIPN TRACEX ;Did he say /TRACE?
RET ; No
PUSH P,[1]
PUSH P,[0]
PUSH P,[0]
PUSH P,[0]
CALL $TRACE ;Yes - switch tracer on now
SKIPN TRCSTK ;Should we open a trace file?
JRST SYG.9A ; No
MOVEI A,5
MOVEM A,-3(P) ;Yes - change the function code
CALL $TRACE
SYG.9A:
ADJSP P,-4
RET
SYG.10: ;Here on /TRACE
TXNN A,CM%SWT ;Any value with the switch?
JRST SYG.4 ; No - ignore it
COMND$ FLD ;Parse the routine name
TXNE A,CM%NOP
JRST INVCMD
SETOM TRACEX ;Set the flag for later
MOVEI A,1(P)
HRLI A,(POINT 7,0)
PUSH P,ATOM ;Copy the routine name to the stack
PUSH P,ATOM+1
PUSH P,[1]
PUSH P,A ;Point to the name
PUSH P,[0]
PUSH P,[0]
COMND$ COL ;Look for a colon
TXNE A,CM%NOP
JRST SYG.11
SETOM TRCSTK ;File will now be opened
COMND$ NUX ;How many stack items
TXNE A,CM%NOP
SETZ B, ;Assume none
MOVEM B,-1(P) ;Store this number
COMND$ COL ;Colon again
TXNE A,CM%NOP
JRST SYG.11
COMND$ FLD ;Name of location to watch
MOVE B,[POINT 7,ATOM] ;Name is in ATOM buffer
TXNN A,CM%NOP
MOVEM B,(P) ;Store it if OK
SYG.11:
CALL $TRACE ;Enable tracing on the routine
ADJSP P,-6
POP P,A ;Restore flags
JRST SYG.4
INVCMD: ;Invalid command
MOVEI A,.PRIOU
HRLI B,.FHSLF
SETZ C,
ERSTR
JFCL
JFCL
CALL CMDINI ;Reinit the routine
JRST SYG.1
INVSWT: ;Invalid switch
HRROI A,[ASCIZ /Value not allowed on switch/]
ESOUT
CALL CMDINI ;Reinit the routine
JRST SYG.1
ERROR: ;Fatal error
MOVEI A,.PRIOU
HRLOI B,.FHSLF
SETZ C,
ERSTR
JFCL
JFCL
MOVEI A,1 ;Send status back up
HALTF
CMDINI: ;Init this routine
MOVE A,CMDOPT ;Copy the implied flags
MOVEM A,OPTION
SETZM INPNAM ;And clear the names
SETZM OUTNAM
SETZM JOUNAM
SETZM CMDNAM
SETZM GTJBLK+.GJNAM ;Make sure any defaults are cleared
SETZM GTJBLK+.GJEXT
RET
REPARS: ;Reset for a reparse
CALL CMDINI ;Reinit the flags etc
JRST SYG.2
;
;SWITCH SUBROUTINES
;
;Enter with:
; A = Flags in right half
;
;Exit with:
; F =Flags for options word
CSWT0: ;/COMMAND or /NOCOMMAND
TRNE A,SW%NOT
JRST [MOVEI F,OP%NCM ;/NOCOMMAND
RET]
PUSH P,B
MOVEI A,CMDNAM
PUSH P,A
CALL GETFSP
ADJSP P,-2
MOVEI F,OP%COM
RET
CSWT1: ;/JOURNAL or /NOJOURNAL
TRNE A,SW%NOT
JRST [MOVEI F,OP%NJO ;/NOJOURNAL
RET]
PUSH P,B
MOVEI A,JOUNAM
PUSH P,A
CALL GETFSP
ADJSP P,-2
SETZ F,
RET
CSWT2: ;/OUTPUT or /NOOUTPUT
TRNE A,SW%NOT
JRST [MOVEI F,OP%NOU ;/NOOUTPUT
RET]
PUSH P,B
MOVEI A,OUTNAM
PUSH P,A
CALL GETFSP
ADJSP P,-2
SETZ F,
RET
CSWT3: ;/READONLY or /NOREADONLY
TRNN A,SW%NOT
MOVEI F,OP%NJO+OP%NOU ;/NOOUTPUT /NOJOURNAL
RET
CSWT4: ;/RECOVER or /NORECOVER
TRNN A,SW%NOT
MOVEI F,OP%REC ;/RECOVER
RET
CSWT5: ;/CREATE or /NOCREATE
TRNE A,SW%NOT
MOVEI F,OP%NCR ;/NOCREATE
RET
;
;THESE ROUTINES SET THE DEFAULT FILE NAMES AND TYPES
;FOR THE SWITCHES /COMMAND, /JOURNAL, AND /OUTPUT.
;
SWDF0: ;/COMMAND = EDTINI.EDT
MOVX A,GJ%OLD!GJ%XTN
MOVEM A,GTJBLK+.GJGEN
MOVE A,[POINT 7,[ASCIZ /EDTINI/]]
MOVEM A,GTJBLK+.GJNAM
MOVE A,[POINT 7,[ASCIZ /EDT/]]
MOVEM A,GTJBLK+.GJEXT
RET
SWDF1: ;/JOURNAL = input-file.JOU
MOVX A,GJ%FOU!GJ%MSG!GJ%XTN
MOVEM A,GTJBLK+.GJGEN
MOVE A,INPNAM+D$DEV
MOVEM A,GTJBLK+.GJDEV
MOVE A,INPNAM+D$DIR
MOVEM A,GTJBLK+.GJDIR
MOVE A,INPNAM+D$NAME
MOVEM A,GTJBLK+.GJNAM
MOVE A,[POINT 7,[ASCIZ /JOU/]]
MOVEM A,GTJBLK+.GJEXT
RET
SWDF2: ;/OUTPUT = input-file.input-type
MOVX A,GJ%FOU!GJ%MSG!GJ%XTN
MOVEM A,GTJBLK+.GJGEN
MOVE A,INPNAM+D$DEV
MOVEM A,GTJBLK+.GJDEV
MOVE A,INPNAM+D$DIR
MOVEM A,GTJBLK+.GJDIR
MOVE A,INPNAM+D$NAME
MOVEM A,GTJBLK+.GJNAM
MOVE A,INPNAM+D$EXTN
MOVEM A,GTJBLK+.GJEXT
RET
END