	.sbttl	COMMON editor definitions (prefix file)
	.nlist
	.dsabl	crf


	.iif ndf, minitab,minitab = 0		; ne minitab screen edit

	.iif ndf, resovr, resovr = 0
	.iif ndf, tedrts, tedrts = 1		; ne RSTS runtime system
	.iif ndf, rsx11m, rsx11m = 0		; ne if RSX11M or VMS
	.iif ndf, rt11	, rt11   = 0		; ne if REAL RT11
	.iif ne	, rt11  , smallrt= 1		; ne to leave out cmds
	.iif ndf, smallr, smallrt= 0		;
	.iif ndf, tedres, tedres = 0		; ne , RSTS reslib

	.iif ndf, $$$abs, $$$abs = 0		; eq , relocatable data
	.iif ne , minitab!rsx11m!rt11!tedres,$$$abs = 0
	.iif ne , minitab!rsx11m!rt11!tedres, tedrts = 0

	.iif ne,  tedrts, $$$abs  = 1		; for RSTS/E run time
	.iif ne,  resovr, $$$abs  = 1
	$$$wrk =  0
	.iif ne,  resovr, $$$wrk  = 2000	; start of the r/w asect
						; system, data is fixed

	.iif ne, rt11&rsx11m, .error ,multiple rt/rsx def
;
;
;	Brian Nelson
;	Computer Services
;	University of Toledo
;	2801 West Bancroft
;	Toledo , Ohio 43606
;
;	(419) 537-2511
;
;
;	
;	
;	Copyright (C) 1978, 1979, 1980, 1981, 1982 Brian Nelson
;	
;	
;	
;	This software is furnished under a license and may
;	be  used  and  copied  only in accordance with the
;	terms of such license and with  the  inclusion  of
;	the  above copyright notice.  This software or any
;	other copies thereof may not be provided or other-
;	wise made available to any other person.  No title
;	to and ownership of the software is hereby  trans-
;	ferred.
;	
;	The information in this  software  is  subject  to
;	change  without notice and should not be construed
;	as a commitment by the University of Toledo or  by
;	the author.
;	
;	
;	edits:	16-mar-82	rewrite .print to save space
;
;

;
;	COMMON definitions for the EDRT run time system(s)
;
;
;	Parameters affecting speed and i/o performance that
;	can be changed at assembly time.
;
;	1. In the i/o paging subroutines.
;
;	   PG.SIZ	=	1024.
;
;	   Records for the scratch disk file will be paged
;	   out to disk in 'PG.SIZ' byte blocks. It must be
;	   a multiple of 512 bytes. The smaller the  page,
;	   the better the paging. Larger pages cut down on
;	   initial disk hits.
;
;	   BUFCNT	=	4.
;
;	   The number of pages currently in core will affect
;	   performance the most during the edit session. The
;	   number of pages has little effect on disk  access
;	   during startup and during the 'END' command   for
;	   large files.
;
;	   IDX.SZ	=	400.
;
;	   The initial size of the index is set by this. The
;	   index, however, will always  be  extended  to the
;	   top of core, and will be dynamically expanded  if
;	   required.
;
;
;	IBFSIZ	=	1024.
;
;	This is the buffer size for all file creates (writes).
;
;
;	MAXLEN	=	146.
;
;	Maxlen is the max size of a line in core. Also affects the
;	buffer size for initial file loading since 'readin'  uses
;	the text window area for a large buffer.
;

	.NLIST	TTM
	.NLIST	ME
	.ENABL	LC
	.DSABL	GBL


	.sbttl	emt prefix definition
;;	prefix	=	1		; set to use emt 377 prefix
	.if ndf	,prefix
	.ift
	prefix	=	0		; no emt prefix codes today
	.endc

	.sbttl	general register definitions

	r0	=	%0		; general register 0
	r1	=	%1		; general register 1
	r2	=	%2		; general register 2
	r3	= 	%3		; general register 3
	r4	=	%4		; general register 4
	r5	=	%5		; general register 5
	sp	=	%6		; stack pointer
	pc	=	%7		; program counter
	f0	=	%0		; floating point %0
	f1	=	%1		; floating point %1
	f2	=	%2		; floating point %2
	f3	=	%3		; floating point %3

	lf	=	^d10		; line  feed
	cr	=	^d13		; car return
	space	=	^d32		; space char
	ff	=	^d12		; form feed
	smalla	=	140		; lower case 'a'


	.sbttl	moniter and rts job status word
;	in @#jbstat	(=400)
;
	jfswer	=	100000		; swap error for job
	jflock	=	40000		; lock this job in core
	jfig	=	20000		; job can exceed core maximum
	jfnopr	=	10000		; job has no account yet
	jfsys	=	4000		; job has temporary priv's
	jfpriv	=	2000		; job has permanent priv's
	jffpp	=	1000		; save/restore 11/45 fpp unit
	jfspri	=	400		; job has special run priority


	.sbttl	monitor call emts

	.if eq	,rt11!rsx11m
	.ift

	.asect
	.	=	104000


	op$ro	=	20000
	op$mod	=	100000

