Google
 

Trailing-Edge - PDP-10 Archives - bb-d868b-bm_tops20_v3a_2020_dist - 3a-sources/cmd.mac
There are 21 other files named cmd.mac in the archive. Click here to see a list.
;<3A.UTILITIES>CMD.MAC.3, 24-May-78 11:01:00, EDIT BY OSMAN
;ADD RFLDE, CMDER1
;<3A.UTILITIES>CMD.MAC.2, 24-May-78 10:27:54, EDIT BY OSMAN
;MAKE SO ERRORS DON'T GET PREFIXED WITH "JSYS ERROR"
;<OSMAN>CMD.MAC.4,  8-May-78 15:17:49, EDIT BY OSMAN
;CHANGE ASCIZ DELIMITER TO SOMETHING RARER
;<OSMAN>CMD.MAC.3, 28-Apr-78 14:36:58, EDIT BY OSMAN
;ON ERROR, RETURN TO CALL DPROMPT RATHER THAN PREVIOUS INSTRUCTION
;<OSMAN>CMD.MAC.2, 14-Apr-78 14:48:45, EDIT BY OSMAN
;CHANGE FROM CMDREL TO CMD
;make this just a comnd utility module
;<OSMAN>OZ.MAC.32, 22-Mar-78 14:44:07, Edit by OSMAN
;<OSMAN>OZ.MAC.31, 22-Mar-78 14:41:07, Edit by OSMAN
;<OSMAN>OZ.MAC.30, 22-Mar-78 14:36:05, Edit by OSMAN
;<OSMAN>OZ.MAC.29, 22-Mar-78 14:19:04, Edit by OSMAN
;<OSMAN>OZ.MAC.28, 22-Mar-78 14:16:57, Edit by OSMAN
;DON'T REQUIRE USER'S STACK TO BE CALLED "PDL"
;<OSMAN>OZ.MAC.27, 13-Mar-78 11:20:38, Edit by OSMAN
;PUT IN CFIELD
;<OSMAN>OZ.MAC.26, 10-Mar-78 14:42:49, Edit by OSMAN
;<OSMAN>OZ.MAC.25, 10-Mar-78 14:12:25, Edit by OSMAN
;<OSMAN>OZ.MAC.24, 10-Mar-78 11:35:25, Edit by OSMAN
;<OSMAN>OZ.MAC.23,  9-Mar-78 22:26:25, Edit by OSMAN
;CHANGE NOISEX TO NOISE
;<OSMAN>OZ.MAC.22,  6-Mar-78 14:18:08, Edit by OSMAN
;<OSMAN>OZ.MAC.21,  6-Mar-78 11:27:59, Edit by OSMAN
;<OSMAN>OZ.MAC.20,  3-Mar-78 14:34:27, Edit by OSMAN
;<OSMAN>OZ.MAC.19,  1-Mar-78 17:08:02, Edit by OSMAN
;<OSMAN>OZ.MAC.18,  1-Mar-78 15:58:53, Edit by OSMAN
;<OSMAN>OZ.MAC.17,  1-Mar-78 14:59:00, Edit by OSMAN
;<OSMAN>OZ.MAC.16,  1-Mar-78 14:51:03, Edit by OSMAN
;<OSMAN>OZ.MAC.15,  1-Mar-78 14:42:01, Edit by OSMAN
;<OSMAN>OZ.MAC.13,  1-Mar-78 14:32:53, Edit by OSMAN
;<OSMAN>NEWTV.MAC.1, 28-Feb-78 16:33:29, Edit by OSMAN
;<OSMAN>OZ.MAC.3, 28-Feb-78 15:55:27, Edit by OSMAN
;ADD COMND CONVENIENCES
;<OSMAN>OZ.MAC.2, 21-Nov-77 13:18:16, EDIT BY OSMAN

IFNDEF REL,<REL==0>		;DEFAULT IS UNIVERSAL

IFE REL,<
UNIVERSAL cmd
EXTERNAL RFIELD,CMDINI,CFIELD,CMDER1,DPROMPT,RFLDE
>
IFN REL,<
TITLE cmd
>
SEARCH MONSYM,MACSYM


;AC DEFINITIONS

A=1		;A-E ARE TEMPORARY
B=2
C=3
D=4
E=5

P1=10		;P1-P4 ARE SUPPOSEDLY PRESERVED THROUGH SUBROUTINE CALLS
P2=11
P3=12
P4=13

P=17		;STACK POINTER

;MACRO TO PROMPT FOR COMMAND

