Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/freeze.mac
There are 2 other files named freeze.mac in the archive. Click here to see a list.
COMMENT * freeze, SIMULA specification;
OPTIONS(/E:QUICK,ZYLFRZ);
PROCEDURE freeze(restartcode); NAME restartcode; INTEGER restartcode;
COMMENT Stops the program after preparing it for a SAVE command.
When continued directly (CONTINUE instead of SAVE), restartcode will be zero,
otherwise restartcode = offset + 1, where offset = restart address - .JBSA<RH>.
The offset can be specified in a RUN UUO or implicitly by giving the absolute
starting address in a START command. The limits on offset are:
	0<=offset<=15, implying 0<=restartcode<=16.
Sysin and Sysout, but no other files, may be open when freeze is called.
Sysin and Sysout will be closed and then reopened on continuing or restarting.
Note that Sysin will be read from the start again if it is not a terminal, and
Sysout will be overwritten unless it is a terminal or written in append mode.
;

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

	TITLE	freeze
	ENTRY	ZYLFRZ
	SUBTTL	SIMULA utility, Lars Enderin Mar 1976

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

	;! Edits: [135,165,277,307]

	sall
	search	simmac,simmcr,simrpa
	macinit

	ENTRY	.ZYLCL,.ZYLOP,.ZYLRJ,.ZYLSJ,.ZYLRT

	IF1,<
	qocti==0
	IFDEF OCTI,<qocti==1>
	>
OPDEF	PORTAL		[JRST	1,]
OPDEF	XEC		[PUSHJ	XPDP,]
OPDEF	LINKBUFF	[XEC	OCIND]
OPDEF	sysclose	[JSR	.ZYLCL]	;! Close Sysin and Sysout
OPDEF	sysopen		[JSR	.ZYLOP]	;! Open again
OPDEF	jobsave		[JSR	.ZYLSJ]	;! Save job status
OPDEF	jobrestore	[JSR	.ZYLRJ]	;! Restore it

	DEFINE	acsave<
	LI	s0
	BLT	s0+x17
	>
	DEFINE	acrestore<
	MOVSI	x17,s0
	BLT	x17,x17
	>

	DEFINE	type(t)<
	OUTSTR	[ASCIZ\
t
\]
>
	;! Local definitions ;!
	xfil==XWAC1

	.JBREL==44
	.JBHRL==115
	.JBSA==	120
	.JBOPC==130
	.JBCOR==133
	.JBFF== 121
	.JBDDT==74
	.JBSDD==114
	.JB41==41
	.JBS41==122
	.JBREN==124
	.JBAPR==125


	X17==17
	XHRL==X14
	XJBSA==X13
	XST0==X12
	XJBREN==X11

	rmax==	^D16	;! Max restartcode value
ZYLFRZ:	PROC
	IFONA	ZFLVTD(XWAC1)
	 RTSERR	100	;! Assignment illegal if value, not address
	LOWADR
	STD	XWAC1,YOBJAD(XLOW)	;! Save parameter
	LOOP	;! Check for open files
		SETOFF	SDSCLO(XLOW)	;! Do not close Sysin and Sysout now
		EXEC	IOCLA
	AS	;! Long as open files do exist
		JUMPE	FALSE
		type	(?ZYLFRZ Files open on call to FREEZE)
		RTSERR	QDSCON,214
		GOTO	TRUE
	SA
	SETZ
	EXEC	SAGC	;! Collect garbage

	jobsave
	MOVSI	X1,1	;! Eliminate hiseg
	CORE	X1,
	NOP
	LI	restart
	HRLM	.ZYLRS
	type	([ZYLFRZ  FREEZE called. Do: SAVE <filename> or CONTINUE])
	type	([Continue after SAVE with START command.])
	EXIT	1,
	type	([Job continued])
	SETZM	.ZYLRS
restart:
	jobrestore
	SETZB	XWAC1,XWAC2
	EXCH	XWAC1,YOBJAD(XLOW)
	EXCH	XWAC2,YOBJAD+1(XLOW)
	LF	X1,ZFLZBI(,XWAC1)
	ADDI	X1,(XWAC2)
	HRRE	.ZYLRS
	ST	(X1)
	CALLOW
	RETURN
	EPROC

.ZYLRS::Z	;! Restart address, returncode
	PORTAL	.+1+rmax	;! Offset=-1 from RUN ends up here