calfip:	.blkw		; call fip, with firqb loaded
.read:	.blkw		; read
.write:	.blkw		; write
.core:	.blkw		; change user memory size
.sleep:	.blkw		; sleep job for n seconds
.peek:	.blkw		; peek at memory
.spec:	.blkw		; special function
.ttape:	.blkw		; enter tape mode
.ttech:	.blkw		; enable echo
.ttnch:	.blkw		; disable echo
.ttddt:	.blkw		; ddt submode
.ttrst:	.blkw		; cancel ^o effect
.time:	.blkw		; get timing information
.postn:	.blkw		; get device's horizontal position
.date:	.blkw		; get current date & time
.set:	.blkw		; set keyword bit(s)
.stat:	.blkw		; get my statistics
.run:	.blkw		; run a new program
.name:	.blkw		; install a new program name
.exit:	.blkw		; exit to default run-time system
.rts:	.blkw		; change to a new run-time system
.erlog:	.blkw		; log an error from the run-time system
.logs:	.blkw		; check for logical devices
.clear:	.blkw		; clear keyword bit(s)
.mesag:	.blkw		; message send/receive
.ccl:	.blkw		; ccl checker
.fss:	.blkw		; file string scanner
.uuo:	.blkw		; uuo hook
.chain:	.blkw		; chain to a new program
.plas:	.blkw		; map plas area

	.asect
	. = -10		; fix up so link (or tkb) will not try to
	.rept	10	; allocate a large (104100) asect in the task
	.blkb	
	.endr

	.endc

	.sbttl	fip subfunction codes


        clsfq=  ^o0     		; close an open channel
        opnfq=  ^o2     		; open a channel
        crefq=  ^o4     		; create/extend/open a channel
        delfq=  ^o6     		; delete a file
        renfq=  ^o10    		; rename a file
        dirfq=  ^o12    		; directory inforamtion
        uuofq=  ^o14    		; uuo call
        errfq=  ^o16    		; return error message text
        rstfq=  ^o20    		; close all channels [except 0]
        lokfq=  ^o22    		; find a file on the disk
        assfq=  ^o24    		; assign a device
        deafq=  ^o26    		; deassign a device
        dalfq=  ^o30    		; deassign all devices
        crtfq=  ^o32    		; cre/ext/opn a unique .tmp file
        crbfq=  ^o34    		; cre/ext/opn a compild channel
 


        ; flag values for a files flag word

        flgrnd= ^o100000		; file is random access
        flgkb=  ^o40000 		; file is keyboard
        flgfrc= ^o20000 		; fil is force type not blocked
        flgnpr= ^o10000 		; file is npr
        flgpos= ^o4000  		; file's position needs checking
        ddwlo=  ^o2000  		; file is write locked
        ddrlo=  ^o1000  		; file is read locked
        ddnfs=  ^o400   		; file is non-file-structured
	mthnd	=	14.		; i/o driver handler indexes
	kbhnd	=	2
	dthnd	=	4
	lphnd	=	6
	crhnd	=	12.
	pkhnd	=	16.
	dkhnd	=	0


	.sbttl	rsts run time system flags for p.flag

	pf.kbm	=	400
	pf.1us	=	1000
	pf.rw	=	2000
	pf.ner	=	4000
	pf.rem	=	10000
	pf.csz	=	20000
	pf.emt	=	100000

	.sbttl	commonnly used macros

	.macro	stackc
	.if eq	,rsx11m!rt11
	cmp	sp	,#scwork+10
	bhis	.+4
	.erlog
	.endc
	.endm	stackc

	.macro	openf	f,c
	mov	c	,-(sp)
	mov	f	,-(sp)
	call	$$open
	.globl	$$open
	.endm	openf

	.macro	closef	c
	mov	c	,-(sp)
	call	$$close
	.globl	$$close
	.endm	closef
	
	.macro	libsect
	.psect	$iolib	,rw,i,lcl,rel,con
	.endm

	.MACRO	GLOBAL	LIST
	.GLOBL	LIST
	.ENDM	GLOBAL

	.MACRO	.ASSUME	ARG1,COND,ARG2
	.IF	COND	<ARG1>-<ARG2>
	.IFF
	.ERROR	ARG1 ;"COND ARG2" FAILS
	.ENDC
	.ENDM	.ASSUME

	.macro	.newline
	call	$pcrlf
	.globl	$pcrlf
	.endm	.newline


	.macro	error	val
	.iif gt,val-maxtrp, .error ; bad value for error trap
	.if ne	,tedrts
	.ift
	trap	val
	.iff
	mov	#val	,-(sp)
	call	p.trap
	.globl	p.trap
	.endc
	.endm	error


	.macro	loadlin	lnum
	mov	lnum	,-(sp)
	call	xfndlin
	.globl	xfndlin
	.endm	loadlin

	.macro	address	reg
	.ntype	$$6	,reg
	.iif gt, $$6-5, .error ; Illegal use of address macro
	.if ne , $$6-1
	 .ift
	  mov	r1	,-(sp)
	  mov	reg	,r1
	  dec	r1
	  mul	#maxlen	,r1
	  add	#cline$	,r1
	  mov	r1	,reg
	  mov	(sp)+	,r1
	 .iff
	  dec	reg
	  mul	#maxlen	,reg
	  add	#cline$	,reg
	.endc
	.endm	address

	.macro	push	reg
	 mov	reg	,-(sp)
	.endm	push

	.macro	pop	reg
	 mov	(sp)+	,reg
	.endm	pop

	.macro	return
	 rts	pc
	.endm


	.sbttl	a few more macros here



	.macro	section	name
	.psect	name	,i,ro,con,lcl,rel
	.endm	section

	.macro	callg	name
	.globl	name
	 jsr	pc	,name
	.endm	callg

	.macro	calli	name
	 jsr	pc	,name
	.endm	calli


	.macro	.wroct	arg
	 push	r5
	mov	arg	,-(sp)
	mov	sp	,r5
	callg	$wroct
	tst	(sp)+
	 pop	r5
	.endm	.wroct

	.macro	iferr	label
	 tstb	@#errsav
	 bne	label
	.endm	iferr

	.macro	ifnoerr	label
	 tstb	@#errsav
	 beq	label
	.endm	ifnoerr

	.macro	.priv
	.iif	ne, prefix , emt 377
	.endm	.priv


	.macro	routine	name
	 name::
	.endm	routine

	.macro	.errprt	errnum
	.if nb, errnum			; if passed an error number
	.ift				; then for rsx, save the last
	.if ne	,rsx11m			; error, stuff it in and then
	.ift				; call error printer
	mov	errsav,-(sp)		; save last error
	mov	errnum,errsav		; stuff new error
	callg	$errprt			; print it
	mov	(sp)+	,errsav		; pop old error
	.iff				; RSTS thank god
	movb errnum , @#402		; simple
	callg	$errprt			; setup with error in firqb
	.endc
	.iff				; balnk error passed
	callg	$errprt
	.endc
	.endm	.errprt



	.macro	save	list
	.if b , <list>
	.ift
	 save	<r0,r1,r2,r3,r4,r5>
	.iff
	.irp	x,<list>
	 mov	x,-(sp)
		.endr
	.endc
	.endm	save


	.macro	unsave	list
	.if b , <list>
	.ift
	unsave	<r5,r4,r3,r2,r1,r0>
	.iff
	.irp	x,<list>
	 mov	(sp)+,x
		.endr
	.endc
	.endm	unsave

	.macro	.rad	raddr,aaddr
	save	<r5>
	mov	aaddr	,-(sp)
	mov	raddr	,-(sp)
	mov	sp	,r5
	callg	$rad
	add	#4	,sp
	unsave	<r5>
	.endm	.rad

	.macro	movc	src,dst,len
	.iif b	,src	,.error		; missing SRC address for MOVC
	.iif b	,dst	,.error		; missing DST address for MOVC
	mov	src	,-(sp)
	mov	dst	,-(sp)
	.iif b	,len	,clr	-(sp)
	.iif nb	,len	,mov	len,-(sp)
	.globl	$movc
	call	$movc
	.endm	movc