DEFINE PROMPT (MESSAGE)
<
	HRROI A,[ASCIZ MESSAGE]
	CALL DPROMPT
>

;MACRO TO PRINT GUIDEWORDS

DEFINE NOISE (SHT)
<	MOVEI A,[FLDDB. .CMNOI,,<-1,,[ASCIZ /SHT/]>]
	CALL RFIELD
>

;MACRO TO REQUIRE CONFIRMATION

DEFINE CONFRM
<	MOVEI A,[FLDDB. .CMCFM]
	CALL RFIELD
>

;MACRO TO MAKE TABLE ENTRY

DEFINE T (WORD,ADDRES)
<
IFB <ADDRES>,<	[ASCIZ /WORD/],,.'WORD>
IFNB <ADDRES>,<	[ASCIZ /WORD/],,ADDRES>
>

;MACRO TO GENERATE COMND JSYS STORAGE

DEFINE CMDSTG
<
CMDBLN==:<^D80*6>/5+1		;ROOM FOR SIX LINE COMMAND
CMDBUF::	BLOCK CMDBLN
CMDACS::	BLOCK 20		;SAVED AC'S FROM BEGINNING OF COMMAND LINE
ATMBLN==:CMDBLN
ATMBUF::	BLOCK ATMBLN		;HOLDS LAST PARSED FIELD
SBK::	BLOCK 20		;COMND JSYS STATE BLOCK
CJFNBK::	BLOCK 20		;GTJFN BLOCK FOR COMND JSYS
REPARA::	0			;REPARSE ADDRESS FOR COMND
CMDFRM::	0			;MARKS BOTTOM OF STACK
CMDPDL::	BLOCK 200		;ROOM TO SAVE PDL
   >
IFN REL,<

;SYMBOLS WHICH USER PROGRAM MUST DEFINE.  HE MAY CONVENIENTLY DO
;SO, HOWEVER, WITH CMDSTG MACRO DEFINED ELSWHERE IN THIS MODULE.

EXTERNAL CMDBUF,CMDBLN		;USER'S COMMAND BUFFER AND LENGTH
EXTERNAL CMDACS			;BLOCK TO STORE AC'S WHEN COMMAND STARTS
EXTERNAL CMDPDL			;PLACE TO SAVE STACK WHEN COMMAND STARTS
EXTERNAL SBK			;STATE BLOCK
EXTERNAL CJFNBK			;JFN BLOCK
EXTERNAL ATMBUF,ATMBLN		;ATOM BUFFER AND LENGTH
EXTERNAL REPARA			;HOLDS REPARSE ADDRESS
EXTERNAL CMDFRM			;HOLDS BOTTOM OF STACK

;GET HERE ON COMND JSYS ERROR.  LET USER TRY AGAIN.

MESLN==30
CMDERR:	STKVAR <<ERMES,MESLN>>
	HRROI A,ERMES		;POINT TO MESSAGE AREA
	MOVE B,[.FHSLF,,-1]	;OURSELF, MOST RECENT ERROR
	MOVSI C,-MESLN*5	;MAXIMUM STRING WE'VE ROOM FOR
	ERSTR			;GET ERROR STRING
	 JFCL
	 JFCL			;UNEXPECTED ERRORS
	HRROI A,ERMES		;POINT AT STRING
	ESOUT			;PRINT IT IN STANDARD MANNER
	;...

;COME HERE TO LET USER FIX HIS ERROR (BY TYPING ^H) OR ISSUE ANOTHER
;COMMAND
;PRINT ERROR MESSAGE BEFORE TRANSFERRING HERE

	;...
CMDER1::
	SOS REPARA		;MODIFY REPARSE ADDRESS SO REPROMPT HAPPENS
	JRST REPARS

;PLACE TO TRANSFER IF USER EDITS PREVIOUSLY PARSED FIELDS

REPARS:	MOVE P,CMDACS+P		;FIRST RESTORE P SO WE KNOW HOW MUCH STACK TO RESTORE
	HRLI A,CMDPDL		;RESTORE STACK FROM SAVED STACK
	HRR A,CMDFRM		;COPY TO BOTTOM OF STACK
	BLT A,(P)		;RESTORE THE STACK
	MOVSI 16,CMDACS		;MAKE BLT POINTER
	BLT 16,16		;RESTORE REST OF AC'S
	JRSTF @REPARA		;TRANSFER BACK TO JUST AFTER .CMINI CALL

