perm filename RUN.MAC[SIM,SYS] blob sn#460193 filedate 1979-07-20 generic text, type T, neo UTF8
COMMENT * SIMULA specification;
OPTIONS(/E:CODE,ZYLRUN);
PROCEDURE run(filespec,entrypoint);
VALUE filespec; TEXT filespec; INTEGER entrypoint;
COMMENT Runs the program specified by filespec without closing files.
Normally, an explicit extension should NOT be given.
entrypoint must be in the range 1-16 inclusive.
For a standard CUSP, 1 gives the normal entry point and 2 gives the
secondary entry point (CCL entry).
If the device was not specified or specified as DSK:, and no ppn was
given, SYS: is tried as device on failure.
;

!*;! MACRO-10 code !*;!

	TITLE	run
	ENTRY	ZYLRUN
	SUBTTL	SIMULA utility, Lars Enderin Feb 1976

;!*** Copyright 1976 by the Swedish Defence Research Institute. ***
;!*** Copying is allowed.					***


	sall
	search	simmac,simmcr,simrpa
	macinit

	;! Local definitions ;!

	OPDEF	typefile	[JSR typefile]

	filespec==2
	entrypoint==4
	xdvn==x4
	xnam==x5
	xext==x6
	xppn==x10
	x17==17

ZYLRUN:	PROC
	GOTO	L1
;! Restore jumps to this point
	SETOM	offs
	GOTO	L2
L1():!	SETZM	offs
	L	entrypoint(XCB)
	WHILE	;! Too large or negative offset
		SOJL	TRUE
		CAIG	↑D15
		GOTO	FALSE
	DO	;! Error
		OUTSTR	[ASCIZ/
?ZYLRUN 2nd RUN parameter must be in range [1-16]
/]
		RTSERR	QDSNIN,214
		NEWVALUE
		ST	entrypoint(XCB)
	OD
	SOS	entrypoint(XCB)
L2():!	EXEC	CPNE	;! Create file object
	XWD	0,IOIN	;! Any file class will do
	LD	filespec(XCB)
	STD	OFFSET(ZFISPC)(XWAC1)
	L	[1B<%ZFIBNW>+1B<%ZFINLE>]	;! No buffers, no lookup
	IORM	OFFSET(ZFIBNW)(XWAC1)
	EXEC	CSEN	;! Initialize file info
	OUTSTR	[ASCIZ/
[ZYLRUN Running program:/]
	LI	x2,filespec(XCB)
	typefile

	LF	xdvn,ZFIDVN(XWAC1)
	LF	xnam,ZFINAM(XWAC1)
	LF	xext,ZFIEXT(XWAC1)
	WLF	xppn,ZFIPRG(XWAC1)
	LOWADR
	SKIPL	X1,offs
	MOVS	X1,entrypoint(XCB)
	HRRI	X1,dvn
	SAVEALLACS
	STD	xdvn,dvn
	HRLZM	xext,ext
	SETZM	ext+1
	ST	xppn,ppn
	SETZM	coreas

	RUN	X1,
	LOWADR
	;! Restore ac's
	MOVSI	x17,YUUOAC(XLOW)
	BLT	x17,x17
	IF	;! Device was not SYS and ppn was not given
		JUMPN	xppn,FALSE
		CAMN	xdvn,[SIXBIT'SYS']
		GOTO	FALSE
	THEN	;! Try SYS
		MOVSI	xdvn,'SYS'
		ST	xdvn,dvn
		RUN	X1,
	FI
	Outstr	[ASCIZ/
?ZYLRUN Could not find program
/]
	EXIT	1,
	EXIT


typefile:Z
	LF	X1,ZTVZTE(x2)
	L	X2,X1
	ADD	X2,OFFSET(ZTELEN)(X1)
	SETZ
	EXCH	(X2)	;! Make ASCIZ text of file spec
	OUTSTR	2(x1)
	EXCH	(X2)
	OUTSTR	[ASCIZ/]
/]
	BRANCH	@typefile


offs:	BLOCK	1	;! If non-zero, used as start offset
dvn:	BLOCK	1
nam:	BLOCK	1
ext:	BLOCK	1
	BLOCK	1
ppn:	BLOCK	1
coreas:	BLOCK	1
	EPROC
	LIT
	END;