;
;	.macro	movc	src ,dest ,len
;
;	  save	<r0,r1>
;	  push	src
;	  push	len
;	  .if	idn	,'dest , r1
;	  .iff
;	     mov dest	,r1
;	  .endc
;	  pop	r0
;	  ble	. + 12
;	  movb	@(sp)	,(r1)+
;	  inc	(sp)
;	  sob	r0	,. - 6
;	  tst	(sp)+
;	  unsave	<r1,r0>
;
;	.endm	movc
;



	.macro	.chksp	arg
	.ntype	$$5	,arg
	.iif eq, < $$5 & 7 >-6, .error ; Illegal use of SP(r6) in call
	.endm	.chksp


	.sbttl	the CALLS macro (call with param on stack)


;	CALLS macro
;
;	subroutine call with arguements passed in an area
;	pointed to by R5 (similiar to F4 and BP2). All args
;	are pushed onto the stack, with the first args  at
;	the lower address and the last ones at the  higher
;	addresses. R5 will point to the SP before the call.
;	R5 is saved and restored.



	.macro	calls	name,arglst	; standard  call  macro using
					; the hardware stack (%6) for
	  .globl	name
	  $$	=	0		; arguement transmission with
	  .irp	x	,<arglst>	; r5 passed as  a pointer  to
	    $$	=	$$ + 1		; to the arguement list.  The
	  .endr				; use of contents of the list
	 .if eq	,$$
	  .ift
	    jsr	pc	,name		; No argument list given.
	  .iff

	    push	r5
	    .if eq , $$ - 1		; One arguement in the list

	     .ift
	      mov	arglst	,-(sp)	; One arg. Generate less code
	      .chksp	arglst
	      mov	sp	,r5
	      jsr	pc	,name
	      tst	(sp)+
	      pop	r5

	     .iff


	      $$2	=	$$	; more than 1 arguement. Thus
	      .rept	$$		; extract the args in reverse
	      $$1	=	0	; order so that we might save
	      .irp x	,<arglst>	; a little core (4 words).
	       $$1	=	$$1 + 1	; Scan the arg list until we
	       .if eq	, $$2 - $$1	; we come to the last one we
		.ift			; before the one we just did.
		 .chksp	x
		 mov	x	,-(sp)	; Push it, and exit the .irp.
		 .mexit			; exit
	       .endc
	      .endr
	      $$2 = $$2 - 1
	      .endr
	      mov	sp	,r5	; Set up the argument lst ptr.
	      jsr	pc	,name	; and go to the routine.
	      .if ne , $$ - 2
	      .ift
	       add	#$$*2	,sp	; fix the stack up, restore r5
	      .iff
	       cmp	(sp)+	,(sp)+
	      .endc
	      unsave	<r5>
	      .endc
	 .endc

	.endm	calls			; thats all


	.sbttl	yet some more macros


	.macro	.print	stradr	,len

	.if ne	,tedrts			; for the RSTS run time system
	.ift				; we will use emt calls to save
	.if b	,len			; space, emt0 for .asciz string
	 .ift				; else emt1 for passed length.
	  mov	stradr	,-(sp)		; stuff asciz string length
	  emt	376			; trap off
	 .iff				; non blank length
	  mov	len	,-(sp)		; stuff length
	  mov	stradr	,-(sp)		; and address
	  emt	377			; and go to it
	.endc				; if b,len
	.endc				; if rsts

	.if eq	,tedrts			; rsx or rt today ?
	.ift
	 .if b	,len			; if no length then .asciz
	 .ift
	 mov	stradr	,-(sp)		; stuff length
	 call	ttio0			; and call similar code to rsts
	 .iff				; passed length
	 mov	len	,-(sp)		; stuff length and fake it out
	 mov	stradr	,-(sp)		; save this also
	 call	ttio1			; and do it
	 .endc				; if b, len
	 global	<ttio0,ttio1>
	.endc				; for rsx and rt11

	.endm	.print			; thats all



	.macro	.wrdec	val
	mov	val	,-(sp)
	callg	$wrdec
	.endm	.wrdec

	.macro	.wrldec	hi,low
	save	<r5>
	mov	low	,-(sp)
	mov	hi	,-(sp)
	mov	sp	,r5
	callg	$wrldec
	add	#4	,sp
	unsave	<r5>
	.endm	.wrldec



