Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0062/meta2.mac
There are 2 other files named meta2.mac in the archive. Click here to see a list.
	TITLE	%META2 SUPPORT PACKAGE -- MICHAEL GREEN
	ENTRY	%BLOCK,%LOOK,%SET,%CHECK,%LIST,%BEGIN,%END
	ENTRY	%RESET,%COPYL,%COPYI,%ERROR,%TYPE,%STR,%LEN
	ENTRY	%GEN,%UNTIL,%TST,%PUSH,%POP,%ID,%NUM,%CLEAR
	ENTRY	%SCAN,%GETNM,%PUTNM,%XLEN,%XBLK,%GET,%PUT
	ENTRY	%LEVEL,%SYMB,%XSYMB,%BLEVL,%CLEVL,%FIN
	ENTRY	%MAKND,%SETRE,%CALND,%DMPTR,%CPYDC,%MARK
	EXTERN	%MESS1,%MESS2
	SEARCH JOBDAT

%RESET:	0
	JRST	RESET-1
	0
	SETOM	CCLSW
	MOVE	%RESET+2
	MOVEM	%RESET
	OPEN	3,CCLD
	JRST	RESET
	INBUF	3,2
	HRRZ	.JBFF
	MOVEM	JOBFFS
	JRST	.+4
	AOS	%RESET
RESET:	SETZM	CCLSW
	CALL	[SIXBIT/RESET/]
	MOVE	P,[IOWD ^D512,PDL]
	MOVE	STK1,[IOWD ^D128,HOLD]
	MOVE	STK2,[IOWD ^D512,TREE]
	MOVEM	STK1,SAVSTK
	MOVEM	STK2,SAVSTK+1
	SETZM	%MARK
	SETZM	ERRLN
	HRLZI	F,SUCCES
	MOVE	BUFFPT,[POINT 7,SCANBF]
	OPEN	TTYD
	HALT
ASKOUT:	SKIPLE	CCLSW
	JRST	ASKCOM
	SKIPE	CCLSW
	JRST	RDCCL
	MOVEI	015
	PUSHJ	P,TTYOUT
	MOVEI	012
	PUSHJ	P,TTYOUT
	MOVEI	"*"
	PUSHJ	P,TTYOUT
	PUSHJ	P,FORCET
ASKCOM:	MOVE	1,[POINT 7,%MESS1]
	ILDB	1
	CAIE	":"
	JRST	.-2
	ILDB	1
	MOVEM	1,CCLMSG
	PUSHJ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	PUSHJ	P,%TYPE
	ASCIZ	/?CAN NOT CREATE OUTPUT FILE/
	JRST	RESET

IODEV:	SETZ	DEV,
	SETZ	FILE,
	SETZ	EXT,
LOOKNM:	SETZ	NAME,
	PUSHJ	P,TTYIN
	IDPB	CCLMSG
	CAIN	015
	JRST	LOOKNM+1
	CAIGE	"0"
	JRST	DELIM
	CAIG	"9"
	JRST	PACKNM
	CAIGE	"A"
	JRST	DELIM
	CAIG	"Z"
	JRST	PACKNM
	CAIGE	141
	JRST	DELIM
	CAIG	172
	JRST	PACKNM+1
IODEVR:	PUSHJ	P,%TYPE
	ASCIZ	/?ILLEGAL COMMAND/
	JRST	RESET
PACKNM:	XORI	40
	ANDI	77
	TLNE	NAME,770000
	JRST	LOOKNM+1
	LSH	NAME,6
	OR	NAME,
	JRST	LOOKNM+1
DELIM:	JUMPE	NAME,.+5
	TLNE	NAME,770000
	JRST	.+3
	LSH	NAME,6
	JRST	.-3
	CAIN	":"
	JRST	STRDEV
	CAIN	"."
	JRST	STRFIL
	CAIN	"_"
	JRST	.+5
	CAIN	"!"
	JRST	RUN
	CAIE	012
	JRST	IODEVR
	JUMPE	FILE,.+2
	SKIPA	EXT,NAME
	MOVE	FILE,NAME
	JUMPN	DEV,.+2
	HRLZI	DEV,(SIXBIT/DSK/)
	POPJ	P,
STRFIL:	JUMPN	FILE,IODEVR
	SKIPN	FILE,NAME
	JRST	IODEVR
	JRST	LOOKNM
STRDEV:	JUMPN	DEV,IODEVR
	SKIPN	DEV,NAME
	JRST	IODEVR
	JRST	LOOKNM

RDCCL:	SETZM	CCLINF+2
	SETZM	CCLINF+3
	MOVE	2,[POINT 7,%MESS1]
	MOVEI	0,0
	ILDB	1,2
	CAIN	1,":"
	JRST	SIXPAK
	ROT	1,-6
	ROTC	0,6
	TRC	0,40
	CAIGE	0,10000
	JRST	.-7
	JRST	.+5
SIXPAK:	CAIL	0,10000
	JRST	.+3
	LSH	0,6
	JRST	.-3
	MOVEM	CCLINF
	MOVSM	T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EMP1
	JUMPE	TEMP3,.+2
	SOJA	TEMP2,.-2
	IDIVI	TEMP2,5
	HRLZI	TEMP2,(TEMP2)
	HRRI	TEMP2,SAVEBF
	HRRZI	TEMP1,1(STK2)
	HRLI	TEMP1,(POINT 7,0)
	PUSH	STK1,TEMP1
	PUSH	STK2,(TEMP2)
	AOBJN	TEMP2,.-1
	POPJ	P,
CPYDCT:	SKIPGE	TEMP1,CURRNT
	JRST	%SET+2
	PUSH	STK1,CURRNT
	HRROS	(STK1)
	POPJ	P,

SCATEN=	040000
BACKUP=	100000
NDELET=	200000
SUCCES=	400000
P=	17
F=	16
TEMP1=	13
TEMP2=	14
TEMP3=	15
TEMP4=	11
TEMP5=	10
BUFFPT=	5
CHAR=	12
STK1=	4
STK2=	3

HOLD:	BLOCK	^D128
TREE:	BLOCK	^D512
%MARK:	BLOCK	1
SAVSTK:	BLOCK	2

SCANBF:	BLOCK	^D64
SAVEBF:	BLOCK	^D32

STACK:	BLOCK	3
STACKL:	POINT	7,STACKA+0*^D64*^D16-1,^D34
STACKU:	POINT	7,STACKA+1*^D64*^D16-1,^D34
	POINT	7,STACKA+2*^D64*^D16-1,^D34
	POINT	7,STACKA+3*^D64*^D16-1,^D34
STACKA:	BLOCK	3*^D64*^D16

PDL:	BLOCK	^D512

%LIST:	BLOCK	1
DICTPT:	BLOCK	^D16
DICTCH:	BLOCK	^D16
CURRNT:	BLOCK	1
BLOCKI:	BLOCK	^D16
BLOCK:	BLOCK	^D16
BLOCKP:	BLOCK	1
BLOCKN:	BLOCK	1
SCANPT:	BLOCK	1

FLAGS:	BLOCK	^D256
CONTEX:	BLOCK	^D256
SYMBOL:	BLOCK	^D256
DICT:	BLOCK	^D512

	END