Google
 

Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 10,5676/teco/newsrc/tecini.mac
There are 3 other files named tecini.mac in the archive. Click here to see a list.
	SUBTTL	Introduction

; Copyright (c) 1980 Stevens Institute of Technology,
; Hoboken, New Jersey, 07030


; This software may be used and copied provided that this copyright notice
;is included, and provided that copies of all modifications are sent to:
;
;	TECO Project
;	Computer Center
;	Stevens Institute of Technology
;	Castle Point Station
;	Hoboken, New Jersey    07030
;
;
; The information in this software is subject to change without notice
; and should not be construed as a commitment by the authors or their
; employers.

  ; Search needed universals

	SEARCH	JOBDAT		; Job data area definitions
	SEARCH	TECUNV		; TECO universal file

  ; Generate the prologue


	TECVER==200		; Major version number
	TECMIN==1		; Minor version number
	TECEDT==1127		; Edit level
	TECWHO==0		; Last editor


	PROLOGUE(INI,<TECO initialization>)	; Generate the TITLE and other stuff
	SUBTTL	Table of Contents

;+
;.pag.lit

;		Table of Contents for TECINI - Initialization
;
;
;			   Section			      Page
;   1. Introduction . . . . . . . . . . . . . . . . . . . . .    1
;   2. Table of Contents. . . . . . . . . . . . . . . . . . .    2
;   3. Revision History . . . . . . . . . . . . . . . . . . .    3
;   4. Psect base address definitions . . . . . . . . . . . .    4
;   5. Startup time initialization. . . . . . . . . . . . . .    5
;   6. I$JOB - Job dependent initialization . . . . . . . . .    7
;   7. I$CCL - Determine if a CCL file. . . . . . . . . . . .    8
;   8. Low segment for TECINI . . . . . . . . . . . . . . . .   10
;   9. End of TECINI. . . . . . . . . . . . . . . . . . . . .   11

;.end lit.pag
;-
	SUBTTL	Revision History
COMMENT	|

1000	Start of this version

1014	By: Nick Bush		On: 11-August-1980
	1) Don't do the AUTO-BUFFER command if we had a error on the last command.
	   This avoids losing info for the error messages.
	2) Make an EB/ER/EX sequence end up renaming the correct files, not
	   trying to rename the ER'ed file to the EB'ed file.BAK, ...
	3) Make TEC file=file work the way it is supposed to.
	Modules: TECPRS,TECFIL,TECECM,TECINI

1074	By: Nick Bush		On: 23-January-1981
	Make TECONC ask for an initial command string for TECINI. This can be
	any set of TECO commands terminated by two altmodes.
	Also make TECECM do a physical-only GETSEG during an EE file restart if
	the original run-from info was gotten from the GETTAB's.
	Modules: TECINI,TECONC,TECECM

Start of Version 200A(1126)

1127	By: Nick Bush@SIT, Robert C. McQueen@SIT		On: 15-October-1981
	Add the following new features:
	- String arguments.  {...} is a string argument.
	- Make I take them, = and == return them.
	- Implement the FC command to define immediate command tables
	- Implement the E? command to return various items.
	- Start doing some work so that TECO will work on TOPS-20
	- Start doing some work so that TECO some day may run in a section
	  besides zero.
	Modules: TECUNV,TECERR,TECPRS,TECCMD,TECSRH,TECMEM,TECUUO,TECECM,TECMVM,TECCOM,TECINI
|
	SUBTTL	Psect base address definitions

; These symbols are used in TECONC to determine the base addresses
;of each PSECT. This module must be the first one loaded.

; First do IMPURE

	$IMPURE
IMPBEG:!			; Start of impure data

	$CODE
CODBEG:!			; Start of pure data and code

	$TEXT			; Start of the error text
TXTBEG:!

	$TXTPT			; Start of the error indeices

PTRBEG:!

	$ONCE		; Start of ONCE only code
ONCBEG:!

	$CODE		; Put back into code section
	SUBTTL	Entry vector and version definitions

; The following are the definitions required for the TOPS-10
; version of TECO

TOPS10<
	LOC	<.JBVER==137>		; Location to the version word
	EXP	%%TECO##		; Generate the version number

	LOC	.JBREN			; Location to the reenter word
	EXP	REE##			; Generate the reenter address

	RELOC				; Back to normal relocation
>; End of TOPS10

; The following are the definitions for the TOPS-20 entry vector into
; TECO.

TOPS20<
%TECO:	EXP	TECO			; Generate the starting address
	EXP	REE##			; Generate the reenter address
	EXP	%%TECO##		; Generate the version number