;	define the structure for 'STRINGS'
;
;	given:
;		mov	#string	,r0	; get address of the string
;
;	then	-2(r0)	=	the maximum string length
;		-4(r0)	=	the current string length
;
	.macro	string	name	,len
	.blkw	1
	.blkw	1
name:	.blkb	len+1
	.even
	.endm	string


	.macro	.itoa	num	,stradr

	  save	<r5>
	  mov	num	,-(sp)		; convert binary value in
	  mov	stradr	,-(sp)		; 'num' to 6 character un-
	  mov	sp	,r5		; signed integer at address
	  callg	$cvti6			; in 'stradr'. The result is
	  add	#4	,sp		; blank padded on right. Fix
	  unsave	<r5>		; the stack up and all done.

	.endm	.itoa




	.macro	.val	stradr,strlen,result

	  save	<r5>
	  .if idn	,r0 ,'result
	   .iff
	    save <r0>			; result is returned in R0
	  .endc

	  mov	strlen	,-(sp)		; The length of the string.
	  mov	stradr	,-(sp)		; and the address of it too.
	  mov	sp	,r5		; pointer to argument list.
	  callg	$val
	  add	#4	,sp		; Reset the stack pointer.
	  .if idn	,r0 ,'result
	   .iff
	    mov	r0	,result
	    unsave <r0>
	  .endc
	  unsave <r5>

	.endm	.val


	.macro	.len	address
	mov	address	,r0		; length of .asciz string
	callg	$len
	.endm	.len


	.sbttl	macros to set control c status

	.macro	.nocc
;;	save	<@#plevel>
;;	mov	sp	,@#plevel
	.endm	.nocc

	.macro	.encc
;;	save	<@#plevel>
;;	clr	@#plevel
	.endm	.encc

	.macro	.resume
;;	unsave	<@#plevel>
	.endm	.resume


	.macro	.tstst	bitnum		; test bit in edstat
	bit	bitnum	,@#edstat
	.endm	.tstst

	.macro	.setst	bitnum		; set a bit in edstat
	bis	bitnum	,@#edstat
	.endm	.setst

	.macro	.clrst	bitnum		; clear a bit out
	bic	bitnum	,@#edstat
	.endm	.clrst


	.sbttl	psect ordering

