C
C COPYRIGHT (C) 1976
C DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
C
C THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
C ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
C THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
C SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
C VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
C EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
C THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
C SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
C
C THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
C WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
C MITMENT BY DIGITAL EQUIPMENT CORPORATION.
C
C DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
C OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY
C DEC.
C
C
C EDIT #1	M. HEBENSTREIT		12/15/75
C 001	28-APR-76 (RCHM)	MASSIVE COMMENTS AND VARIOUS CHANGES.
C
C PROGRAM TO READ CODE FILE CALLED 'CODE SRC' ON
C DAT SLOT 1 AND FROM ANSWERS, GENERTATE A BATCH
C JOB FILE CALLED 'RSX BAT' ON DAT SLOT 2.
C
C DAT SLOTS 1 AND 2 SHOULD BE ASSIGNED TO DISK
C DAT SLOTS 12(8) AND 13(8) TO A TTY.
C
C
C	BUILD PROCEDURE PROCESSOR INSTRUCTION SET
C
C MODE	MNEM.	MEANING
C
C 1	OTT	OUTPUT TEXT FIELD OF INSTRUCTION TO THE TELETYPE.
C
C 2	NJMP	READ A RESPONSE FROM THE USER AND JUMP TO "JUMP" IF
C		THE RESPONSE IS "N"
C
C 3	YJMP	READ A RESPONSE FROM THE USER AND JUMP TO "JUMP" IF
C		THE RESPONSE IS "Y"
C
C 4	OTF	OUTPUT THE TEXT FIELD OF THE INSTRUCTION TO FILE ON
C		DAT SLOT "FILE"
C
C 5	BR	BRANCH TO "JUMP"
C
C 6	SET	SET IFLAG("FLAG") = "FILE"
C
C 7	JMPNE	IF IFLAG("FLAG") >< "FILE" GO TO "JUMP"
C
C 8	JMPEQ	IF IFLAG("FLAG") = "FILE" GO TO "JUMP"
C
C 9	BBR	UNCONDITIONAL BACKWARDS BRANCH
C
C 10	INCTW	IFLAG("FLAG") = IFLAG("FLAG") + 1 IF IFLAG("FLAG")
C		ARE NOT EQUAL TO "FILE" CONTINUE PROCESSING. ELSE
C		OUTPUT THE TEXT FIELD OF THE INSTRUCTION TO DAT SLOT
C		"JUMP"
C
C 11	INCJE	INCREMENT IFLAG("FLAG") IF IFLAG("FLAG") = "FILE" GO TO
C		"JUMP"
C
C 12	DREAD	IFLAG("FLAG") IS SET EQUAL TO THE DECIMAL STRING IN THE
C		INPUT RESPONSE.
C
C 13	AON	APPEND OCTAL NUMBERS TO THE TEXT AND OUTPUT THE VALUE TO
C		FILE.
C
C 14	OBLK	WRITE A 10 CHARACTER OCTAL STRING REPRESENTING THE NUMBER
C		OF BLOCKS ON DISK TO ALLOCATE.
C
C 15	DONE	CLOSE INPUT AND OUTPUT FILES AND STOP THE BUILD
C		PROCEDURE PROCESSOR.
C
C 16	OREAD	IFLAG("FLAG") IS SET EQUAL TO THE OCTAL STRING IN THE
C		INPUT RESPONSE.
C
C 17	TWEQ	FLAG=FILE JUMP "TEXT"
C		FLAG IS CHECKED FOR EQUALITY. IF THIS IS TRUE TEXT IS
C		WRITTEN TO DAT SLOT JUMP.
C
C 18	TWNE	FLAG=FILE JUMP "TEXT"
C		AS ABOVE BUT ON THE NOT EQUAL TEST.
C
C
C
C
C	INSTRUCTION INPUT FORMAT.
C
C	ALL INSTRUCTIONS ARE ASSUMED TO BE 80 CHARACTERS IN LENGTH AND
C	WILL BE BLANK FILLED, BY FORTRAN, UPON INPUT. THE INSTRUCTION
C	FORMAT IS AS FOLLOWS:
C
C	LABEL MODE JUMP FILE FLAG TEXT
C
C	INPUT FORMAT IS :
C
C	I3,1X,I2,1X,I3,1X,I6,1X,I2,1X,60A1
C
C	LABEL = I3
C	MODE = I2
C	JUMP = I3
C	FILE = I6
C	FLAG = I2
C	TEXT = 60A1
C
	INTEGER LABEL,MODE,JUMP,FILE,FLAG,ANSWER,IFLAG(99),TARGET
	REAL RSX(2),CODE(2)
	INTEGER TEXT(61),BLANK
	INTEGER ITEXT(60)
	EQUIVALENCE (ITEXT(1),TEXT(1))
	DATA CODE,RSX/'CODE ',' SRC ','RSX  ',' BAT '/
	DATA BLANK/' '/
	CALL SEEK(1,CODE)
	CALL ENTER(2,RSX)