>; End of TOPS20
	SUBTTL	Tables -- Operating system commands

; The following are the only allowed commands that TECO will RESCAN for and
; determine what it should do.

IFN FTRSCN,<

DEFINE	OSCMDS,<
OS	CREATE,	EW		;; Create is the same as EW<File>
OS	MAKE,	EW		;; MAKE is the same as EW
OS	EDIT,	EB		;; EDIT is the same as EB
OS	TECO,	EB		;; TECO is the same as EB<file>
OS	READ,	ER		;; READ is the same as just doing an ER<file>
OS	PERUSE,	ER		;; PERUSE same as above
OS	R,	NO		;; Just run TECO
OS	RUN,	NO		;; Just run TECO
OS	START,	NO		;; Just start TECO
>; End of OSCMDS macro definition

; Expand the commands to look for

DEFINE	OS(COMMAND,ACTION)<EXP SIXBIT /COMMAND/>

OSCTBL:	OSCMDS			; Expand the commands table
 OSCLEN==.-OSCTBL		; Length of the table

; Define the action table

DEFINE	OS(COMMAND,ACTION)<EXP	ACTION'RSCN>

OSCACT:	OSCMDS			; Expand the action table

>; End of IFN FTRSCN
	SUBTTL	Startup time initialization

TECO:	PORTAL	.+2		; Allow for EXO entry
	 PORTAL	.+2		;  .  .  .
	TDZA	T1,T1		; Denote no CCL entry
	SETO	T1,		; Denote a CCL entry
	HLRZ	T2,.JBSA	; Check if restart
	SKIPE	.JBFF		; If .JBFF is zero, we must just be starting
	 CAMN	T2,.JBFF	;  .  .  .
	  JRST	TECO.R		; No, skip this
	MOVE	.SGDEV,RUNDEV	; Yes, set the ac's back up
	MOVE	.SGPPN,RUNPTH+.PTPPN ;  .  .  .
	MOVE	.SGNAM,RUNNAM	;  .  .  .
TECO.R:	RESET			; Initialize the I/O system
	STORE	T2,IMPBEG,IMPEND-1,0 ; Clear the low segment
	MOVEM	T1,CCLSW	; Save the CCL flag
	HRROI	T1,.GTRS0	; Get the first level SFD
	GETTAB	T1,		;  .  .  .
	 JRST	TECO.0		; Couldn't, don't store any PPN info
	STOR.	T1,FDBSFD,+ERRFDB ; Store for UUO
	MOVEM	T1,RUNPTH+.PTSFD ; Save for EE GETSEG's also
	SETOM	PHYSON		; Flag it is okay to do physical only GETSEG's
	MOVX	T2,<XWD -<.PTMAX-.PTSFD>+1,1> ; Get the loop counter
TECO.1:	HRROI	T1,.GTRS0(T2)	; Get the gettab index
	GETTAB	T1,		; And get the SFD
	 SETZ	T1,		; Assume none
	MOVEM	T1,.FDSFD+ERRFDB(T2) ; Store the SFD
	MOVEM	T1,.PTSFD+RUNPTH(T2) ; Here also
	JUMPE	T1,.+2		; Skip if done
	 AOBJN	T2,TECO.1	; Loop for all possible SFD's
	HRROI	T1,.GTRDI	; Get the PPN now
	GETTAB	T1,		;  .  .  .
	 MOVE	T1,.SGDEV	; Couldn't
	MOVEM	T1,.PTPPN+RUNPTH ; Save here
	STOR.	T1,FDBPPN,+ERRFDB ; And here
	MOVX	T2,FD.PTH	; Flag we have a path
	SKIPN	T1		; Only if we really have one
	 IORM	T2,.FDFLG+ERRFDB ; . . .
	HRROI	T1,.GTRDV	; Get the device we came from
	GETTAB	T1,		;  .  .  .
	 MOVE	T1,.SGDEV	; Couldn't, use what was in the ac's
	JUMPN	T1,.+2		; Have it?
	 MOVX	T1,<SIXBIT |DSK|> ; No, assume disk
	STOR.	T1,FDBDEV,+ERRFDB ; Save the device name
	MOVEM	T1,RUNDEV	; Save for EE command
	HRROI	T1,.GTRFN	; Get the run from file name
	GETTAB	T1,		; Get the file name
	 MOVE	T1,.SGNAM	; Couldn't use what the monitor left in the ac's
	HRROI	T2,.GTPRG	; Get our program name just in case
	GETTAB	T2,		;  .  .  .
	 MOVE	T2,T1		; Couldn't
	JUMPN	T1,.+2		; Have something already?
	 MOVE	T1,T2		; No, use from .GTPRG
	STOR.	T1,FDBNAM,+ERRFDB ; Store for TECUUO
	MOVEM	T1,RUNNAM	; And for EE command
	JRST	TECO.2		; Continue on