;	do not change order of .99990,.99991 and .99992 !

	.psect	$EDIO 	 ,RO,I,LCL,REL,CON
	.psect	rsxovr	,ro,i,lcl,rel,con
	.psect	$CODE 	 ,RO,I,LCL,REL,CON
	.psect	$IOLIB 	 ,RW,I,LCL,REL,CON
	.psect	vtdefs	,ro,d,lcl,rel,con
	.psect	VTEDIT	 ,ro,i,rel,con,lcl
	.psect	TTYUTL	 ,ro,i,rel,con,lcl
	.psect	$TTINI	 ,ro,d,rel,con,lcl
	.psect	$PDATA	 ,RO,D,LCL,REL,CON
	.psect	$COPYR	 ,RO,D,LCL,REL,CON
	.psect	$$CMDS	 ,RO,D,LCL,REL,CON
	.psect	$$CMDL	 ,RO,D,LCL,REL,CON
	.psect	$JUMPA	 ,RO,D,LCL,REL,CON
	.psect	$CMDAR	 ,RO,D,LCL,REL,CON
	.psect	RTSRUN	 ,RO,I,LCL,REL,CON
	.psect	.99990	 ,RO,D,GBL,REL,OVR
	.psect	.99991	 ,RO,D,GBL,REL,CON
	.psect	.99992	 ,RO,D,GBL,REL,OVR
	.psect	.99998	 ,RO,I,LCL,REL,CON
	.psect	.99999	 ,RO,I,LCL,REL,CON
	.if ne	,rt11
	.ift
	.psect	kmonbf	,rw,d,gbl,rel,ovr
	area:	.blkw	20
	kmonbf:	.blkb	84.
	lbuff	=	kmonbf+2
	.endc
	.if eq	,$$$abs
	.ift
	.psect	$$$$$0	,rw,d,gbl,rel,ovr
	.psect	$$$$$1	,rw,d,gbl,rel,ovr
	.psect	$$$$$2	,rw,d,gbl,rel,ovr
	.endc


	.sbttl	user xrb and firqb layout

	jbstat	=	400
	keywrd	=	400		; user job keyword.
	corcom	=	460		; core common addr.

	firqb	=	402		; abs address of user firqb
	iosts	=	0		; offsets in the firqb
	fqjob	=	2		; always jobnum*2 returned here
	fqfun	=	3		; fip sub-function code.
					; also start of uu0 parameters
	fqfil	=	4		; channel number * 2 for fip.
	fqerno	=	4		; rsts error # for error text
	fqsizm	=	5		; most sig byte for filesize .
	fqppn	=	6		; the ppn. project in hi byte
	fqnam1	=	10		; 6 character rad50 filename
	fqsiz	=	16		; filesize is put/returned here
	fqbufl	=	20		; default buffer size .
	fqnam2	=	20		; put new filnam for rename.
	fqmode	=	22		; rsts file open mode to use
					; must be < 0 for 'real' mode.
	fqflag	=	24		; file status after an  open
	fqprot	=	27		; file protection code.
	fqdev	=	30		; 2 byte physical device name
	fqdevn	=	32		; 1 byte device unit number
	fqclus	=	34		; the clustersize to use.
	fqent	=	36		; number entries in  ufd.
	fqbsiz	=	40		; the size of the firqb.


	xrb	=	442		; abs address of user xrb
	xrlen	=	0		; offsets into the xrb
	xrbc	=	2		; byte count for i/o request
	xrloc	=	4		; address of the buffer to use
	xrci	=	6		; what channel do we use
	xrblkm	=	7		; most sig byte for block number
	xrblk	=	10		; what block should we do. also
					; for 'fss', length of user log
					; table (asgppn,asgprot,asgdev)
	xrtime	=	12		; how long to wait on tt input.
					; for 'fss', addr(user log tbl)
	xrmod	=	14		; device dep. modifiers .
	xrbsiz	=	16		; size of the xrb

	.sbttl 	user low core layout


	tmplun	=	1		; channel for the temp  file
	lstlun	=	2		; channel for listings.
	kblun	=	3		; the keyboard
	inlun	=	4		; channel for current input dev
	vtlun	=	5		; for scope editor
	zaplun	=	5		; for overwrite at 'end'
	hlplun	=	6		; for the help file
	jrnlun	=	7		; journal file channel?
	maxlun	=	10		; highest channel to use + 1


	trpvec	=	34		; trap vector
	corcom	=	460		; address of core common
	usrlog	=	740		; user's logical table is here.
	asgppn	=	734		; user's assigned ppn '@'
	asgprt	=	736		; user's assigned protection
	asgdev	=	740		; user's assigned device tbl



	.sbttl	constant definitions, trap codes, status bits

	tiny	=	0
	super	=	0
	maxlen	=	136.		; the maximum length of a line.
	ibfsiz	=	1024.

	.iif	ndf,super , super = 0
	.iif	ndf,tiny , tiny = 0	; default to no tiny version
	.iif	ndf,idx.sz,idx.sz = 200.; default to 5k version


