Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0001/mcr20.mac
There is 1 other file named mcr20.mac in the archive. Click here to see a list.
;<LEMAIRE-P.TEST>MCR20.MAC.3, 22-Mar-78 14:27:53, Edit by LEMAIRE-P
;<LEMAIRE-P.TEST>NEWMCR.MAC.4, 22-Mar-78 12:08:09, Edit by LEMAIRE-P
	TITLE	MCR20 - ROUTINE TO GET COMMAND INPUT LINE
	SEARCH	MONSYM,MACSYM
	ENTRY	MCR20
R1==1
R2==2
R3==3
R4==4

DPT=5		; Destination PoinTer
SWCHS=DPT+1	; SWitCHeS bits implemented are:
 SPSW=1		 ; SPace SWitch
 ENDSW=2	 ; END of line SWitch
TBLPT=SWCHS+1	; translate TaBLe PoinTer
NCHAR=TBLPT+1	; New CHARacter

TMP=0
PARAM=16

SP=17

	SALL

	DEFINE	XFER (TO,FROM,LEN<1>)<
	MOVE	TMP,[XWD FROM,TO]
	BLT	TMP,TO+LEN-1>

STKLEN==20
STACK:	BLOCK	STKLEN


BPRMPT:	Z				; NULL PROMPT

ATMLEN==^D120
ATOM:	BLOCK	ATMLEN/5+1
ATMPTR:	POINT	7,ATOM


TXLEN==^D120
TEXT:	BLOCK	TXLEN/5+1
TXTPTR:	POINT	7,TEXT			; pointer into TEXT

POSINI:	EXP	46			; initial position for text


					PAGE
; **************************
; *			   *
; *  COMMAND STATE BLOCK   *
; *			   *
; **************************

.HERE==.
CMFLG:	Z			; reparse address
CMIOJ:	.PRIIN,,.PRIOU		; input/output device
CMRTY:	POINT	7,BPRMPT	; CTRL/R buffer
CMBFP:	POINT	7,TEXT		; pointer to beginning of user's input?
CMPTR:	POINT	7,TEXT		; pointer to next field to be parsed
CMCNT:	TXLEN			; count of space in buffer
CMINC:	Z			; count of unparsed chars.
CMABP:	POINT	7,ATOM		; pointer to atom buffer?
CMABC:	ATMLEN			; atom buffer length
CMGJB:	JFNBLK			; GTJFN argument block

CSLEN==.-.HERE
CSTATE:	BLOCK	CSLEN

; ********************************
; *				 *
; *  FUNCTION DESCRIPTOR BLOCKS  *
; *				 *
; ********************************

	SALL

FINIT:	FLDDB.	.CMINI

FFILE:	FLDDB.	.CMFIL

FSTRNG:	FLDDB.	.CMTXT


; **************************
; *			   *
; *  GTJFN argument block  *
; *			   *
; **************************

JFNBLK:
GJGEN:	GJ%OLD
GJSRC:	.PRIIN,,.PRIOU
GJDEV:	Z
GJDIR:	Z
GJNAM:	Z
GJEXT:	TXEXE
GJPRO:	Z
GJACT:	Z
GJJFN:	Z
	BLOCK	6

TXEXE:	ASCIZ	/EXE/
				PAGE
  ; translate table for input follows

TTABL:	BYTE	(7)0,1,2,3,4, 5,6,7,10,40, 12,13,14,15,16
	BYTE	(7)17,20,21,22,23, 24,25,26,27,30, 31,32,33,34,35
	BYTE	(7)36,37,40,41,42, 43,44,45,46,47, 50,51,52,53,54
	BYTE	(7)55,56,57,60,61, 62,63,64,65,66, 67,70,71,72,73
	BYTE	(7)74,75,76,77,100, 101,102,103,104,105
	BYTE	(7)106,107,110,111,112, 113,114,115,116,117
	BYTE	(7)120,121,122,123,124, 125,126,127,130,131
	BYTE	(7)132,133,134,135,136, 137,140,101,102,103
	BYTE	(7)104,105,106,107,110, 111,112,113,114,115
	BYTE	(7)116,117,120,121,122, 123,124,125,126,127
	BYTE	(7)130,131,132,173,174, 175,176,177

SPACE=40	; used by immediate mode test instructions
LF=12		; me too
CR=15		; and me

NWORD:	ASCII	/     /		; New WORD  used to create hollerith
NWPT:	POINT	7,NWORD,6	; New Word PoinTer
			PAGE
	SUBTTL	PARSE PAST PROGRAM NAME
MCR20:	MOVEI	R1,.RSINI		; initialize rescan buffer
	RSCAN
	 ERJMP	MCRERR			; give null return if error here

	JUMPE	R1,MCRERR		; exit if buffer is empty

	XFER	CSTATE,CMFLG,CSLEN	; initialize state block
	MOVEI	R1,CSTATE		; initialize COMND
	MOVEI	R2,FINIT
	COMND

BEGIN:	MOVEI	R2,FFILE		; Parse for filename (program name)

PHASE1:	COMND				; parse past 'BLAST'
	TXNE	R1,CM%NOP		; Did I get one?
	JRST	MCRERR			; NO, return with 'no-string'

	JXO	R1,CM%EOC,MCRERR	; 'no-string' if end-of-line here

	MOVEI	R2,FSTRNG		; move string to atom buffer
	COMND

; PROCESS COMMAND LINE NOW

	MOVE	DPT,(PARAM)	; get destination pointer
	SUBI	DPT,1		;  set it before first char

	MOVEI	SWCHS,SPSW	; initialize switches
	MOVE	TBLPT,[POINT 7,TTABL,6]	; set up TTABL pointer

	MOVE	R2,ATMPTR		; initialize text pointer

LOOP:	ILDB	R1,R2			; get next input byte
	JUMPE	R1,TERM			; get out on null

	ADJBP	R1,TBLPT	; index translate table
	LDB	NCHAR,R1	; get function byte

	CAIE	NCHAR,SPACE	; is it a space?
	JRST	NOTERM		; NO, go to next test
	TRNE	SWCHS,SPSW	; YES, is space switch set?
	JRST	LOOP		; YES, ignore this space
	IORI	SWCHS,SPSW	; NO, set space switch and..
	JRST	BUMPIN		;  send space to destination

TERM:	IORI	SWCHS,ENDSW	; YES, set terminator switch
	TRNE	SWCHS,SPSW	; is space switch set?
	JRST	NOBMP		; YES, overwrite last char (space)
   ; SKIPing next instruction would be slower than executing it,
	; result is irrelevent so....
NOTERM:	ANDI	SWCHS,-1-SPSW	; clear space switch

BUMPIN:	ADDI	DPT,1		; bump destination pointer

NOBMP:	DPB	NCHAR,NWPT	; put byte in high order position
	MOVE	NCHAR,NWORD	; pick up whole word
	MOVEM	NCHAR,(DPT)	; send to destination
	TRNN	SWCHS,ENDSW	; was it a terminator?
	JRST	LOOP		; NO, go around again
	SUB	DPT,(PARAM)	; =length without <term>

	SKIPA			; skip reassignment of DPT
MCRERR:	MOVEI	DPT,0		; set 'no-string' return code

	MOVEM	DPT,@1(PARAM)	; send return code to caller
	RET

	LIT

	END