C
C
C-----------------------------------------------------------------------------
C
C	PROGRAM:	ASMBLE
C
C	AUTHOR:		Jan H. Belgraver
C
C	DATE:		9-NOV-81
C
C	VERSION:	V1.0
C
C	PURPOSE:	Spawns MAC with command input line.
C			OBJ- and LST-files are purged on exit.
C			Switches entered by user other than /SP are illegal.
C
C	BUILDING:	@ASMBLEBLD.CMD:
C			ASMBLD,ASMBLD/-SP=ASMBLD
C			/
C			TASK=...ASM
C			ACTFIL=1
C			//
C
C-----------------------------------------------------------------------------
C
C

C
C
	PROGRAM 	A S M B L E

	LOGICAL*1	BUF(80), SP(4), PIPB(24)

	REAL		MCR

	REAL*8		R8(3)

	EQUIVALENCE	(PIPB(1),R8(1))

	DATA	SP	/ '/','-','S','P' /
	DATA	MCR	/ 6RMCR... /
	DATA	R8	/ '.OBJ;*/P','U,.LST;*','/PU' /

	CALL	GETMCR (BUF)		! Get command line.

	BUF(1)	= 'M'			! Convert taskname into MAC for later.
	BUF(2)	= 'A'
	BUF(3)	= 'C'
	I	= 4			! Points to 1st byte output cmd-string
	DO	10 K= 5, 80		! Check input cmd-string.
	IF	(BUF(K).EQ.'.') GOTO 99	! Following filetype illegal, exit.
	IF	(BUF(K).EQ.'/') GOTO 12	! Check kind of switch.
	IF	(BUF(K).LT.32)  GOTO 14	! End of string found.
10	CONTINUE

12	I	= 0
	DO	13 L= K, 80
	IF	(BUF(L).LT.32) GOTO 14
	I	= I + 1
13	SP(I)	= BUF(L)

14	BUF(K)	= ','			! Add colon
	KNC	= K - 1
	NCH	= K - 1 - 4
	J	= 4
	DO	15 L= K+1, K+NCH
		J = J + 1
		BUF(L) = BUF(J)
15	CONTINUE

	J	= 0
	DO	16 L= K+NCH+1, K+NCH+I
		J = J + 1
		BUF(L) = SP(J)
16	CONTINUE
	L	= K + NCH + I + 1

17	BUF(L)	= '='
	J = 4
	DO	18 K= L+1, L+NCH
		J	= J + 1
		BUF(K)	= BUF(J)
18	CONTINUE

	WRITE	(5,100) (BUF(J),J=1,L+NCH)
100	FORMAT	(' ', 80A1)

	NCH	= L + NCH
	CALL	SPAWN  (MCR,,,1,,,,BUF,NCH,,,IDS)
	CALL	WAITFR (1)

	J	= 0
	DO	19 I= KNC+1, KNC+19
		J	=J+1
		BUF(I)	=PIPB(J)
19	CONTINUE

	BUF(1)	= 'P'
	BUF(2)	= 'I'
	BUF(3)	= 'P'
	WRITE	(5,100) (BUF(J),J=1,KNC+19)
	CALL	SPAWN  (MCR,,,1,,,,BUF,KNC+19,,,IDS)
	CALL	WAITFR (1)

C	STOP	'Assembling and Purging OBJ and LST files'
	CALL	EXIT

99	STOP	'*** ERROR *** " . " in string NOT allowed'
	END