TECO.0:	SKIPN	.SGDEV		; If we have a device
	 MOVX	.SGDEV,<SIXBIT |DSK|> ; Else default to DSK:
	STOR.	.SGDEV,FDBDEV,+ERRFDB ; Store the device name
	MOVEM	.SGDEV,RUNDEV	; Store the device name
	SKIPN	.SGNAM		; If we don't have a name
	 MOVX	.SGNAM,<SIXBIT |TECO|> ; Default to TECO
	STOR.	.SGNAM,FDBNAM,+ERRFDB ; Store the name
	MOVEM	.SGNAM,RUNNAM	; Store it
	JUMPE	.SGPPN,TECO.2	; Jump if no PPN
	MOVEM	.SGPPN,RUNPTH+.PTPPN ; Store the PPN
	STOR.	.SGPPN,FDBPPN,+ERRFDB ; Store in the error block too
	BITON	T1,FD.PTH,ERRFDB+.FDFLG ; Light the flag too

TECO.2:	MOVE	P,[IOWD D.PDLL,PDL] ; Get the stack pointer
	PUSH	P,[[EXIT]]	; And stack the fatal error address
	MOVEM	P,PDLSAV	; Save the stack for later
	MOVEM	P,SAVEP		; And in case of error
	MOVEM	P,CMDSVP	; Here also
IFN FTXADR,MOVE	T1,[EXP PFL-1]	; Get the address of the stack
IFE FTXADR,MOVEI T1,PFL-1	; Get the address of the stack
	MOVEM	T1,QRGSTK	; Save the pointer
	MOVE	XS,[IOWD D.XPDL,XSPDL] ; Get the execution stack pointer
	PUSH	XS,[EXP 0]	; And stack a zero in case of error
	SETZB	F,S		; Clear the flags

; Get the number of jiffies per second. This is used by TECVID (LINCST)

	MOVX	T1,%CNTIC	; Get the item
	GETTAB	T1,		; From the gettab table
	 MOVX	T1,^D60		; Assume 60 per second
	MOVEM	T1,JIFSEC	; Save it
	PUSHJ	P,M$INIT	; Initialize memory management
	PUSHJ	P,F$INIT	; Initialize file system interface
	PUSHJ	P,I$JOB		; Do the job initialization
	PUSHJ	P,U$INIT	; Initialize error/LUUO management
	PUSHJ	P,T$INIT	; Do the terminal initialization
	PUSHJ	P,P$INIT	; Do the parser initialization
	PUSHJ	P,C$INIT	; Do the command initialization
	PUSHJ	P,E$INIT	; Initialize the E command processing
	PUSHJ	P,S$INIT	; Init the symbol table management
	PUSHJ	P,I$INIT	; Initialize immediate mode editing
	PUSHJ	P,SR$INI	; Initialize TECSRH
;	DEFAULT	SRCHSW,SRHMOD	; Set the default search mode
	DEFAULT	TYCASW,TYCASF	; Default the type out case
	DEFAULT	EOVAL,EOFLAG	; Default the EO value
	DEFAULT	AUTOFS,AUTOF	; Default the auto type out after searches
	JUMPPT	T1,CPKA,CPKA,CPKI,CPKL ; Jump on the processor type

CPKA:	SETOM	CPFLAG		; Mark this as a KA-10
	JRST	CPDONE		; And continue processing
CPKI:	TDZA	T1,T1		; Flag a KI-10 with 0
CPKL:	MOVEI	T1,1		; And a KL-10 with 1
	JRST	CPSTOR		; Store the processor flag

CPKS:	MOVEI	T1,2		; Get the flag
CPSTOR:	MOVEM	T1,CPFLAG	; Store the processor flag
CPDONE:				; Continue
IFN FTKL,<
	SKIPG	CPFLAG		; Is this a KL or KS?
	 ERROR	E.WCT		; No, wrong CPU type
> ; End of IFN FTKL
	SKIPE	SRHMOD		; If default search mode is not 0
	TXO	F,F.PMAT	; Make exact mode current


