Trailing-Edge
-
PDP-10 Archives
-
bb-bt99l-bb
-
declar.x18
There is 1 other file named declar.x18 in the archive. Click here to see a list.
TITLE DECLARE ;Define user defined commands
SUBTTL Tarl Neustaedter/RCB 3 Dec 86
;COPYRIGHT (c) 1984,1986,1987 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;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.
SEARCH JOBDAT,MACTEN,SCNMAC,UUOSYM ;Universals
TWOSEG ;Put code in sharable hiseg
RELOC 400000 ;Starting now
ASCIZ |
COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1984,1987.
ALL RIGHTS RESERVED.
|
.REQUE REL:SCAN,REL:HELPER
.TEXT "/SYMSEG:HIGH/LOCALS"
DCLWHO==0
DCLVER==1
DCLMIN==1
DCLEDT==13
.ORG .JBVER
BYTE (3)DCLWHO(9)DCLVER(6)DCLMIN(18)DCLEDT
.ORG
;Edit history
;1) Program creation
;2) Make the command .DECLAR<CR> give an error
;3) Add version numbers
;4) Change a Z to a BLOCK 1 so that LINK knows this is a null loseg.
;5) Require a filename. COMCON requires it, make sure the error
; gets caught before we pass it to the monitor.
;6) Update handling of /UNIQUE switch to conform to new monitor handling
; introduced by MCO 11206.
;7) Add new /AUTOPUSH switch to allow access to new ability to define
; commands that preserve a core-image.
;10) Change some symbols whose names were changed in UUOSYM
; by MCO 11689. /NT
;11) Remove edit 5. COMCON doesn't require a name if the device
; is pathological and will default the name from the device definition.
;12) Fix bug with path defaulting.
;13) Don't do so many CORE UUOs. Maybe this will speed up declaring multiple
; commands at LOGIN time. /RCB
T4=:1+<T3=:1+<T2=:1+<T1=:1+0>>> ;Temporary ACs
P4=:1+<P3=:1+<P2=:1+<P1=:1+T4>>>;Permanent ACs
CM=:P4+1 ;Pointer to command's scan block
FI=:CM+1 ;Pointer to filespec scan block
LI=:FI+1 ;Offset pointer into list block
P=:17 ;Stack pointer
OPDEF CALL [PUSHJ P,] ;So that I don't have to type so much
OPDEF RET [POPJ P,] ;Bad return
OPDEF RETSKP [JRST .POPJ1##] ;good return from most routines
OPDEF SKP [TRNA] ;skip over an instruction
OPDEF NOOP [TRN] ;do nothing. Ignore skip returns
DEFINE $WARN(PREFIX,TEXT),<
CALL [ POP P,T3 ;;PC in case desired
MOVE T2,["%",,[ASCIZ \TEXT\]]
MOVE T1,[SIXBIT \DCL'PREFIX\]
JRST ERRORH] ;;And call the error handler
>
ND NSCANF,0 ;Change FX.xxx stuff before turning on.
ND LSTSIZ,100 ;Maximum number of commands to get a list of
ND PDLSIZ,50
RELOC ;loseg, for data storage
STACK: BLOCK PDLSIZ ;Stack
;Scan switch locations
SW0: ;Start of switch area
CLEARS: BLOCK 1
KILLSW: BLOCK 1
LISTSW: BLOCK 1
AUTOSW: BLOCK 1
;Not really switches, but we want to setom them every time
CMDNAM: BLOCK 1
CMDFIL: BLOCK 1
ERRORF: BLOCK 1
SW9: ;End of switch area
UNIQUE: BLOCK 1 ;Switch to setzm (not setom)
OFFSET: BLOCK 1 ;For SCAN
CMDBLK: BLOCK .CMMAX ;Block to do CMAND.s in
BLOCK 1 ;Buffer word
LSTBLK: BLOCK LSTSIZ+1 ;Block to get a list of commands
RELOC ;Hiseg, for switch tables
KEYS UNQ,<4,3,2,1> ;Possible uniqueness values
; (must be in this order)
PD.UNQ==1_<UNQ4-1> ;Default for bare switch is /UNIQUE:4
DEFINE SWTCHS,<
SN *AUTOPUSH,AUTOSW,
SS *CLEAR,CLEARS,1,
SS *KILL,KILLSW,1,
SS *LIST,LISTSW,1,
SL *UNIQUE,UNIQUE,UNQ,PD.UNQ,FS.OBV
>
DOSCAN(CM.) ;Generate the switch tables
ISBLK: ;ISCAN block
IFN NSCANF,<XWD 12,%%FXVE> ;If new scan, pass a version number
IOWD 2,[SIXBIT \DECLAR\
SIXBIT \COMMAN\]
XWD OFFSET,'DCL' ;Offset,,sixbit CCL name
XWD 0,0 ;Input,,output routines
XWD 0,0 ;Length,,block for preset indirect file
XWD 0,0 ;Prompt,,exit routines
EXP FS.INC ;Flags,,future (no CORE UUOs)
ISBLKP: XWD .-ISBLK,ISBLK
TSBLK: ;TSCAN block
IFN NSCANF,<XWD 12,%%FXVE> ;If new scan, pass a version number
IOWD CM.L,CM.N
XWD CM.D,CM.M
XWD 0,CM.P ;Switch table pointers for TSCAN
EXP -1 ;Use system helper
XWD CLRSWT,0 ;Clear all answers,,files (no files)
XWD ALLIN,ALLOUT ;Allocate input and output filespecs
TSBLKP: XWD .-TSBLK,TSBLK ;TSCAN block pointer
PDL: IOWD PDLSIZ,STACK ;Pointer to stack
;Start of the program itself.
COMMAN: TDZA T1,T1 ;Non CCL entry
MOVEI T1,1 ;CCL entry
MOVEM T1,OFFSET ;SAVE AS OFFSET FOR SCAN TO LOOK AT
RESET ;oops.
MOVE P,PDL ;Set up stack pointer
MOVE T1,ISBLKP ;GET THE ISCAN BLOCK POINTER
PUSHJ P,.ISCAN## ;initialize the world
COM1: MOVE T1,TSBLKP ;Pointer to TSCAN block
PUSHJ P,.TSCAN## ;Ask for a command
SKIPL ERRORF ;Did an error flag get set?
JRST COM1 ;YEs, forget this line
SKIPL CM,CMDNAM ;did we get an output spec? (command name)
JRST COM2 ;Yes, skip over single spec checking
SKIPG CM,CMDFIL ;Did we get an input spec
JRST [PUSH P,[COM1];Set up return address
$WARN NCG,<No command given>]
MOVEM CM,CMDNAM ;save as output filespec
SETOM CMDFIL ;And clear input filespec
COM2: CALL CMDCHK ;Check CMDNAM to make sure only name typed
JRST COM1 ;Error, try again.
CALL PRCLIN ;process the line
JRST COM1 ;and go for another line
CMDCHK: MOVE T1,.FXMOD(CM) ;Get the modifications word
TXNN T1,FX.NDV ;Make sure he didn't type a device name
$WARN CMD,<Command may not contain device field>
TXNN T1,FX.NUL ;Make sure he didn't give an extension
$WARN CMD,<Command may not contain extension field>
TXNE T1,FX.DIR ;Make sure he didn't give a directory
$WARN CMD,<Command may not contain any path specification>
RETSKP
PRCLIN: SKIPL CLEARS ;Should we clear all commands?
JRST COMCLR ;Yes, go do it.
SKIPL KILLSW ;Should we kill a command
JRST COMKIL ;Yes, kill this particular command
SKIPL LISTSW ;Should we list all the command names?
JRST COMLST ;Yes, go do it.
SKIPL FI,CMDFIL ;Did we get an input filespec?
JRST COMADD ;Yes, we must be adding commands
SKIPN .FXNAM(CM) ;Did a command name come in on this?
RET ;Pretend this didn't happen
; JRST COMSHO ;show if command but no filespec
COMSHO: SKIPL CMDFIL ;Make sure no filespec was typed
$WARN FNA,<Filespec not allowed for /SHOW switch>
SKIPN T1,.FXNAM(CM) ;make sure he gave us a command
$WARN CMN,<Command name required for /SHOW switch>
SETCM T2,.FXNMM(CM) ;Get inverted wildcard mask from command
JUMPE T2,COMSH. ;Just show one if no wildcarding
ANDCM T1,T2 ;Mask name down for comparisons
MOVEM T1,.FXNAM(CM) ;Update where we can find it
MOVEI T1,LSTSIZ ;LSTBLK size
MOVEM T1,LSTBLK+.CMCOU;Save as max number of command names to return
MOVE T1,[.CMLST,,LSTBLK] ;get the list of names
CMAND. T1,
$WARN CGL,<Couldn't get list of commands>
SETZ LI, ;Offset of 0 into LSTBLK
COMSH$: CAML LI,LSTBLK+.CMCOU ;Do we still have more commands to go?
RET ;no, return to top level
MOVE T1,LSTBLK+1(LI) ;Get a command name
MOVE T2,T1 ;Copy the name
AND T2,.FXNMM(CM) ;Account for wildcards
CAMN T2,.FXNAM(CM) ;If it matches,
CALL COMSH. ;List it
AOJA LI,COMSH$ ;and go do another command
COMSH.: SETZM CMDBLK ;Clear CMAND. block
MOVE T2,[CMDBLK,,CMDBLK+1];BLT Pointer
BLT T2,CMDBLK+.CMMAX-1 ;Clear the whole block
MOVEM T1,CMDBLK+.CMCMN ;Which command to return information on
MOVEI T1,.CMMAX ;Maximum size of a command block
MOVEM T1,CMDBLK+.CMSIZ ;Save as amount of info to return us
MOVE T1,[XWD .CMRET,CMDBLK] ;Args for UUO
CMAND. T1, ;Get information on this command
$WARN NSC,<No such command>
MOVE T1,CMDBLK+.CMNAM ;Get command name
CALL .TSIXN## ;Type it out in sixbit
LDB P1,[POINTR CMDBLK+.CMFLA,CM.UNQ]
JUMPE P1,COMSH0 ;If no uniqueness, skip it
MOVEI T1,[ASCIZ |/UNIQUE:|] ;Switch string
CALL .TSTRG## ;Type it
MOVE T1,UNQSTR(P1) ;Get translation string for the bits
CALL .TSTRG## ;Type the value(s)
COMSH0: MOVEI T1,[ASCIZ |/AUTOPUSH|] ;String to use
MOVX T2,CM.AUT ;Auto-push bit
TDNE T2,CMDBLK+.CMFLA ;Is it lit?
CALL .TSTRG## ;Yes, type it out
MOVEI T1,[ASCIZ | = |] ;ascii equals sign
CALL .TSTRG## ;Type it out
SKIPN T1,CMDBLK+.CMDVC ;Get device name
JRST COMSH1
CALL .TSIXN## ;Type out device name
CALL .TCOLN## ;indicate device with a colon
COMSH1: MOVE T1,CMDBLK+.CMFLE ;Get filename
CALL .TSIXN## ;Type it out.
SKIPN T1,CMDBLK+.CMEXT ;Get extension
JRST COMSH2 ;skip
MOVEI T1,"." ;Dot.
CALL .TCHAR## ;Precede it with a dot
MOVE T1,CMDBLK+.CMEXT ;get extension back again
CALL .TSIXN##
COMSH2: SKIPN CMDBLK+.CMPPN ;Get PPN
JRST COMSH9 ;Finished.
MOVEI T1,"[" ;Start PPN typeout
CALL .TCHAR## ;type it out
MOVE T1,CMDBLK+.CMPPN ;Get PPN
CALL .TXWDW## ;Type it out
MOVE P1,[IOWD 5,CMDBLK+.CMSFD] ;AOBJN pointer to SFD names
COMSH3: SKIPN 1(P1) ;Check to see if next level of SFD is there
JRST COMSH8 ;nope, close of filespec
CALL .TCOMA## ;Type out a separating comma
MOVE T1,1(P1) ;Get SFD name
CALL .TSIXN##
AOBJN P1,COMSH3 ;And find another SFD
COMSH8: CALL .TRBRK## ;Close PPN part of filespec
COMSH9: PJRST .TCRLF## ;End typeout and return
RET
COMADD: SETZM CMDBLK ;Clear CMAND uuo block
MOVE T1,[CMDBLK,,CMDBLK+1] ;BLT pointer
BLT T1,CMDBLK+.CMMAX-1 ;clear it all out
MOVE T1,.FXNAM(CM) ;Get the command name
MOVEM T1,CMDBLK+.CMNAM;Save as command name in uuo block
IFE NSCANF,<MOVE T1,.FXDEV(FI)> ;Device name (DSK: default)
IFN NSCANF,<
SKIPN T1,.FXDEV(FI) ;get device name
MOVSI T1,'DSK' ;Default to DSK:
>;END IFN NSCANF
MOVEM T1,CMDBLK+.CMDVC ;Save as device to run off of
MOVEI P1,3 ;Number of words we are using so far
SKIPE T1,.FXNAM(FI) ;Get the filename of program to be run
MOVEI P2,4 ;Number of words we have taken already
MOVEM T1,CMDBLK+.CMFLE ;save as filename
HLLZ T1,.FXEXT(FI) ;Get extension
JUMPE T1,COMAD2 ;If nothing, proceed
MOVEM T1,CMDBLK+.CMEXT;Set as extension of program to run
MOVEI P2,5 ;Bump P2 to include this
COMAD2: MOVE T4,.FXDIR(FI) ;Get ppn returned by SCAN
TLNN T4,-1 ;Project number seen?
HLL T4,.MYPPN## ;No, default it
TRNN T4,-1 ;Programmer number seen?
HRR T4,.MYPPN## ;No, default that
SKIPE .FXDIM(FI) ;Was there any point to this exercise?
MOVEM T4,.FXDIR(FI) ;Yes, update the ppn word
MOVEI T4,.FXDIR(FI) ;Pointer to source directory
MOVE T3,[XWD -6,CMDBLK+.CMPPN] ;Pointer to destination directory
COMAD3: SKIPN T1,(T4) ;Anything in the source?
JRST COMAD8 ;nope.
MOVEI P2,-CMDBLK+1(T3);Update number of words deposited
MOVEM T1,(T3) ;Save directory word
ADDI T4,2 ;Point to next input directory name
AOBJN T3,COMAD3 ;And go get another word
COMAD8: SKIPE T1,UNIQUE ;Uniqueness bits specified?
DPB T1,[POINTR P2,CM.UNQ] ;Yes, add flags to count word
SKIPLE AUTOSW ;/AUTO:YES?
TXO P2,CM.AUT ;Yes, add flag to count word
MOVEM P2,CMDBLK+.CMFLA ;Save number of words we picked up
MOVE T1,[XWD .CMADD,CMDBLK] ;Arg for UUO
CMAND. T1, ;Add this command
$WARN CUA,<CMAND. UUO function .CMADD failed>
RET ;Command added, done.
COMCLR: SKIPN .FXNAM(CM) ;Did we get a command name?
SKIPL CMDFIL ;or an input filespec?
$WARN CLS,</CLEAR switch must be standalone>
SETZM CMDBLK+0 ;Clear command block
MOVE T1,[XWD .CMINT,CMDBLK] ;Initialize (clear) command data base
CMAND. T1, ;Wipe.
$WARN CUI,<CMAND. UUO function .CMINT failed>
RET
COMKIL: SKIPL CMDFIL ;Make sure we don't have a filespec
$WARN KMN,</KILL switch cannot take a filespec>
MOVEI T1,2 ;Number of words in argument block
MOVEM T1,LSTBLK+.CMCOU ;Put into list block
MOVE T1,.FXNAM(CM) ;Get command name to wipe
MOVEM T1,LSTBLK+1 ;Save as command to delete
MOVE T1,[.CMDEL,,LSTBLK] ;Delete a command
CMAND. T1, ;Wipe!
$WARN NSC,<No such command>
RET
COMLST: SKIPN .FXNAM(CM) ;Did we get a command name?
SKIPL CMDFIL ;or an input filespec?
$WARN CLS,</LIST switch must be standalone>
MOVEI T1,LSTSIZ ;Size of the list buffer
MOVEM T1,LSTBLK ;Save in the list block
MOVE T1,[.CMLST,,LSTBLK] ;Args to list the command names
CMAND. T1, ;Get the list
$WARN CUL,<CMAND. UUO function .CMLST failed>
SETZB P1,LI ;Clear both counters
COMLS1: CAML LI,LSTBLK+.CMCOU ;Have we typed out all commands?
JRST .TCRLF## ;yes, let CRLF terminate for us
SOJG P1,COMLS4 ;Check to see if we should crlf
CALL .TCRLF## ;Yes, terminate the line
MOVEI P1,^D8 ;reset number of commands to type before crlf
SKP ;and skip
COMLS4: CALL .TTABC## ;Seperate
COMLS3: MOVE T1,LSTBLK+1(LI) ;Get the command name
CALL .TSIXN## ;Type it out
AOJA LI,COMLS1 ;And go do another command
CLRSWT:
HLRZ T1,.JBSA ;Get original amount of core
MOVEM T1,.JBFF ;save as current amount of core
; CORE T1, ;And release core
; $WARN CFC,<Core UUO failed in cleanup routine>
SETOM SW0 ;Clear first switch
MOVE T1,[SW0,,SW0+1] ;BLT pointer to clear all switches
BLT T1,SW9 ;Clear them all
SETZM UNIQUE ;Also clear the bit-valued switch
RET ;return
ALLIN: SKIPL CMDFIL ;Make sure we don't already have a filespec
CALL [$WARN MFI,<Multiple filespecs are not legal>]
HRRZ T1,.JBFF ;Get pointer to free core
MOVEM T1,CMDFIL ;Save as input filespec
ALLOC: MOVEI T2,.FXLEN
ADDM T2,.JBFF ;Increase memory size
MOVE T3,.JBFF ;Current core size
SOJ T3, ;Only allocate what we'll use
CAMG T3,.JBREL ;Do we already have this much?
RET ;Yes, just return info to scan
CORE T3, ;Make sure we get it
$WARN CUF,<Core UUO failed in memory allocater>
RET ;And return to scan
ALLOUT: SKIPL CMDNAM ;Count times we have given this away
CALL [$WARN MCN,<Multiple command names are not legal>]
HRRZ T1,.JBFF ;Get pointer to free area
MOVEM T1,CMDNAM ;save as output filespec
PJRST ALLOC ;And allocate the core we are taking
ERRORH: CALL .ERMSA## ;Call scan's error handler
CALL .TCRLF## ;Finish the line
AOS ERRORF ;Bump error count (flag)
RET ;and return
;The translation table for uniqueness bits (right-adjusted) to display text
UNQSTR: [ASCIZ |NONE|] ;0
[ASCIZ |4|] ;CM.UN4
[ASCIZ |3|] ;CM.UN3
[ASCIZ |(3,4)|] ;CM.UN3!CM.UN4
[ASCIZ |2|] ;CM.UN2
[ASCIZ |(2,4)|] ;CM.UN2!CM.UN4
[ASCIZ |(2,3)|] ;CM.UN2!CM.UN3
[ASCIZ |(2,3,4)|] ;CM.UNQ^!CM.UN1
[ASCIZ |1|] ;CM.UN1
[ASCIZ |(1,4)|] ;CM.UN1!CM.UN4
[ASCIZ |(1,3)|] ;CM.UN1!CM.UN3
[ASCIZ |(1,3,4)|] ;CM.UNQ^!CM.UN2
[ASCIZ |(1,2)|] ;CM.UN1!CM.UN2
[ASCIZ |(1,2,4)|] ;CM.UNQ^!CM.UN3
[ASCIZ |(1,2,3)|] ;CM.UNQ^!CM.UN4
[ASCIZ |(1,2,3,4)|] ;CM.UNQ
END COMMAN