;	.iif df	,f.bfsz	,.error		; f.bfsz already defined ??
;	.iif df	,f.blk	,.error		; f.blk  already defined ??
;	.iif df	,f.ofst	,.error		; f.ofst already defined ??
;	.iif df	,f.rfil	,.error		; f.rfil already defined ??

	f.bfsz	=	512.		; Buffer size for temp file.
	f.blk	=	f.bfsz / 512.	; disks block per logical record
	f.ofst	=	f.blk * 42.	; Offset into record for the txt
	f.rfil	=	f.blk * 15.	; Number lines per logical recrd


	.if	ne	,512.-f.bfsz
	 .ift
	   .error	; Tmp buffer size is not 512 bytes for paging
	.endc

	.iif	ne , idx.sz & 1 , idx.sz = idx.sz + 1



	.sbttl	Status bits in EDSTAT

	fulls	=	1		; Search/replace case ignore
	xlupc	=	2		; convert lower case to upper
	rtcc	=	4
	rtexit	=	10
	loclin	=	40		; Lock command toggle
	rtdump	=	20		; A dump is in progress now.
	badlin	=	100
	edhelp	=	200		; We already printed help
	notext	=	400
	faterr	=	1000
	ovrflo	=	2000
	filbak	=	4000		; Back up in file if set
	xltab	=	10000		; convert tabs to spaces
	edinp	=	20000		; waiting for kb input
	rtcmd	=	edinp
	badcmd	=	40000
	patfnd	=	100000		; found pattern in search

;	Status bits in EDSTA1

	zapfil	=	1		; overwrite output file
	endcmd	=	2		; currently in END command
	vtedit	=	4		; in scope edit mode
	vtnlin	=	10		; no printing line numbers out
	vtev2	=	20
	jrnput	=	40		; echoing kb input to disk file
	jrnget	=	100		; reading from a journel file.
	vteof	=	200		; have inserted dummy <eof> rec.
	vtexit	=	400		; exit to end command please


;	bits in VTANSI flag word

	wast52	=	1		; the vt100 started life as a 52
	wastm1	=	2		; the GIGI had been in TM1 mode



	.sbttl	trap codes

	t.ovrwrn=	1		; overflow on internal index.
	t.ovrfat=	2		; overflow on int index,fatal
	t.notxt	=	3		; no text present to edit.
	t.baderr=	4		; undefined RSTS fatal errors.
	t.inabo	=	5		; insert abort due to overflow.
	t.illcmd=	6		; % Illegal command.
	t.illarg=	7		; % Illegal command arguements.
	t.badmov=	10		; % Bad target for a move cmd.
	t.badlin=	11		; % Bad line numbers
	t.maxl	=	12
	t.extra	=	13
	ccabrt	=	14
	w.nofind=	15
	badvt	=	16
	notvt	=	17
	badpat	=	20
	tmperr	=	21
	maxtrp	=	21		; The highest trap number


	.sbttl	Error codes

	ed.eof	=	11.		; end of file error.
	ed.long	=	47.		; line is too long
	ed.cc	=	28.		; control c trap error #
	ed.badn	=	2		; Illegal filename error #
	ed.fnd	=	5		; Can't file file or account.
	.if ne	,rsx11m			; define eof error code
	.ift
	 ed.eof	=	-10.
	 ed.fnd	=	-26.
	 ed.bad	=	-54.
	.endc

	.if ne	,rt11
	.ift
	ed.eof	=	1
	ed.bad	=	2
	ed.fnd	=	2
	.endc


	.sbttl	part of low core (1st 1kw for RSTS)


	.if eq	,$$$abs			; make this relocatable unless
	.ift				; we are building a RSTS type
	 .psect	$$$$$0			; sharable run time system
	 rwar0	=	.		; RSX,RT or minitab version
	.iff				; RSTS rts or overlayed reslib
	 .asect
	 .if ne	,rsx11m!tedres!resovr	; if overlayed reslib, then for
	 .ift				; RSX use 2000 else for RSTS
	 .	=	$$$wrk		; version (as a reslib or as a
	 rwar0	=	.		; run time system) use 200 for
	 .iff				; this part of the r/w data.
	 .	=	200		; RSTS does not use locations
	 rwar0	=	200		; 200-377 in the use job image
	 .endc				; 
	.endc				; if ne, $$$abs


	.if ne	,rsx11m			; include FDB's and GMCR buffer
	.ift

	.mcall	fdbdf$,	gmcr$

fdb1:	fdbdf$				; will init them at run time
fdb2:	fdbdf$				; what a waste of space
fdb3:	fdbdf$
fdb4:	fdbdf$
fdb5:	fdbdf$
fdb6:	fdbdf$
fdb7:	fdbdf$
fdb8:	fdbdf$

;	can not do this in an asect
;
	.if ne	,$$$abs
	.ift
gmcr:	.blkb	2
	.blkw	40.
	.iff
gmcr:	gmcr$
	.endc

filmod:	.blkw	11

hlpfdb	=	fdb6
errfdb	=	fdb8
tmpfdb	=	fdb1
rwfdb1	=	fdb1
rwfdb2	=	fdb2
rwfdb3	=	fdb3
rwfdb4	=	fdb4
rwfdb5	=	fdb5
rwfdb6	=	fdb6
rwfdb7	=	fdb7
rwfdb8	=	fdb8

rwios1:	.blkw	2
rwios2:	.blkw	2
rwios3:	.blkw	2
rwios4:	.blkw	2
rwios5:	.blkw	2
rwios6:	.blkw	2
rwios7:	.blkw	2
rwios8:	.blkw	2