; Here to do the INI file and the CCL file if any

	DMOVE	T1,FSTCMD	; Get the first command
	PUSHJ	P,CB$MOV	; Put it into the command buffer
	MOVEM	P,PDLSAV	; Save the stack for later
	MOVEM	P,SAVEP		; And in case of error
	MOVEM	P,CMDSVP	; Here also
	SKIPE	CCLSW		; CCL mode ?
	 PUSHJ	P,I$CCL		; Do the CCL processing
IFN FTRSCN,<
	SKIPN	CCLSW		; CCL mode ?
	 PUSHJ	P,I$RSCN	; No, go try a rescan
> ;End of IFN FTRSCN
	DMOVE	T1,[TXTPTR(<>)] ; End this with two altmodes
	PUSHJ	P,CB$MOV	; Put it into the command buffer
	PUSHJ	P,C$XCT		; Execute the commands
	  JFCL			; Error return
	PJRST	COMND		; Start the command processing
	SUBTTL	I$JOB - Job dependent initialization

;+
;.Hl1 I$JOB
;This routine will do the job dependent initialization for TECO.
;.LITERAL
;
; Usage:
;	PUSHJ	P,I$JOB
;	(Return)
;.end literal
;-

I$JOB:	GETPPN	T1,		; Get the user's project-programmer number
	  JFCL			; In case skip return
	MOVEM	T1,MYPPN	; Store the user's PPN
	PJOB	T1,		; Get the job number
	MOVEM	T1,MYJOB	; Store this job number
	MOVEI	T4,3		; Set up the counter
I$JO.0:	IDIVI	T1,12		; Convert the job number ot sixbit
	ADDI	T2,'0'		; Make it a sixbit number
	LSHC	T2,-6		; Move the number over
	SOJG	T4,I$JO.0	; Loop for the three digits
	MOVEM	T3,SIXJOB	; Save it
	POPJ	P,		; Return to the caller
	SUBTTL	I$CCL - Determine if a CCL file

;+
;.HL1 I$CCL
;This routine will determine if there is a CCL file and if there is it will
;read the file into the command buffer, so that it can be executed.
;.literal
;
; Usage:
;	SKIPE	CCLSW		; CCL mode
;	 PUSHJ	P,I$CCL		; Yes - Processing the CCL
;	(Return)
;.end literal
;-

I$CCL:	FRAME.	<TMPPT,STERCM>	; Allocate some space
	MOVX	T2,.BTGEN	; Get a general core block
	MOVX	T1,.FDLEN	; Get the length of the block
	PUSHJ	P,M$ZBLK	; Allocate an FDB
	MOVEM	T1,TMPFDB	; Store the block address
	MOVX	T2,<SIXBIT /TMP/> ; Get the device name
	STOR.	T2,FDBDEV,(T1)	; Store the device name
	MOVX	T2,<SIXBIT /EDT/> ; Get the file name
	STOR.	T2,FDBNAM,(T1)	; Store the file name
	MOVX	T2,$IOREA	; Read the file
	EXCH	T1,T2		; Move the arguments into the correct place
	PUSHJ	P,F$OPEN	; Open the file
	  JRST	CCL.E		; Process the error
	MOVEI	CH,.CHESC	; Get an escape
	PUSHJ	P,CB$STO	; Store this in the command buffer
	MOVE	T1,TMPFDB	; Get the File access block
	PUSHJ	P,F$READ	; Read the LINED S
	 JRST	CCL.EF		; Go check if EOF
	LOAD.	T1,TPTADR,+CMDBUF ; Get the command buffer address
	LOAD.	T1,BLKPT,(T1)	; And get the pointer address
	MOVEM	T1,TMPPT	; Save it for later

	SETZ	P1,		; Flag not dollar sign seen yet
	MOVEI	P2,"="		; Flag no equals sign seen
; Loop back to here on each new character in the TMP:EDT file

CCL.0:	MOVE	T1,TMPFDB	; Get the address of the file access block
	PUSHJ	P,F$READ	; Input a character
	 JRST	CCL.EF		; Go check for error or eof
	CAXN	CH,"$"		; Is this a dollar sign ?
	  JRST	CCLALT		; Yes - Convert it to an altmode
	CAMN	CH,P2		; First equals sign seen ?
	  JRST	CCLEQL		; Yes - Jump
	CAXE	CH,.CHCRT	; Is this a carriage return
	 CAXN	CH,.CHALT	; or an old altmode ?
	  JRST	CCLNUL		; Yes - Assume we're done