;COME HERE TO PROMPT FOR NEW COMMAND OR NEW PROMPT LINE OF COMMAND.
;CALL THIS ROUTINE WITH POINTER TO PROMPT IN A, OR 0 IF NO PROMPT.

DPROMP::	CAIN A,0		;ANY PROMPT?
	HRROI A,[0]		;NO, POINT TO A NULL STRING
	MOVEM A,SBK+.CMRTY	;SAVE POINTER TO PROMPT
	POP P,REPARA		;REMEMBER REPARSE ADDRESS
	DMOVEM 0,CMDACS+0	;SAVE AC'S
	MOVE 1,[2,,CMDACS+2]
	BLT 1,CMDACS+17
	HRL A,CMDFRM		;SAVE FROM BOTTOM OF STACK
	HRRI A,CMDPDL		;MOVE DATA TO COMND PDL AREA
	HRRZ B,P		;SEE WHERE TOP OF STACK IS NOW
	SUB B,CMDFRM		;CALCULATE NUMBER OF WORDS
	BLT A,CMDPDL(B)		;SAVE THE STACK
	PUSH P,REPARA		;MAKE STACK LIKE IT WAS
	HRLI A,100		;SOURCE OF COMMAND
	HRRI A,101		;REGULAR PRIMARY OUTPUT
	MOVEM A,SBK+.CMIOJ
	MOVEI A,[FLDDB. .CMINI]	;TYPE PROMPT
	CALL RFIELD
	RET			;RETURN TO CALLER

;READ A FIELD ROUTINE.  GIVE IT ADDRESS OF FUNCTION BLOCK IN A.
;JRSTS TO CMDERR IF ERROR.  A AND B WILL HAVE
;RESULT OF COMND JSYS IN THEM.

RFIELD::
	CALL RFLDE		;READ FIELD, SKIP IF SUCCESS
	 JRST CMDERR		;FAILED, GO PROCESS ERROR
	RET			;SUCCESS

;ROUTINE TO READ A FIELD AND SKIP IFF SUCCESSFUL.  A,B, AND C WILL HAVE
;RESULT OF COMND JSYS IN THEM UPON RETURN.

RFLDE::	MOVE B,A		;PUT FUNCTION BLOCK POINTER IN B
	MOVEI A,SBK		;POINTER TO STATE BLOCK IN A
	COMND			;READ FIELD OF COMND
	 ERJMP R		;ERROR IN COMND JSYS
	TXNE A,CM%NOP		;DID COMMAND PARSE CORRECTLY?
	 RET			;NO, SINGLE RETURN
	RETSKP			;YES, SKIP RETURN

;READ A FIELD AND REQUIRE CARRIAGE RETURN AFTER IT FOR CONFIRMATION

CFIELD::	STKVAR <<VALUES,2>>
	CALL RFIELD		;READ THE FIELD
	DMOVEM A,VALUES		;SAVE DATA FROM FIELD
	CONFRM			;GET CONFIRMATION
	DMOVE A,VALUES		;GET VALUES OF FIELD
	RET			;RETURN TO CALLER

;COMND JSYS INITIALIZATION ROUTINE.  CALL ONLY ONCE AT BEGINNING OF
;PROGRAM.
;ALWAYS CALL THIS ROUTINE AT A LESS-THAN-OR-EQUALLY NESTED LOCATION
;WITHIN THE PROGRAM IN COMPARISON WITH ANY SUBSEQUENT CALL TO THE COMND
;JSYS EXECUTION ROUTINES

CMDINI::	MOVEI A,REPARS		;REPARSE ADDRESS
	MOVEM A,SBK+.CMFLG
	HRROI A,CMDBUF		;POINTER TO COMMAND BUFFER
	MOVEM A,SBK+.CMBFP
	MOVEM A,SBK+.CMPTR	;POINTER TO NEXT FIELD
	MOVEI A,CMDBLN*5	;ROOM FOR TYPIN
	MOVEM A,SBK+.CMCNT
	SETZM SBK+.CMINC	;NO UNPARSED CHARACTERS YET
	HRROI A,ATMBUF		;POINTER TO ATOM BUFFER
	MOVEM A,SBK+.CMABP
	MOVEI A,ATMBLN*5
	MOVEM A,SBK+.CMABC	;ROOM IN ATOM BUFFER
	MOVEI A,CJFNBK		;POINTER TO JFN BLOCK
	MOVEM A,SBK+.CMGJB
	MOVEM P,CMDFRM		;REMEMBER BEGINNING OF STACK
	RET
   >	;END OF IFN REL

END