.ZYLRT:	REPEAT	rmax,<PORTAL	.+rmax+1>
	REPEAT	rmax+1,<SOS	.ZYLRS>
	MOVS	X1,.ZYLRS
	BRANCH	(X1)

	IFE	qocti,<
OCTI:	PROC	;! (re)initialize for interrupts and UUO:s
	LI	OCTR
	ST	.JBAPR
	LI	AP.ILM!AP.NXM!AP.FOV!AP.AOV!AP.REN
	JRSTF	@[004000,,.+1]
	APRENB	
	L	[PUSHJ	XPDP,OCUU]
	ST	.JB41
	RETURN
	EPROC
>
	SUBTTL	jobsave

.ZYLSJ:	PROC
	Z		;! Return address by JSR
	CFORBID
	edit(307)	;! Save info only if not done before
	SKIPE yhnam	;! [307]
	 GOTO L2	;! [307]
	edit(277)	;! Save info to GETSEG hiseg
	MOVSI	YOCGSB(XLOW)
	HRRI	ydev
	BLT	yppn
	L	[-2,,.GTPRG]	;! Hiseg name
	GETTAB
	 SETO
	HRROI	X1,.GTPRG	;! Program name
	GETTAB	X1,
	 SETZ	X1,
	IF	;! Hiseg from same file as lowseg
		JUMPE	TRUE
		CAME	X1
		 GOTO	FALSE
	THEN	;! Note where program came from
		ST	X1,yhnam
		HRROI	.GTRDV	;! Run device
		GETTAB
		 SETZ
		SKIPN
		 MOVSI 'DSK'
		ST	ydev
		HRROI	.GTRDI	;! Run directory
		GETTAB
		 SETZ
		ST	yppn
	FI
L2():!	sysclose
	SETZ	XST0,
	IF	;! Channel 0 active
		DEVCHR	XST0,
		JUMPE	XST0,FALSE
	THEN	;! Save status in XST0, then release channel
		GETSTS	XST0
		HRROS	XST0	;! Make sure XST0=/=0
		CLRBFI		;! Get rid of type-ahead
		RELEASE
	FI
	L	XJBSA,.JBSA	;! Save old .JBSA
	HRL	.JBREL		;! Lowseg end
	HRRI	.ZYLRT		;! Start address
	ST	.JBSA
	LI	^D17		;! Counter, initial
	HRRM	.ZYLRS
	L	XHRL,.JBHRL
	JSP	.+1		;! Save PC flags
	HRR	.ZYLRT		;! Continue address
	ST	.JBOPC
	LI	XJBREN,ree1	;! .JBREN value
	EXCH	XJBREN,.JBREN
	SETZM	yjbren
	acsave
	L	.JBREL
	TRO	777
	HRL
	ST	.JBCOR
	L	.JBDDT
	ST	.JBSDD
	SETZM	.JBHRL
	SETZM	.JBAPR
	SETZM	.JB41
	BRANCH	@.ZYLSJ
	EPROC


yjbren:	Z
ree1:	ST	yjbren
	HRRZ	.JBOPC
	IF	;! No valid address
		CAIE	-1
		GOTO	FALSE
	THEN	;! Substitute one
		HRRZ	.JBSA
		HRRM	.JBOPC
	FI
	EXCH	yjbren
	type	<[ZYLRJ REENTER deferred]>
	BRANCH	@.JBOPC
	SUBTTL	jobrestore