CCL.1:	PUSHJ	P,CB$STO	; Store the character in the command buffer
	JRST	CCL.0		; Loop for the next character


; Here on a dollar sign seen

CCLALT:	MOVEI	CH,.CHESC	; Get an escape
	JUMPN	P1,CCL.1	; First one ?
	LOAD.	P1,TPTADR,+CMDBUF ; Get the command buffer address
	LOAD.	P1,BLKPT,(P1)	; And save the pointer for the EY if needed
	CAIN	P2,"="		; See an equals yet?
	 SETO	P2,		; Flag no equals allowed now
	JRST	CCL.1		; Continue

; Here on the first '=' in the command string (Unless $ seen first)

CCLEQL:	LOAD.	T1,TPTADR,+CMDBUF ; Get the current position
	LOAD.	T1,BLKPT,(T1)	;  .  .  .
	MOVEM	T1,STERCM	; Save the start of the er command
	DMOVE	T1,[TXTPTR(<ER>)] ; Get a text pointer
	PUSHJ	P,CB$MOV	; Move it into the command buffer
	MOVX	P2,.INFIN	; Prevent finding later equals
	JRST	CCL.0		; Go get the next character
; Here on the end of the command line

CCLNUL:	MOVE	P3,CH		; Get a copy of the terminating character
	CAXG	P3,.CHCRT	; Doing an EB?
	 CAXE	P2,.INFIN	; See an equals sign?
	  JRST	CCLN.1		; No, skip this
	LOAD.	T1,TPTADR,+CMDBUF ; Get the address of the command buffer
	MOVE	T3,STERCM	; Get the start of the ER command
	SKIPN	T2,P1		; Have a $?
	 LOAD.	T2,BLKPT,(T1)	; No, use the current pointer
	SUB	T2,T3		; Get the number of chars to delete
	SKIPE	P1		; Have a $?
	 SUB	P1,T2		; Account for what we are deleting
	PUSHJ	P,M$SRNK	; And shrink the buffer
CCLN.1:	MOVE	T1,[POINT 7,[ASCII |EB|]] ; Assume an EB
	CAXLE	P3,.CHCRT	; Was the break a CRLF ?
	 MOVE	T1,[POINT 7,[ASCII |EW|]] ; No - Get the EW
	MOVEI	T2,2		; Only two characters
	LOAD.	T3,TPTADR,+CMDBUF ; Get the command buffer address
	MOVE	T4,TMPPT	; Get the address of where to insert
	STOR.	T4,BLKPT,(T3)	; Store where to put the string
	SETZ	T4,		; Flag that there is no text buffer for the source
	PUSHJ	P,M$INSS	; Insert the string
	SKIPE	P1		; Have anything here?
	 ADDI	P1,2		; Yes, bump the pointer for the ER/EW command
	LOAD.	T1,TPTADR,+CMDBUF ; Get the address back
	SKIPN	T2,P1		; Get the point to insert the "EY" command
	 LOAD.	T2,BLKEND,(T1)	; Get the end
	STOR.	T2,BLKPT,(T1)	; And store as the posistion
	DMOVE	T1,[TXTPTR(<EY>)] ; Get the EY command
	CAXE	P2,.INFIN	; Have we seen an equals?
	 CAXG	P3,.CHCRT	; Doing just an EW?
	  PUSHJ	P,CB$MOV	; Store it
	LOAD.	T1,TPTADR,+CMDBUF ; Get the address back
	LOAD.	T2,BLKEND,(T1)	; Get the end
	STOR.	T2,BLKPT,(T1)	; And store as the posistion

; Now to clean up the files.

CCL.3:	MOVE	T1,TMPFDB	; Get the file access block
	PUSHJ	P,F$CLOS	; Close the file
	 JFCL			; Ignore the error
	MOVX	T1,$IODEL	; Delete the temporary file
	MOVE	T2,TMPFDB	; Get the file descriptor block
	PUSHJ	P,F$OPEN	; Delete the TMP: file
	 JFCL			; Ignore it

; Here if there was an error opening the CCL file

CCL.E:	MOVE	T1,TMPFDB	; Get the address of the FDB again
	PJRST	M$RBLK		; Return the block to free core


; Here on an error return from F$READ

CCL.EF:	STOPCD	(ERT,<Error reading TMPCOR file>)
	SUBTTL	I$RSCN - Set up for command rescanning

;+
;.hl1 I$RSCN
;This routine will determine if there is a command to rescan on the command
;line.  If there is it will read the command and store the information into
;the command buffer to execute.
;.literal
;
; Usage:
;	PUSHJ	P,I$RSCN
;	(Return)
;
;.end literal
;-

