.TITLE AUXUSR AUX user loadable special commands .IDENT /1.0/ .ENABL LC ;+ ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; ; Title: AUXUSR ; Author: Frank Borger ; Date: December 17, 1986 ; ; Description: ; ; This module contains the routines to read in possible ECR.CMD ; file containing user defined commands and process them later ; changing things ala the massage program. Special user commands ; are entered from the file ECR.CMD and stored. There format is ; ; xxx ldr...~trl...~ ; ; xxx up to 3-character name for the pseudo command name. The name & ; following space(es) are stripped from the command for parsing. ; ; ldr... is a string to replace the mcr pseudo name received ; from the terminal, (terminated by the tilde character) ; ; y/n is either a y, (specifying that ";*.*" should be added to ; the command string if no period was encountered) ; ; trl... is a string to trail the command received from the terminal ; ; ` A back-quote character encountered in a leader or trailer ; will cause the user supplied command string (less the pseudo ; mcr name and space) to be included again. ; ; Another option (turned on and off by control-G) is to remember the ; last "default" string (usually a name) and re-use it if a subsequent ; command has nothing following the command name this would let you do: ; ; ECR>ked prog ; ECR>for ; ECR>link ; ; ECR is capable of storing up to 48. 40. byte massage commands ;- .ENABL AMA .NLIST BEX .MCALL CLOSE$ ; .psect rwdata,rw,d,lcl,rel,con ; ; file specification for ECR.CMD command file ; AUXDEF: .ascii /SY0:/ AUXUIC: .ascii /[nnn,nnn]/ ; uic to be rewritten .ASCIZ "ECR.CMD" ; Look for COMMAND file .EVEN ; ; misc data ; perflg: .word 0 ;flag that period was seen in command line defflg: .word -1 ; default flag, -1 = off, 0 or n = length ; of default name ; ; buffer for default name ; defbuf: .blkb 40. ; this should be enough ; ; buffer for loadable redefine commands ; numcom==48. ; number of commands that can be stored sizcom==40. ; size of commands in bytes usrbuf:: ; buffer for user defined commands .rept numcom .blkb sizcom .endr .psect code,ro,i,lcl,rel,con ; ; loacmd loads file ecr.cmd from current ; default defice and uic into buffer ; ; call: no parameters necessary ; ; return: no registers changed, ; buffer erased and then re-loaded if file is found ; loacmd:: ; load info from command file call $saval ; save all used regs MOV IENTRY,R5 ; Terminal file entry address. MOV O.FDB(R5),R0 ; Copy the FDB address. mov .crtsk,r2 ; get my atl mov a.ti(r2),r2 ; and my pud pointer mov U.UI(r2),r3 ; get my uic in binary mov u.lbh(r2),r2 ; and my default device pud mov u.dn(r2),auxdef ; move in default device name movb u.un(r2),auxdef+2 ;and unit number bisb #60,auxdef+2 ; change bin-asc (hope no more that 7 disks) mov #auxuic,r2 ; point to ascii string area mov #1,r4 ; set to do 3 character numbers, inc {,} call .ppasc ; convert uic to ascii MOV #AUXDEF,R1 ; Set the file name address. CALL OPENR ; Open the LUN for read. bcs 95$ ; don't do anything if open failed mov #usrbuf,r0 ; point to command buffer mov #numcom*sizcom/2,r1 ; get set for zero 1$: clr (r0)+ ; zero any previous commands sob r1,1$ ; Loop reading the command file. MOV #usrbuf,R0 ; Set output buffer address. mov #numcom,r3 ; set line counter 20$: CALL GET ; Read the next record. BCS 90$ ; If CS, error or EOF. mov r0,r4 ; starting address in user buffer -> r4 30$: movb (r1)+,(r4)+ ; xfer a character of file sob r2,30$ ; till whole line is xferred add #sizcom,r0 ; bump to next slot in storage sob r3,20$ ; try for another command 90$: CLOSE$ O.FDB(R5) ; Close the input file. 95$: return ; ; chkcmd check command line and modify it if necessary ; ; call: Command line address in R0, (usually address of FMTBUF) ; command length in r1 ; ; return: new command address in r0 ; new command length in r1 ; chkcmd:: ;check command and parse if necessary mov r2,-(sp) ;save r2 mov r1,-(sp) ;save buffer length mov r0,-(sp) ;and start address mov #usrbuf,r2 ;point to buffer for pseudo commands mov #numcom,r3 ;set loop counter 1$: cmpb (r0),(r2) ;first letter match ? bne 2$ ;br if not cmpb 1(r0),#40 ;1 char command name ? beq altcmd ; yes cmp r1,#1 ;1 char command with name only ? beq altcmd cmpb 1(r0),1(r2) ;2nd letter match ? bne 2$ ;br if not cmpb 2(r0),#40 ;2 char command name ? beq altcmd ;yes cmp r1,#2 ;2 char command with name only ? beq altcmd cmpb 2(r0),2(r2) ;test 3rd, (or each space if 2-char command) beq altcmd ;br if found a match 2$: add #sizcom,r2 ;bump to next buffer tst (r2) ;end of commands ? beq 3$ ;branch if yes sob r3,1$ ;if not, try next command 3$: mov (sp),r0 ;restore buffer pointer mov 2(sp),r1 ;and length ;check regular command for defaults call skispa ;skip command name and spaces mov r0,r2 ;save pointer for possible restore default use call savdef ;save possible default line tst r1 ;do we need to do restore ? bgt 31$ ;no, skip it call resdef ;restore possible default tst r1 ;was default restore successful ? bgt 32$ ;br if we found something to add 31$: mov (sp)+,r0 ;restore r0 and r1 to original mov (sp)+,r1 br 6$ ;and do exit 32$: movb #' ,(r2)+ ;in this mode, we must insert space 4$: movb (r0)+,(r2)+ ;get the default ascii sob r1,4$ ;one at a time 5$: mov (sp)+,r0 ;restore start of command pointer sub r0,r2 ;calculate new length (if changed) mov r2,r1 ;update r1 tst (sp)+ ;trash old r1 value 6$: mov (sp)+,r2 ;restore r2 rts pc ;return unchanged ; ; we have found a match, ; alter command line accordingly ; ; r0 points to user's command line ; r2 points to matching massage command line ; altcmd: mov r3,-(sp) mov r0,r3 add r1,r3 ;point past end of line movb #40,(r3) ;put space in if user just typed command only call skispa ;find end of spaces after command name ; ; we are now looking at meat of users command line ; mov #inbuf,r3 ;point to buffer for new command 4$: cmpb (r2)+,#40 ;found space in pseudo command ? beq 45$ ;br if yes br 4$ ;try again 45$: cmpb (r2)+,#40 ;now look for first letter of command beq 45$ dec r2 call coptil ;copy command leader till you get a tilde call savdef ;save possible user default tst r1 ;need to restore default ? bgt 46$ ;br if not call resdef ;restore possible user defaults 46$: tst r1 ;still nothing there ? ble 47$ ;skip if nothing left call copusr ;copy the default command line 47$: cmpb (r2)+,#'Y ;should we add defaults to file name ? bne 7$ ;br if not tst perflg ;do we want to add ;*.* ? bne 7$ movb #'.,(r3)+ movb #'*,(r3)+ movb #';,(r3)+ movb #'*,(r3)+ 7$: call coptil ;copy command trailer till you get a tilde mov #inbuf,r0 ;point to start of buffer mov r3,r1 ;end to r1 sub #inbuf,r1 ;calc new length mov (sp)+,r3 cmp (sp)+,(sp)+ ;get rid of old r0,r1 mov (sp)+,r2 rts pc ; ; default routines ; ; ; if there is something left in command line, save it if default ; mode is on. If not, if default mode is on, use default instead ; savdef: tst defflg ;default mode turned on ? bmi 4$ ;br if not tst r1 ;anything to save ? ble 4$ ; skip it if nothing there cmp r1,#40. ;too many characters to store ? bgt 4$ ;if so, something really wrong, forget it mov r1,defflg ;set size of new default name mov r0,-(sp) mov r2,-(sp) ;save used regs mov #defbuf,r2 ;point to storage area 1$: movb (r0)+,(r2)+ ;xfer one sob r1,1$ ;till done mov defflg,r1 ;restore regs mov (sp)+,r2 mov (sp)+,r0 4$: rts pc ; ; ; point r0 at default buffer and ; put size in r1 if default is enabled and default command exists ; resdef: tst defflg ;is default enabled & do we have any to give? ble 2$ ; br if not or if length =0 clr perflg ; clear period flag again mov #defbuf,r0 ;point to default buffer mov defflg,r1 ;set up default size 1$: cmpb (r0)+,#'. ;period seen bne 15$ ;br if not inc perflg ;set flag 15$: sob r1,1$ mov #defbuf,r0 ;point to default buffer mov defflg,r1 ;set up default size 2$: rts pc ; ; skip over command name and following spaces ; advances r0 and decrements r1 until it finds a character ; following a space ; returns r0 pointing to start of actual command ; r1 number of characters left ; r0 past end of input line ; r1 =0 if nothing is left on the line ; skispa: dec r1 ;sub 1 char of users command bmi 3$ ;quit if we just got rid of whole input line cmpb (r0)+,#40 ;look for first space bne skispa ;after pseudo command name 2$: dec r1 ;sub one again bmi 3$ ;quit if that's all there is cmpb (r0)+,#40 ;are there multiple spaces? beq 2$ ;br if there are dec r0 ;back up the pointer 3$: inc r1 ;adjust counter rts pc ;return ; ; toggle the default name state ; tgldef:: tst defflg ;check current state bmi 1$ ;br if its is off mov #-1,defflg ;turn state off br 2$ 1$: clr defflg ;turn state on 2$: ; ;report change on status line ; jsr r5,$savrg ;save r3 to r5 mov #fmtbuf,r0 ; set buffer address call setmsg ; set to do message line thing call reverse ; in reverse video mvs < Default Mode is now > tst defflg ; what is current status ? bmi off ; br if it is off mvs br show off: mvs show: call typmsg ;display it jmp refcmd ; ; sub to copy users command line to buffer ; This sub may be called more than once if user is creating ; a fortran or macro compile command line ; ; call: r1=length of user's command line (leading mcr name stripped) ; r0=address of start of command line ; r3=current text pointer int command being assembled ; ; return: r3 updated ; perflg set/cleared depending on whether period was seen copusr: mov r0,-(sp) mov r1,-(sp) clr perflg ;clear flag for period seen 5$: movb (r0)+,(r3) ;copy rest of the command from the terminal cmpb (r3)+,#'. ;period seen in file spec ? bne 6$ ;br if not inc perflg ;else show period seen 6$: sob r1,5$ mov (sp)+,r1 mov (sp)+,r0 rts pc ; ; sub to copy leader or trailer until we get tilde character ; ; call: r2=current pointer into stored command ; r3=current text pointer int command being assembled ; ; return: r3 updated ; coptil: cmpb (r2),#"` ;back quote ? bne 1$ ;no, inc r2 ;yes, bump over it call copusr ;and copy the users line again br coptil ;and go for more 1$: cmpb (r2),#'~ ;terminating character ? beq end ;yes, all done tstb (r2) ;or null ? beq end movb (r2)+,(r3)+ ;copy one character cmp r3,#inbuf+128. ;have we overflowed conversion buffer ? bge error ;yes, that a baddie br coptil end: inc r2 ;bump pointer past terminator rts pc ;normal return error: tst (sp)+ ;get rid of my call mov (sp)+,r3 ;default to orig command mov (sp)+,r0 mov (sp)+,r1 mov (sp)+,r2 rts pc .END