.ZYLRJ:	PROC
	Z	;! Call by JSR
	LOWADR
	acrestore
	ST	XJBSA,.JBSA
	;! Restore hiseg
	MOVSI	X1,1
		edit(165)
	HLR	X1,.JBCOR	;! [165] May be higher than .JBREL
	CORE	X1,	;! Eliminate any hiseg
	 HALT		;! [165] Not enough
	L	.JBREL	;! [165]
	ST	.JBFF	;! [165]
		edit(277)
	LI	X1,ydev
	GETSEG	X1,
	 HALT
	LOWADR
	IF	;! Not restarted directly
		SKIPN	.ZYLRS
		GOTO	FALSE
	THEN	;! Reset elapsed time, cpu time etc
		SETZ	X1,
		RUNTIM	X1,
		ST	X1,YRUNTM(XLOW)
		ST	X1,YSATIM(XLOW)	;! Last G.C. considered to be here
		SETZM	YSAGCN(XLOW)	;! Number of GC's
		SETZM	YSAGCT(XLOW)	;! Accumulated GC time
		MSTIME	X1,
		ST	X1,YDAYTM(XLOW)
		PJOB	X1,
		ST	X1,YJOBNO(XLOW)
	FI
	acrestore
	IF	;! Channel 0 was active
		JUMPE	XST0,FALSE
	THEN	;! Restore it
		L	x4,YOCBST(XLOW)
		IF	;! Really active
			JUMPE	x4,FALSE
		THEN	;! Do it
			LI	X1,(XST0)
			MOVSI	X2,'TTY'
			HRRI	x3,1(x4)
			HRLI	x3,52+1(x4)
			OPEN	0,X1
			HALT
			LI	x6,23
			LI	x7,2
			HRRI	X1,-1(x3)
			LINKBUFF
			HLRZ	X1,x3
			HRRI	X1,-1(X1)
			LINKBUFF
	FI	FI
	EXEC	OCTI
	sysopen
	EXCH	XJBREN,.JBREN
	IF	;! REENTER was done since job was saved
		SKIPN	yjbren
		GOTO	FALSE
	THEN	;! Let it work now
		JSP	.+1
		HRR	.ZYLRJ
		ST	.JBOPC
		L	.JBREN
		HRRM	.ZYLRJ
	FI
	CALLOW
	BRANCH	@.ZYLRJ
	EPROC
	SUBTTL	sysopen

.ZYLOP:	PROC
	Z	;! Call by JSR
	IF	;! Sysin was open
		HRRZ	xfil,yinout
		JUMPE	xfil,FALSE
	THEN	;! Reopen
		LD	XWAC2,imagei
		LF	X1,ZFICHN(xfil)
		IF	;! On channel 0
			JUMPN	X1,FALSE
		THEN	;! Restore channel table entry
			HRRM	xfil,YIOCHT(XLOW)
		FI
		EXEC	IOOP
	FI
	IF	;! Sysout was open
		HLRZ	xfil,yinout
		JUMPE	xfil,FALSE
	THEN	;! Reopen
		LD	XWAC2,imageo
		LF	X1,ZFICHN(xfil)
		IF	;! On channel 0
			JUMPN	X1,FALSE
		THEN	;! Restore channel table entry
			HRLM	xfil,YIOCHT(XLOW)
		FI
		EXEC	IOOP
			edit(135)
		IF	;![135] Sysout is actually a Printfile
			IFOFF	ZFIPF(xfil)
			GOTO	FALSE
		THEN	;! Restore old LINESPERPAGE, SPACING
			L	ylpsp
			WSF	,ZPFLP(xfil)
		FI
	FI
	BRANCH	@.ZYLOP
	EPROC
	SUBTTL	sysclose

.ZYLCL:	PROC
	Z
	;! Close Sysin and Sysout if open
	SETZM	yinout
	L	xfil,YSYSIN(XLOW)
	IF	;! Open
		IFOFF	ZFIOPN(xfil)
		GOTO	FALSE
	THEN	;! Save address, then close
		LD	OFFSET(ZFIIMG)(xfil)
		STD	imagei
		HRRM	xfil,yinout
		EXEC	IOCL
	FI
	L	xfil,YSYSOUT(XLOW)
	IF	;! Sysout is open
		IFOFF	ZFIOPN(xfil)
		GOTO	FALSE
	THEN	;! Save address, close
		LD	OFFSET(ZFIIMG)(xfil)
		STD	imageo
		HRLM	xfil,yinout
			edit(135)
		IF	;![135] Sysout is actually a Printfile
			IFOFF	ZFIPF(xfil)
			GOTO	FALSE
		THEN	;! Save LINESPERPAGE, SPACING
			WLF	,ZPFLP(xfil)
			ST	ylpsp
		FI
		EXEC	IOCL
	FI
	BRANCH	@.ZYLCL
	EPROC
s0:	BLOCK	^D16	;! Ac save area
imagei:	BLOCK	2
imageo:	BLOCK	2
yinout:	BLOCK	1
			edit(135)
ylpsp:	BLOCK	1	;![135] Saves ZPFLP, ZPFSP (Linesperpage, Spacing)
			edit(277)
ydev:	BLOCK	1	;! GETSEG device
yhnam:	BLOCK	1	;! HISEG name
	BLOCK	2
yppn:	BLOCK	1	;! Directory of hiseg
	Z
	LIT
	END;