IFN FTRSCN,<

I$RSCN:	RESCAN	1			; Rescan the command line
	 SKPINC				; Make sure something is really there
	  POPJ	P,			; No command to process
	PUSHJ	P,I$NTMP		; Open up the new temp file
	 POPJ	 P,			;  Silly error
	MOVEM	T1,TMPFDB		; Save the FDB addr
	MOVEI	T1,TRMCHR		; Get the character input routine
	MOVEM	T1,RTN			; Save it
	PUSHJ	P,F$SXBT		; Input the sixbit
	MOVE	T2,[XWD -OSCLEN,OSCTBL]	; Get the table pointer
	PUSHJ	P,LOKNAM		; Look for the name in the table
	 JRST	 NORSCN			; User invoked us with a funny
					;  command. Make beleive we didn't
					;  do a rescan.
	SUBI	T2,OSCTBL		; Make this just an index
	MOVEI	T1,NORSCN		; Get the no rescan dispatch
	CAMN	T1,OSCACT(T2)		; Is this a no rescan command???
	 JRST	 NORSCN			; Yes, don't overwrite the temp file
	CAIN	CH,.CHLFD		; Did command terminate?
	 JRST	@OSCACT(T2)		; Yes, dispatch
	PUSHJ	P,GNBCHR##		; Get the next non-blank character
	CAIN	CH,.CHLFD		; Did command terminate?
	 JRST	@OSCACT(T2)		; Dispatch if no filespecs

;At this point the user gave a command with filspecs, now we must
;copy the rescan buffer into TMP:EDS and go to the magic routines

	PUSH	P,T2			; Save the offset

	PUSHJ	P,TRMCHR		; Copy a char into TMP:EDS
	CAIE	CH,.CHLFD		; Did command terminate?
	 JRST	.-2			; Jump if not at end of command

	MOVE	T1,TMPFDB		; Get the new FDB address
	PUSHJ	P,F$CLOS		; Write and close the temp file
	 JFCL				; ???
	MOVE	T1,TMPFDB		; Get the FDB address
	PUSHJ	P,M$RBLK		; Release the block
	POP	P,T2			; Restore the OSC offset
	JRST	@OSCACT(T2)		; And dispatch to the action routine

; Here if the name was not found in the table

RSCN.E:	MOVE	T1,TMPFDB		; Get the FDB address
	PUSHJ	P,F$RSET		; Reset this file
	MOVE	T1,TMPFDB		; Get the block address
	PJRST	M$RBLK			; Return the block

; This routine will just input characters from the RESCANed command

BITMSK(BRKMSK,.CH,<LFD,VTB,FFD,CNC,BEL,CNZ,ESC,CNR,CNU,CNW,CNT>)

TRMCHR:	PUSH	P,T1			; Get a spare AC
TRMC.0:	SKPINC				; Have any characters left?
	 SKIPA	CH,[EXP .CHLFD]		; No, pretend we got an eol
	INCHWL	CH			; Get the character
	JUMPE	CH,TRMC.0		; Forget nulls
	PUSHJ	P,ALTEO			; Convert altmodes if necessary
	PUSHJ	P,I$WTMP		; Write the character
	 JFCL				; ???
	CAIN	CH,.CHCRT		; Is it a <CR>?
	 JRST	TRMC.0			; Yes, don't let it get any farther
	MOVX	T1,BRKMSK		; Get the break mask
	LSH	T1,(CH)			; Determine if this is a break
	SKIPGE	T1			; It is not, just return
	 MOVX	 CH,.CHLFD		; Fool the upper level routines
	TXNE	F,F.INCM		; In TECO command input?
	 JRST	TRMC.1			; Yes, no comments
	CAXE	CH,";"			; Start of a comment?
	 CAXN	CH,"!"			; Other comment character?
	  PUSHJ	P,EATEOL		; Eat the rest of the line

TRMC.1:	POP	P,T1			; Restore T1
	POPJ	P,			; Return to the caller

; Routine to eat to end of line

EATEOL:	TXO	F,F.INCM		; Flag to ignore comments
EATE.1:	PUSHJ	P,TRMCHR		; Get a character
	CAXE	CH,.CHLFD		; End of line character?
	 JRST	EATE.1			; No, try again
	POPJ	P,			; Yes, all done

>; End of IFN FTRSCN
	SUBTTL	I$RSCN -- Handle READ/PERUSE commands