110	FORMAT(1X,'ERROR - UNSATISFIED JUMP TO ',I3)
101	FORMAT(I3,1X,I2,1X,I3,1X,I6,1X,I2,1X,60A1)
201	FORMAT(61A1,19X)
	CALL SYSDEV(IFLAG(99))
1001	READ(1,101)LABEL,MODE,JUMP,FILE,FLAG,ITEXT
20	GOTO(1,2,3,4,5,6,7,8,9,90,91,92,93,94,2001,95,96,97),MODE
30	TARGET=JUMP
3001	READ(1,101,END=4001)LABEL,MODE,JUMP,FILE,FLAG,ITEXT
	IF(LABEL.EQ.TARGET)GOTO 20
	GOTO 3001
1	CONTINUE
C	OUTPUT TEXT TO TTY
	CALL TTOUT(TEXT)
	GOTO 1001
2	CONTINUE
C	Y/N ROUTINE (YES PROCEED/NO JUMP)
	CALL TTOUT(TEXT)
	CALL REPLY(ANSWER)
	GOTO(1001,30),ANSWER
3	CONTINUE
C	Y/N ROUTINE (NO PROCEED/YES JUMP)
	CALL TTOUT(TEXT)
	CALL REPLY(ANSWER)
	GOTO(30,1001),ANSWER
4	CONTINUE
C	OUTPUT TEXT TO FILE "FILE"
C
C	COMPRESS ALL BLANKS OUT OF TRAILING PORTION OF STRING.
C
	DO 115 I=1,60
	IF(TEXT(61-I).NE.BLANK) GO TO 120
115	CONTINUE
120	IF(JUMP.EQ.0) JUMP=#15
	TEXT(62-I)[0:6]=JUMP
304	WRITE(FILE,201)TEXT
	GOTO 1001
5	CONTINUE
C	JUMP TO LABEL
	GOTO 30
6	CONTINUE
C	SET FLAG WITH VALUE 'FILE'
	IFLAG(FLAG)=FILE
	GOTO 1001
7	CONTINUE
C	TEST FLAG AND JUMP IF VALUE NE 'FILE'
	IF(IFLAG(FLAG).NE.FILE)GOTO 30
	GOTO 1001
8	CONTINUE
C	TEST FLAG AND JUMP IF VALUE EQ 'FILE'
	IF(IFLAG(FLAG).EQ.FILE)GOTO 30
	GOTO 1001
9	CONTINUE
C	BACK UP TO LABEL
	REWIND 1
	GOTO 30
90	CONTINUE
C	INCREMENT FLAG "FLAG" AND TEST VALUE "FILE" OUTPUT FILE "JUMP" IF EQ
	IFLAG(FLAG)=IFLAG(FLAG)+1
	IF(IFLAG(FLAG).NE.FILE)GOTO 1001
	FILE=JUMP
	JUMP=0
	GOTO 4
91	CONTINUE
C	INCREMENT FLAG "FLAG" AND TEST VALUE "FILE" JUMP TO "JUMP" IF EQ
	IFLAG(FLAG)=IFLAG(FLAG)+1
	IF(IFLAG(FLAG).EQ.FILE)GOTO 30
	GOTO 1001
92	CONTINUE
C	MODE 12 - READ A DECIMAL NO. AND STORE IN IFLAG
	CALL TTOUT(TEXT)
	CALL GNUM(IFLAG(FLAG),FILE,10)
	GOTO 1001
93	CONTINUE
C	MODE 13 - WRITE TEXT TO FILE AND APPEND NUMBER IN IFLAG
	CALL MODE13(TEXT,IFLAG(FLAG),8)
	GOTO 1001
94	CONTINUE
C	MODE 14 - WRITE K WORDS IN IFLAG TO FILE AS OCTAL BLOCKS
	ITMP= IFLAG(FLAG)*4
	WRITE(2,941) ITMP
941	FORMAT (4X,O6)
	GOTO 1001
95	CONTINUE
C
C	OCTAL READ AND STORE IN FLAG.
C
	CALL GNUM(IFLAG(FLAG),FILE,8)
	GO TO 1001
C
C TEST AND WRITE IF EQUAL.
C
96	CONTINUE
	IF(IFLAG(FLAG).NE.FILE) GO TO 1001
	FILE=JUMP
	JUMP=0
	GO TO 4
C
C TEST AND WRITE IN NOT EQUAL.
C
97	CONTINUE
	IF(IFLAG(FLAG).EQ.FILE) GO TO 1001
	FILE=JUMP
	JUMP=0
	GO TO 4
4001	WRITE(10,110)TARGET
2001	ENDFILE 2
	ENDFILE 1
	STOP
	END