tmpios	=	rwios1
hlpios	=	rwios6
errios	=	rwios8

	.assume	tmplun eq 1
	.assume hlplun eq 6

errbuf:	.blkb	1000

	.mcall	csi$
	csi$
csiblk:	.blkb	c.size
kbiost:	.blkw	2

	.endc

regsav:	.blkw	8.			; core dumper saves regs here
adr$in:	.blkw				; dump, save address of index
adr$tb:	.blkw				; dump, save address of tempbuff
adr$pc:	.blkw				; dump, save pc
tmp$st:	.blkw	8.			; temp file access statistics
recount:.blkw				; byte count of last read saved
errsav:	.blkw				; error @firqb stuffed here
kw11:	.blkw	4			; savearea for stats from RSTS
cpsave:	.blkw	4			; savearea for cputine  stats.
vtansi:	.blkw				; vtedit sets if vt100 in ansi
usrppn:	.blkw				; current ppn (uic)
job$:	.blkw				; ascii of job number
ourjob:	.blkw				; binary of job number
cclent:	.blkw				; ccl entry flag
ccllen:	.blkw				; length of the ccl text string
string	lcmd	,40.			; save your last command  here.
ckount:	.blkb	1			; count of control c's
ffdmp:	.blkb	1			; 'dmplin' sets if ff terminator
tmo:	.blkb	1			; current kb timeout in seconds
ecmdflg:.blkb	1			; last command esc seq flag
	.even
tt.psz:	.blkw	1			; size of screen for a scope
scopef:	.blkb	1			; set if scope if set for kb:
doscop:	.blkb	1			; set if scope editor @entry
xplace:	.blkw	1
	.even				; please
	..rwar1	=	.		; end of first r/w area
	rwar0s	=	. - rwar0

	.if ne	,$$$abs & tedrts
	.iif ge, ..rwar1-400, .error ; low core into FIRQB and XRB
	.endc



	.sbttl	more read/write data
;	warning (for RSTS). this is using part of core common !!!!

	.if eq	,$$$abs
	.ift
	 .psect	$$$$$1			; RSX/RT11 or RSTS reslib
	.iff
	.if ne	,tedrts
	.ift
	 .	=	460		; RSTS/E run time system
	.iff
	 . = ..rwar1 + 2
	.endc
	.endc

sysid:	.blkb	30.			; save your system id msg here.
scope:	.blkw	2			; scope type and ttyset save
edstat:	.blkw	1			; current internal status bits
edsta1:	.blkw	1			; more of the same
$inswi:	.blkw	1			; input switches bit pattern
arstat:	.blkw	1			; cmd argument status bits
plevel:	.blkw	1			; current cc interupt flag
iostat:	.blkw	maxlun+1		; saved channel*2 @firqb+fqflag
blknum:	.blkw	maxlun+1		; current block number @chan*2
bufpnt:	.blkw	maxlun+1		; current offset into buffer
rd$siz:	.blkw	maxlun+1		; size of last read in bytes
rm$siz:	.blkw	maxlun+1		; what's left in rms record.
rc$fmt:	.blkw	maxlun+1		; used for RMS support, recfmt
vfc$:	.blkw	maxlun+1		; rms, vertical form control ch
	.even

	..rwar2 = .

	.if ne	,$$$abs&tedrts
	.ift
	$$	=	.
	.iif ge, $$ - 734 , .error ; overflow into user logical table
	.endc


	.sbttl	the rest of the fixed read/write data
	.if eq	,$$$abs			; if eq, then the data will
	.ift				; be relocatable, else the
	 .psect	$$$$$2			; data will be in an asect
	.iff				; thus implying a RSTS/E
	 .if ne	,tedrts
	 .ift
	 .asect				; run time system.
	 .	=	1000		; a rts
	 .iff
	 . = ..rwar2+2
	 .endc
	.endc				; if eq, $$$abs

wflag:	.blkw	1			; must not be cleared at restart
windex:	.blkw	1			; index for wildcard file
infsrc:	.blkb	50			; wildcard filename

	rwsiz1	=	.

rwar2:
lowlim:	.blkw	1			; for a command, lowlim is the
hilim:	.blkw	1			; lowest line, hilim is the top
idxsiz:	.blkw	1			; store current size of index.
la$blk:	.blkw	maxlun+1		; rms, last free block in file
la$byt:	.blkw	maxlun+1		; rms, last free byte in block
	.even
swival:	.blkb	8. * 8.			; text asscociated with switches
	swvsiz	=	. - swival
mx$siz	=	swival			; switches not needed lateron


;	the area 'cline$' is the text 'window' where sub fndlin
;	puts text from the temp file into to use as a work space.
;	Please note that 'readin' sub will also use this area for
;	large block buffering on the input file !

loadbf:					; use also for ifl buffer
cline$:	.blkb	f.rfil  * maxlen	; temporary in-core text buffer
	.if eq	,rt11
	.ift				; RSTS (or RSX also)
	.if gt	,4000-<f.rfil*maxlen>	; for the file load buffer,
	.ift				; round this up to 4000 bytes
	.blkb	4000-<f.rfil*maxlen>	; to speed things up please.
	.endc