;+
;.hl2 ERRSCN
;This routine will handle the action of parsing the READ/PERUSE commands.
;This routine is called after the parser has eaten the READ/PERUSE operating
;system command.
;-

IFN FTRSCN,<

ERRSCN:	$SAVE	(<P1>)		; Save an AC
	SETZ	P1,		; Make RSCCOM do an EY
	DMOVE	T1,[TXTPTR(<ER>)] ; Get the ER command
	PUSHJ	P,CB$MOV	; Install it
	JRST	RSCCOM		; And jump into common code

>; End of IFN FTRSCN
	SUBTTL	I$RSCN -- Handle MAKE/CREATE commands

;+
;.hl2 EWRSCN
;This routine will handle the action of parsing the MAKE/CREATE commands.
;This routine is called after the parser has eaten the MAKE/CREATE operating
;system command.
;-

IFN FTRSCN,<

EWRSCN:	$SAVE	(<P1>)		; Save an AC
	SETO	P1,		; Indicates we were called via MAKE/CREATE
	DMOVE	T1,[TXTPTR(<EW>)] ; Get the EW command
	PUSHJ	P,CB$MOV	; Install it
	JRST	RSCCOM		; And jump into common code

>; End of IFN FTRSCN
	SUBTTL	I$RSCN -- Handle EDIT/TECO commands

;+
;.hl2 EBRSCN
;This routine will handle the action of parsing the TECO and EDIT commands.
;This outine is called after the operating system command has bee n input.
;-

IFN FTRSCN,<

EBRSCN:	$SAVE	(<P1>)		; Save an AC
	SETZ	P1,		; Indicates we were called via EDIT/TECO
	DMOVE	T1,[TXTPTR(<EB>)] ; Get the EB command
	PUSHJ	P,CB$MOV	; Install it

RSCCOM:	PUSHJ	P,I$OTMP	; Open up the old temp file
	 ERROR	E.NPC		; ?TECNPC No previous command
	MOVEM	T1,TMPFDB	; Save it
	MOVEI	T1,I$RTMP	; Get the I/O routine
	MOVEM	T1,RTN		; Save it
	PUSHJ	P,F$SXBT	; Skip past the command
	PUSHJ	P,GNBCHR	; Skip past some spaces
	JRST	RSCENT		; Enter the loop at the right place

RSCLOP:	MOVE	T1,TMPFDB	; Get the address of the file access block
	PUSHJ	P,F$READ	; Input a character
	 JRST	CCL.EF		; Go check for error or eof
RSCENT:	CAXN	CH,.CHCRT	; Is this a carriage return
	 JRST	 RSCLOP		; Yes, ignore it
	MOVX	T1,BRKMSK	; Get the break mask
	LSH	T1,(CH)		; Determine if this is a break
	SKIPGE	T1		; It is not, continue
	 JRST	RSC.1		; Yes - Assume we're done
	PUSHJ	P,CB$STO	; Store the character in the command buffer
	JRST	RSCLOP		; Loop for the next character

RSC.1:	JUMPL	P1,NOEY		; If called from MAKE/CREATE, don't do EY
	DMOVE	T1,[TXTPTR(<EY>)] ; Get the EY for reading
	PUSHJ	P,CB$MOV	; Put it in the buffer

NOEY:	MOVE	T1,TMPFDB	; Get the temps FDB address
	PUSHJ	P,F$CLOS	; Close the file
	 JFCL			; ???

	MOVE	T1,TMPFDB	; Get the FDB addr again
	PUSHJ	P,M$RBLK	; Drop the block
	POPJ	P,		; And return triumphant

>; End of IFN FTRSCN
	SUBTTL	I$RSCN -- Handle RUN/START commands

;+
;.hl2 NORSCN
;This routine will handle the case of TECO just being run or started.  It
;will look for the commands after a "-".
;-

IFN FTRSCN,<

NORSCN:	CLRBFI				; For now, act just like we used to
	POPJ	P,
>; End of IFN FTRSCN
	SUBTTL	I$OTMP - Open up the old temp file for reading

;+
;.hl1 I$OTMP
;This routine will open up the old temp file TMP:EDS.
;The file will be opened for reading.
;.literal
;
; Usage:
;	PUSHJ	P,I$OTMP
;	(Failed)			; File not found
;	(Successful return)		; T1 contains the FDB address
;
;.end literal
;-

IFN FTRSCN,<

I$OTMP:	MOVX	T2,.BTGEN		; Allocate some general storage
	MOVX	T1,.FDLEN		; Get the length of the block
	PUSHJ	P,M$ZBLK		; Allocate the block
	PUSH	P,T1			; Store the old FDB
	MOVX	T2,<SIXBIT /TMP/>	; Get the device
	STOR.	T2,FDBDEV,(T1)		; Store the device
	MOVX	T2,<SIXBIT /EDS/>	; Get the temp file name
	STOR.	T2,FDBNAM,(T1)		; Store it
	MOVX	T1,$IOREA		; Get the read function
	MOVE	T2,(P)			; Get addr of old temp FDB
	PUSHJ	P,F$OPEN		; Open the old temp file for reading
	 JRST	[POP P,T1			; Failed, get back FDB address
		 PUSHJ P,M$RBLK			; Release the memory
		 POPJ P,]			; And contine happily
	POP	P,T1			; Restore the FDB address
	JRST	.POPJ1			; Return successful, FDB in T1
>; End of IFN FTRSCN
	SUBTTL	I$NTMP - Write the command into a temp file

;+
;.hl1 I$NTMP
;This routine will open up the new temp file TMP:EDS.
;The temp file will be opened for writing. This is so that
;TECO will know what to do on the next TECO/MAKE/CREATE/EDIT command.
;.literal
;
; Usage:
;	PUSHJ	P,I$NTMP
;	(Failed)
;	(Successful return)		; New FDB address in T1
;
;.end literal
;-

IFN FTRSCN,<

I$NTMP:	MOVX	T2,.BTGEN		; Allocate some general storage
	MOVX	T1,.FDLEN		; Get the length of the block
	PUSHJ	P,M$ZBLK		; Allocate the block
	PUSH	P,T1			; Store the new FDB
	MOVX	T2,<SIXBIT /TMP/>	; Get the device
	STOR.	T2,FDBDEV,(T1)		; Store the device
	MOVX	T2,<SIXBIT /EDS/>	; Get the temp file name
	STOR.	T2,FDBNAM,(T1)		; Store it
	MOVX	T1,$IOWRI		; Get the function
	MOVE	T2,(P)			; Get the FDB address
	PUSHJ	P,F$OPEN		; Open the file for writing
	 JRST	[POP P,T1			; Failed, get back FDB address
		 PUSHJ P,M$RBLK			; Release the memory
		 POPJ P,]			; And contine happily
	POP	P,T1			; Restore the FDB address
	JRST	.POPJ1			; Give a good return
>; End of IFN FTRSCN
	SUBTTL	I$WTMP - Write a character into the TMP: file

;+
;.hl1 I$WTMP
;This routine is used to write a character into the TMP: file for the
;CREATE/MAKE/EDIT/TECO commands.
;.literal
;
; Usage:
;	CH/ Character to write
;	PUSHJ	P,I$WTMP
;	(Failure return)
;	(Good return)
;
;.end literal
;-

IFN FTRSCN,<

I$WTMP:	MOVE	T1,TMPFDB		; Get the FDB address
	PJRST	F$WRIT			; Write the character into the buffer

I$RTMP:	PUSH	P,T1			; Save this ac
	MOVE	T1,TMPFDB		; Get the FDB address
	PUSHJ	P,F$READ		; And read a byte
	 SETO	CH,			; Get end of file indicator
	POP	P,T1			; Restore it
	POPJ	P,
>; End of IFN FTRSCN
	SUBTTL	Low segment for TECINI

; The following is the low segment for the initialization segment

	$IMPURE			; Impure section
	LOWVER(INI,3)		; Low segment version number for this module

PDLSAV:	BLOCK	1		; Save of the stack
CCLSW:	BLOCK	1		; -1 to denote CCL entry
PDL:	BLOCK	D.PDLL+1	; Main stack
QRGSTK:	BLOCK	1		; Stack pointer for Q-register stack
PFL:	BLOCK	LPF+1		; Q-reg/macro stack

TMPFDB:	BLOCK	1		; Temp file FDB
SIXJOB:	BLOCK	1		; Sixbit job name
CPFLAG:	BLOCK	1		; CPU flag
				; -1 for KA-10
				;  0 for KI-10
				; +1 for KL-10
				; +2 for KS-10
JIFSEC:	BLOCK	1		; Number of jiffies per second
PHYSON:	BLOCK	1		; Flag if physical only GETSEG allowed

; High segment locations set up by TECONC

	$CODE			; Put in high segment

FSTCMD:	EXP	0,0		; Allow space for character count and address
	SUBTTL	End of TECINI

	END			; End of TECINI