loadsz	= <<<. - loadbf> / 1000> & 16> * 1000
	.iff
loadsz	= <<<f.rfil*maxlen> / 1000> & 16> * 1000	
	.endc
	.even


maxrec:	.blkw	1			; current highest active record
string	line$	,maxlen			; cmd line / current text line.
botlin:	.blkw	1			; lowetst line number  in  use.
toplin:	.blkw	1			; highest line number  in  use.
loclow:	.blkw	1			; if  linenumber  defaults  are
lochi:	.blkw	1			; set, use values stuffed here.
target:	.blkw	1			; for the :linenumber argument.
lstprt:	.blkw	1			; last line printed to TTY
clow:	.blkw	1			; lowest line currently in core
chi:	.blkw	1			; highest lin currently in core
blink:	.blkw	1			; the bottom record link
ylink:	.blkw	1			; the tail link
rnum:	.blkw	1
corlen:	.blkw	f.rfil+2		; length of lines in core
lincnt:	.blkw	1			; nlines in cur temo file blk
offset:	.blkw	1			; offset into the block
mode:	.blkw	1			; for the temp file controller
slen:	.blkw	1
pmaxrec:.blkw	1			; number of lines in block
string	infile	,40.			; we saved the input filename
tmpbuf:	.blkb	f.bfsz			; the logical tempfile buffer.
inbuf:	.blkb	ibfsiz			; for all ascii disk i/o
	lstsiz	=	ibfsiz
	lstbuf	=	inbuf		; Careful here !!!!!!!!!!!
	hlpbuf	=	inbuf		; Really careful

	.if eq	,rt11			; add a journal file buffer for
	.ift				; all but RT11 now
jrnbuf:	.blkb	1000			; simple
	.endc


txtoff:	.blkw	1			; used by replacement routines


	.sbttl	data for the temp file paging subroutines


	.if ne	,rt11			; use fewer buffers for the
	.ift				; rt11 version, else build
	bufcnt	=	2		; a larger one for RSTS and
	.iff				; rsx11m.
	bufcnt	=	4.		; The number of buffers to use
	.endc
	pg.siz	=	1024.		; 2 blocks per virtual page

pg$bsz:	.blkw	1
pg$clu:	.blkw	1
pg$cnt:	.blkw	1

bufmod:	.blkw	bufcnt			; Has the buffer be modified ?
hitcnt:	.blkw	bufcnt			; Access count for the buffers
bufres:	.blkw	bufcnt			; Is the desired block in core
lastpg:	.blkw	1			; The last block in temp file
hcount:	.blkw	1			; Number of calls to routine
pfault:	.blkw	2			; Number of page faults.
bufpol:	.blkb	pg.siz * bufcnt		; The buffer pool
pgrw	=	. - bufmod		; Size of the area for paging


;	file control related data areas

bufsiz:	.blkw	1			; current file buffer size
insize:	.blkw	1			; size of the input file
inprot:	.blkw	1			; prot code of the input file
opnprot:.blkw	1			; temp, filled in by $open
opnsize:.blkw	1			; temp, filled in by $open
	.if ne	,rsx11m			; for RSX, save the file owner
	.ift				; yep
opfilo:	.blkw	1			; filled in by open
infilo:	.blkw	1			; filled in by edinit
	.endc
	.if ne	,rt11
	.ift
tmpsiz:	.blkw	1
	.endc
inchan:	.blkw	1			; initial chan # at entry
outsiz:	.blkw	1			; preextend size of out file
lstblk:	.blkw	1			; last block written at close
string	file$	,40.			; filename if passed on cmd line
string	newstr	,maxlen
string	oldstr	,maxlen
stklim:	.blkw	400 + < <maxlen+10>/2 >	; lower limit of the stack.
scwork	=	newstr			; let scope edit module have a
spat$	=	newstr			; text pattern for search cmd.


;	the following checks are made in order to assure that
;	the scope editor section can get at a large amount of
;	stack work space without messing up any critical  low
;	core regions.  Note that for  all practical  purposes
;	the scope editor is independent of the line editor.

	$$	=	maxlen+1
	.assume stklim eq <oldstr+$$+<$$&1>>
	.assume	oldstr eq <newstr+$$+<$$&1>+4>
	.assume	ibfsiz eq 1024.

	stack	=	.-2		; top of the stack


;	the index to the temp random access work file must be
;	allocated on top of everything else since we like  to
;	be able to do extend  task directives to  RSTS to  be
;	able to increase dynamically the file size.

index:	.blkw	20
	.if ne	,rt11
	.ift
	.blkw	2000
	idxmax	= . - 2
	.endc

;	finally, get minimum size and check for < 16k size.


	$$	=	.
	rwsiz1	=	. - rwsiz1	; size of the first r/w area.
	.if ne	,$$$abs
	.ift
	..msiz	=	<$$ / 4000> + 1
	.iif gt	,..msiz - 16. , .error	; LOW SEGEMNT OVER 16 KWORDS
	.endc






	.list
	.enabl	crf
