	.title	k11cmd	command level for kermit-11
	.ident	/3.60/
	.enabl	gbl

	baselev	==	3		; baseline level
	edit	==	60.		; edit (independent of base_level)
	release	==	'T&137		; T for test, V for release

	.save
	.psect	ident	,ro,d,gbl,rel,con
lasted::.ascii	/  Last edit: 21-Mar-89 /
	.ascii	/ /
	.byte	0
	.even
ident::	.word	baselev,edit,release
	.psect	$pdata
do$ver::.word	1
do$exi::.word	1
do$lng::.word	1
umddef::.word	usermd
warn$::	.byte	CR,LF
	.ascii	/Check SHOW RELEASE_NOTES for possible incompatabilities/
	.byte	CR,LF
	.ascii	/with previous releases of Kermit-11 and other Kermits./
	.byte	CR,LF,0
$beep2:	.byte	CR,LF,7,7,0
	.even	
	.restore

	.macro	BEEP2
	PRINT	#$beep2
	.endm	BEEP2


;	Brian Nelson  01-Dec-83  13:19:14
;
;	Change Software, Toledo, Ohio
;	University of Toledo, Toledo, Ohio
;
;	Copyright (C) 1983   Change Software, Inc.
;
;	edits:
;
; 60 21-Mar-89  00:00:00  K11M41.MAC	For RSX, ensure Kermit is privileged
;			  K11MCO.MAC	before performing SF.SMC to remote
;			  K11DIA.MAC	port; failure to do so will crash M+
;					V4.0.  Also added local terminal
;					buffering to RSX connect module.
;					Completed definition of DF224 modem.
; 59 12-Oct-87  08:55:33  K11ATR.MAC	Support attribute packet type 54(8)
;			  K11RMS.MAC	to send files11 protection over. If
;					RSTS, convert to/from F11 format.
; 59 17-Sep-87  15:28:36  K11SER.MAC	Fix processing of server cwd cmd.
; 58 14-Aug-87  08:19:24  K11ECO.MAC	SET LINE TTN:/[NO]ALLOCATE, added
;			  K11ST1.MAC	mostly for RSTS/E
; 56 23-Jun-87  07:41:18  K11PRT.MAC	Fix sending break for XL on RT11
; 56 13-Mar-87  13:18:18  K11RMS.MAC	Dynamically allocate the command
;			  K11M41.MAC	line buffer count set by TKB via
;			  K11E80.MAC	GBLDEF=LNCNT$:nn. This allows us
;					to have > 3 for the I/D tasks.
; 56 19-Feb-87  15:58:58  All sources	Use teco macro to change all the
;					.INCLUDES to be conditional, this
;					was done to allow assembly on RT11
;					version 4 and P/OS.
; 56 17-Feb-87  09:35:04  K11RMS	Redo record buffer allocation to
;					be dynamic at startup. Set MAXSIZ
;					during task build to allow bigger
;					buffers for I/D space Kermit11.
; 56 09-Dec-86  14:15:23  K11INI.MAC	Control A stats support.
;			  K11REC.MAC
;			  K11SEN.MAC
; 56 06-Nov-86  08:27:33  K11M41.MAC	IO.WAL for tt output with CLE
; 56 06-Nov-86  08:27:54  K11SHO.MAC	Fix command macro list (SHO ?)
; 55 23-Oct-86  11:00:59  K11CMD.MAC	Prompting bug for RT11 XM overlay
; 54 30-Sep-86  13:24:07		SHOW DIAL
; 54 29-Sep-86  10:23:49  Numerous	Fix sources for possible I/D space
;					linking under RSTS/E and RSX11M+.
; 54 23-Sep-86  16:28:14  K11DIA.MAC	Support VADIC 4224 .v22bis modem
; 54 23-Sep-86  16:28:46  K11ST0.MAC	SET PHONE TONE/PULSE and SET PHONE
;					BLIND, added for VA4224 support.
; 54 10-Sep-86  11:22:52  K11M41.MAC	Fix setting of typeahead buffer
;					size for M+, ie, move the TC.TBS
;					to a point AFTER the TC.RAT.
; 54 09-Sep-86  16:01:27  K11ST1.MAC	SET FILE NAMING/NAMES option
;			  K11CVT.MAC	Options are: LITERAL, CONVERTED
;			  K11DAT.MAC	             FULL, UNTRANSLATED
; 54 23-Aug-86  12:37:09  K11E80.MAC	Had to cut some code from K11E80 and
;			  K1180S.MAC	K11M41, moved to K1180S and K11RMZ
;			  K11M41.MAC	respectively so the task images don't
;			  		cross the 130000 high limit boundary.
;					Caused by adding in extra XAB's.
; 54 22-Aug-86  14:36:44  K11RMS.MAC	Added in Date XAB's per a user request
;					Ultimate goal: to send attribute paks
;					with creation date/time.
; 53 13-Aug-86  09:38:04  K11PAK.MAC	Add SET SEN [NO]XON so one can force
;			  K11ST1.MAC	every packet sent to be prefixed with
;			  K11DAT.MAC	an XON. Perhaps this will help for
;					the DHV/U problems with flow control.
; 53 12-Aug-86  16:28:14  K11PAK.MAC	Fix BUFUNP to process repeat counts.
;			  K11SER.MAC	It would seem the 2.29 of MS Kermit
;			  K11REC.MAC	is prefixing filename in F packets.
; 53 12-Aug-86  11:08:13  K11M41.MAC	IO.GTS to check for extended I/O
;					Also check TC.PAR
; 53 12-Aug-86  11:05:03  K11CMD.MAC	Allow ; and ! to delimit comments.
; 53 07-Aug-86  08:40:36  K11RCO.MAC	Minor changes to connect under RT11
;			  K11PRT.MAC	SJ without timer support. This was
;					done AGAINST my better judgement.
; 53 05-Aug-86  19:35:19  Many		Make CMDBUF and ARGBUF pointers to
;					the actual data in order to reduce
;					the K11XM and K11RT4 sizes to help
;					in SRUN or FRUN's. Add code to re-
;					locate some PIC code into dynamic
;					region based from APR7 for RT11.
; 53 29-Jul-86  13:10:34  K11ST1.MAC	Add SET FIL TYP DEC_MULTINATIONAL
;					to allow 8bit text files. The mod
;					to K11ATR was to add support for
;					this between two 3.53 or later K11
;					systems.
; 53 29-Jul-86  12:58:38  K11ATR.MAC	Modified attribute  type '0' to
;					allow types other than IFABs. It
;					is backwards compatible with old
;					versions of Kermit-11.
; 52 28-Jul-86  17:10:00  K11RTI.MAC	More TSX+ features, also for PRO.
;					(I know have a TSX+ system on my
;					PRO/350).
; 52 2X-Jul-86		  Numerous	Command line editing and recall,
;					use arrow keys to control. Created
;					K11EDI.MAC from CLEEDI.MAC
; 52 2x-Jul-86		  K11RT*.MAC	Root size reductions for XM, via
;					moving more things into dynamic
;					region. Affected K11RMS, K11M41,
;					K11E80 and K11DAT also as some
;					things in K11DAT were changed to
;					pointers.
; 51 07-Jul-86  12:31:17  K11PRT.MAC	.TWAIT for packet reads to reduce
;					overhead on XM and TSX+
; 51 03-Jun-86  12:00:43  K11M41.MAC	Support for IO.EIO
; 51 13-Jun-86  13:53:05  K11CVT.MAC	Truncate filenames for RT11
; 51 06-Jun-86  09:52:29  K11RTI.MAC	Alter TSX+ memory allocation
; 51 06-Jun-86  09:52:57  K11PRT.MAC	Get rid of .HRESET for XC handler
; 51 04-Jun-86  11:16:07  Misc.		More changes to get K11XM.SAV to run
;					in the Foreground on RT11 v5.
; 51 29-May-86  13:50:00  K11CMD.MAC	Remove first (unneeded) call to SETCC
;					so we can wait for XINIT to do a .QSET
;					as we need extra one for the control
;					C watcher on RT11.
; 51 29-May-86  13:46:07  K11RT4.MAC	Add a real control C trap. IE, start a
;					watchdog timer to check the terminal
;					status word.
; 51 27-May-86  11:33:23  K11RCO.MAC	Kludge for bug in the RT 5.1 XL handler
; 51 25-May-86  09:33:12  K11RT4.MAC	Move XINIT out into K11RTI.MAC and put
;			  K11RTI.MAC	into an overlay. Also redo the overlay
;			  K11XM.COM	to cut down autoload vectors on RT XM.
; 51 23-May-86  11:49:44  A few		Allocate ALBUFF at run time.
; 51 23-May-86  10:50:16  K11RCO.MAC	Check for SJ exec having a clock
; 51 08-May-86  15:54:56  K11RCO.MAC	Rewrote RT11 connect code.
; 51 08-May-86  13:20:33  K11CM1.MAC	Fix TYPE command for large recordsize
;					files.
; 50 04-Apr-86	19:59:36  K11M41.MAC	Enable echoing for local terminal in
;					case of task abort w/o characteristics
;					getting reset.
; 50 04-Apr-86	19:57:27  K11PCO.MAC	Look for spawning PRO/COMM if PROCOM
;			  K11DAT.MAC	global ne 0. Set via SET POS [NO]DTE
;			  K11ST0.MAC	and via tkb GBLPAT option. SET code
;			  K11STD.MAC	in K11ST0, cmd def in K11STD.
; 50 02-Apr-86	15:53:27  K11ECO.MAC	Rewrote RSTS/E connect code for speed
; 49 28-Mar-86	09:25:10  K11HLP.MAC	Rewrote help routine
; 49 24-Mar-86	12:16:33  K11ATR.MAC	Fix protocol error for attribute
;					packets. See K11INS.DOC and K11.BWR,
;					also see K11ATR.MAC
; 48 21-Mar-86	16:54:53  K11DIA.MAC	Don't go to sleep for 2 secs after
;					successfull connection unless M or M+
; 48 21-Mar-86	16:54:26  K11PCO.MAC	Extend flushing of XOFFS to P/OS
; 48 13-Mar-86	14:28:10  K11SHO.MAC	SHOW PHONE
; 48 17-Mar-86	13:22:19  K11ECO.MAC	Ignore XOFF's from connected host.
;					(have a fubarred DHU11 on my 785).
; 47 07-Mar-86	18:17:30  K11RMS.MAC	BINFIL return(text) for FB$FTN files
;					This means that FD.FTN files will be
;					converted to text files.
; 47 05-Mar-86	12:48:19  K11PCO.MAC	Trash K11CON, K11PCO is for P/OS,
;					K11RXY is for RSX, K11ECO RSTS/E,
;					K11RTC RT11.
; 46 21-Feb-86	11:45:01  K11RMS.MAC	Add TLOG$S call to see if the
;					filespec is a logical name.
; 45 20-Feb-86	15:28:56  K11DIA.MAC	Added SET PHONE NUMBER
;			  K11ST0.MAC
; 45 18-Feb-86	11:14:04  K11ST0.MAC	Added SET DIAL
; 45 14-Feb-86	13:46:55  K11E80.MAC	Modify RSTS packet reader to cancel
;					XOFF'ed line, requires SYSIO priv.
; 45 12-Feb-86	16:56:35  K11M41.MAC	Find out terminal type for RSX & POS
; 45 11-Feb-86	12:17:09  K11RT4.MAC	Pass kmon command BYE for server
;					logout on TSX+
; 45 11-Feb-86	12:27:42  K11RTD.MAC	Skip volume verify for LDn:
; 45 11-Feb-86	12:28:06  K11PRT.MAC	Do s SET CLn LFOUT when closing line
; 45 11-Feb-86	15:44:36  K11E80.MAC	Rewrote support for SERVER logout to
;					use RSTS/E v9 features, also hangup
;					line if logout will succeed.
; 45 10-Feb-86	11:56:37  K11ECO.MAC	Creation, RSTS/E ONLY connect code.
; 45 10-Feb-86	11:52:21  K11CON.MAC	Removed RSTS/E and RT11 code
; 45 10-Feb-86	11:30:41  Misc		Final MODS from Steve Heflin
; 44 08-Feb-86	06:13:26  K11RXY.MAC	Added Robin Miller's new high speed
;					connect code as SET RSX CONNECT ALT
; 44 07-Feb-86	16:02:52  K11M41.MAC	Follow Heflin's EXST$S with EXIT$S
; 44 07-Feb-86	16:00:00  K11E80.MAC	Try to UNDO DEC's feature of turning
;					C1 characters into ESCAPE sequences.
; 44 07-Feb-86	15:48:45  K11PAK.MAC	Change Steve Heflin's exiting Kermit
;					if the wait for SOH reads a contrl Z
;					to require TWO control Z's in a row.
; 44 07-Feb-86	13:58:09  K11DAT.MAC	Data for displaying TIMEOUT count
;			  K11INI.MAC	Display TIMEOUT count
; 44 04-Feb-86	09:00:12  K11PRT.MAC	Implicit SET CL NOLFOUT for TSX+
;					Write SET SPEED code for CL (TSX+)
; 44 03-Feb-86	12:46:50  K11PRT.MAC	Allow CLn: for TSX+, where N is 0..7
;			  K11DSP.MAC
; 43 24-Jan-86	16:30:22  K11PRT.MAC	Added SET RT11 BREAK [SHORT][LONG]
;			  K11DAT.MAC	Short is 275 MS, long is 3 Sec.
;			  K11ST0.MAC
; 43 24-Jan-86	14:42:32  K11RMZ.MAC	Creation from K11RMS. Root segment
;					was getting too large.
;			  K11CPY.MAC	Reduce buffer size, module too large
; 43 23-Jan-86	15:58:51  Misc		Added stats for packet and file data
;					Also compute data rate in STAT	and
;					SHO PAC commands.
; 43 17-Jan-86	13:39:50  K11INI.MAC	Clean up SET SEND/RECEIVE and also
;			  K11ST1.MAC	use LONG PACKETS only if the user
;					did SET REC PAC > 94
; 43 17-Jan-86	11:26:01  K11PAK.MAC	Change packet stats into 32 bits
;			  K11INI.MAC	to avoid overflow. Run DOB on SYSLIB
;			  K11DAT.MAC	modules CDDMG, CBTA and SAVRG and
;			  K11SHO.MAC	put them into K11RT4.MAC
;			  K11REC.MAC
;			  K11SEN.MAC
;			  K11RT4.MAC
; 42 14-Jan-86	13:03:38  K11DIA.MAC	Rixon R212A modem support added
;					by Robin Miller of Nothern Telecom
; 42 10-Jan-86	11:43:37  several	LONG packet support.
; 41 31-Dec-85	12:23:53  K11ST1.MAC	Added SET SERVER [NO]TIME_OUT [value]
;			  K11PAK.MAC
;			  K11INI.MAC
;			  K11DAT.MAC
;			  K11SER.MAC
;			  K11DEB.MAC
; 41 31-Dec-85	04:23:27  K11PRT.MAC	Added support for RT11 5.2 and DTR
;					control.
; 41 28-Dec-85	11:43:52  Numerous	Added Steve Heflin's mods in for AtoZ
;
; The following things (edit 40) came up from comments received at F85 Decus
;
; 40 18-Dec-85	10:03:57  K11DSP.MAC	Added dummy EP for INQDTR:
;
; 40 18-Dec-85	10:03:35  K11M41.MAC	Added dummy EP for INQDTR:
; 40 18-Dec-85	10:03:02  K11ST0.MAC	Print DTR status on SET LINE
; 40 18-Dec-85	10:01:55  K11E80.MAC	Add routine to find out if line has DTR
;					up. RSTS/E normally keeps DTR low, it
;					raises it on seeing CD or RING. Only
;					works on 9.x or later.
; 40 17-Dec-85	18:24:53  K11E80.MAC	Redo of RSTS/E v9.x options regarding
;					setting typeahead (small buffer quota)
;					i.e., save and restore it please.
; 40 17-Dec-85	13:39:06  K11M41.MAC	Added mods by Robin Miller for logical
;					names for terminals, also checks for
;					SET LIN TTn: for TTn: having someone
;					logged in. (RSX11M/M+ only)
; 40 17-Dec-85	13:20:12  K11DIA.MAC	Added REDIAL ntimes command.
;			  K11DAT.MAC	Added global PHNUM for REDIAL command
; 40 16-Dec-85	15:14:23  K11CVT.MAC	Remove .COM from default binary types
;					Re: Bernie Eiben's "QAR". Very much
;					a PAIN if one edits VMS com files on
;					the PRO.
; 40 16-Dec-85	15:13:19  K11M41.MAC	Start timer on packet writes to clear
;					things in case we got XOFF'ed
;
; 2.39 is the Fall Decus version
;
; 39 06-Dec-85	11:57:58  K11DIA.MAC	Support for calling external routine
;			  K11M41.MAC	to dial (ala PRO/TMS). Added in mods
;					from Steve Covey for PRO/TMS dialing
;					out, mods for dialing in not done.
; 39 04-Dec-85	17:58:37  K11DIA.MAC	Modem type data structure mods, see
;					K11DIA.MAC for more info.
; 39 03-Dec-85	13:00:14  K11TSX.MAC	More mods to use CONSOLE port on RT11
;			  K11DSP.MAC	Also, SET LIN TT: will override the
;					use of XL or MT service.
; 39 30-Nov-85	12:35:44  K11INI.MAC	Send ESC > to force ansi mode if a
;					VT100.
; 39 30-Nov-85	12:35:20  K11E80.MAC	Minor mods for RSTS/E v9.x, get term
;					type and set buffer count for input.
; 39 16-Nov-85	12:13:26  K11CON.MAC	Intercept ESC Z and return a terminal
;					id that all exec's understand on P/OS.
;					Also, intercept all escape sequences
;					from P/OS keyboard and map some of the
;					upper row F keys to something usefull,
;					like ESC (F11)-> \033, INT (F6)>-> \03
;					and so on. Both features added at the
;					request of B. Eiben, DEC LDP, formerly
;					DEC LCG (eiben@dec-marlboro.arpa)
; 39 14-Nov-85	10:17:53  K11TSX.MAC	TSXFLG=1 for TSX+, -1 for RT11 without
;					XC,XL or MT service. Thus, RT11 kermit
;					can run using console only systems.
; 39 14-Nov-85	10:17:15  K11RT4.MAC	Check for XC, XL and MT service.  If
;					not present, warn and fake using TSX
;					TT: code.
; 38 09-Nov-85	12:35:05  K11M41.MAC	Alter XBINREAD to use MRKT$S for the
;					read timeout and do an IO.KIL if it
;					fails then convert IE.ABO to IS.TMO
; 38 07-Nov-85	15:13:06  K11M41.MAC	Rewrite handling for REMOTE DIR server
;			  K11E80.MAC	processing so that we do not fill up
;			  K11RTD.MAC	a file with the directory listing and
;			  K11SER.MAC	then send the file. Instead stuff
;					GETROUTINE: with &SDODIR.
; 38 06-Nov-85	16:20:33  K11SER.MAC	Change REM HELP to use asciz sender
;					instead of dumping to file and sending
;					the file for the extended response.
;
; 38 06-Nov-85	15:17:36  K11RT4.MAC	Change EPT name GETCR0 to FGETCR0
; 38 06-Nov-85	15:17:36  K11RMS.MAC	Change EPT name GETCR0 to FGETCR0
; 38 06-Nov-85	15:13:59  K11PAK.MAC	Moved GETCR0 to call actual next_char
;					routine via CALL @GETROUTINE so we can
;					support the use of alternate routines.
;					This allows extended server responses
;					to use memory or whatever instead of
;					temporary files.
; 37 05-Nov-85	10:19:47  K11PRT.MAC	Added .TWAIT for 1/3 second in TTYFIN
;					to avoid turning the XC/XL driver off
;					before all I/O has been sent to host.
; 37 04-Nov-85	17:23:30  K11PRT.MAC	Put back  in the kludges for the lack
;			  K11RTT.MAC	of a clock, which somehow got lost in
;					subspace somewhere (RT11 specific).
; 37 04-Nov-85	15:25:08  K11PRT.MAC	Various mods for CL: handler for TSX+
;			  K11RT4.MAC	to allow the use of 8BIT mode on the
;			  K11TSX.MAC	handler, also avoid dropping DTR when
;			  K11RTT.MAC	we close CL line. Dummy EPT's stuffed
;			  K11DSP.MAC	in K11TSX and K11RTT for reset @ exit
;					code.
; 37 04-Nov-85	13:23:52  K11REC.MAC	Insure call to FPARSE for case where
;					user says GET remote_name local_name
; 37 01-Nov-85	10:51:33  K11INI.MAC	Get defensive in RPAR so we can catch
;					short SINIT packets better and fix(?)
;					them. Needed for FIDO Kermit.
; 37 29-Oct-85	17:01:53  K11M41.MAC	Add code for IO.BRK on P/OS.
; 37 28-Oct-85	17:40:52  K11M41.MAC	Stuff *.*;* into DEFDIR in DODIR: iif
;					the first byte of DEFDIR is \0 (null)
; 37 28-Oct-85	13:37:44  K11CON.MAC	Added code re Steve Heflin to (1) do
;					a MRKT$S iif 'TC.DLU' does a zero to
;					non-zero transition,  and (2)  alter
;					function code for REMWRITE QIO if the
;					TC.DLU == 2 to IO.WBT!TF.WAL,  a must
;					do for M+ V3  and MicroRsx V3.	Would
;					assume not  needed for packet sending
;					as currently packet sending is block-
;					ing (ie, its half duplex).
; 37 19-Oct-85	17:17:49  K11DIA.MAC	Add DIAL command
; 37 19-Oct-85	17:00:01  K11ST0.MAC	Added SET MODEM command
; 36 13-Oct-85	15:27:45  K11SEN.MAC	Fix up control C aborts. Add new state
;			  K11REC.MAC	called STA.CCABORT for processng ctl C
;			  K11M41.MAC	aborts. Added IO.KIL in ctrl C ast
;			  K11E80.MAC	code for RSX and P/OS to stop current
;					i/o operation. Can't do this on RSTS.
; 36 10-Oct-85	14:53:55  K11CON.MAC	Save and reset speed if change TC.DLU
; 36 10-Oct-85	14:51:33  K11PAK.MAC	Fix call from M$RETRY to ERROR()
; 36 24-Sep-85	12:29:53  K11E80.MAC	Added REMOTE LOGIN and support for it
;			  K11SER.MAC	in the server. The server support makes
;			  K11COM.MAC	sense only for RSTS/E V9.x since RSTS
;			  K11CMD.MAC	is the only PDP exec supporting logins
;					via executive directives. REM LOGIN was
;					a request by Dale Handy for a specific
;					application.
;			  K11CMD.MAC	Disabled for SEND if wilcarded filename
;			  K11SEN.MAC	and   GET filename destination_filename
; 36 17-Sep-85	10:55:06  K11REC.MAC	Allow SEN filename destination_filename
; 36 17-Sep-85	10:54:11  K11ST0.MAC	Added SET RT11 CREATE_SIZE value to
;					for allocation for small disks on file
;					creates, sometimes needed for Kermit-11
;					to non Kermit-11 transfers.
; 36 13-Sep-85	12:30:12  K11ST1.MAC	Added SET REC START-OF-PACKET, also
;			  K11PAK.MAC	SET SEN STA . Also added
;					SET START-OF-PACKET which forces both
;					SOP's to same value.
; 36 10-Sep-85	13:38:31  K11ST0.MAC	Added SET RT11 command, currently as
;			  K11RTD.MAC	SET RT11 [NO]VOLUME_VERIFY, to skip
;			  K11DAT.MAC	checking systype at offset 760 in the
;			  K11RT4.MAC	directory header for disks. Also added
;			  K11COM.MAC	SET RT11 [NO]FLOW_CONTROL, same as the
;					old SET RTFLOW [ON][OFF]
; 35 01-Sep-85	14:45:33  K11SEN.MAC	Added messages for retry aborts.
; 35 01-Sep-85	14:30:22  K11PAK.MAC	Modified insertion of prompt into error
; 35 01-Aug-85	14:15:10  K11CVT.MAC	Fix filenames with fubar characters
;			  K11REC.MAC	to be legit (insert 'x' into name),
;					as in GET abcde_f.dat --> abcdexf.dat
; 34 29-Jul-85	14:22:28		Mod REM CWD to accept password if
;					present, no prompts though.
; 33 16-Jul-85	21:12:01  K11HLP.RNo	Update HELP for SET RSX.
; 33 16-Jul-85	21:10:47  K11M41.MAC	Do a MCR SET/NORPA=TTn:, needed if the
;					line was set to /RPA as /RPA tells the
;					TTDRV to pass XON and XOFF thru.
; 33 16-Jul-85	20:57:50  K11RXX.MAC	Added new connect code, for now invoked
;			  K11ST0.MAC	via SET RSX CONNECT ALTERNATE, default
;			  K11CON.MAC	is SET RSX CONNECT DEFAULT. If it works
;					out ok, will change new code to default
;					as it appears to do the connect i/o
;					better due to it's own internal xon/xof
;					and double buffering.
; 32 02-Jul-85	22:29:34  K11HLP.RNO	Add Doc for modems.
;
; 32 02-Jul-85	13:44:50  K11CMD.MAC	Added support for CWD and REM CWD.
;			  K11SER.MAC	Support for GN$CONNECT (rem cwd)
;			  K11COM.MAC	Added CWD and REM CWD to command lists
; 32 02-Jul-85	13:14:22  K11INI.MAC	Set pro/350 to 7 bit to avoid multinat
;					char sets, use SET CONS 8 to override.
; 32 02-Jul-85	13:10:31  K11CON.MAC	Set remote line to binary mode for RSTS
;					version 9 for the CONNECT command, (see
;					TTDVR, it changes C1 ( > 200 (8)) chars
;					to escape sequences, neat, huh?).
; 32 02-Jul-85	13:02:04  K11PAK.MAC	Insert current prompt into error text
;					sent to other system.
;
; New tape to Columbia	  V2.31
;
;
; 31 20-Jun-85	18:42:39  K11SEN.MAC	Updated SDATA to not abort on 'unknown'
;					packet type.
; 31 20-Jun-85	18:42:27  K11SHO.MAC	Updated SHOW command
; 31 17-Jun-85	15:29:36  K11RT4.MAC	Added .HRESET if device was X?: at exit.
; 31 17-Jun-85	14:53:34  K11CMD.MAC	Add call to RSTSRV to restore line chars
;					if control C abort under SERVER & RSX.
; 31 17-Jun-85	14:23:14  K11CON.MAC	Wait 6 seconds if changing TC.DLU
; 30 04-Jun-85	11:26:04  K11M41.MAC	Added SET RSX CHARIO and SET RSX LINEIO.
;			  K11ST0.MAC	The former will force packet reads to do
;					a SF.GMC for the typeahead count, then
;					read that many under IO.RAL, as is done
;					for P/OS. The latter will (default) do
;					reads by line for M and M+.
; 30 04-Jun-85	11:23:52  K11ST0.MAC	Added SET RSX TC.DLU value to alter
;			  K11M41.MAC	the tc.dlu setting for connecting to a
;			  K11DAT.MAC	modem. By default, Kermit will never try
;			  K11CON.MAC	to change it, however, a value of 1 or 2
;			  K11COM.MAC	will force a change if not already set.
; 30 01-Jun-85	11:04:31  K11M41.MAC	Add 19.2 and 38.4 speeds into SET SPEED
; 30 01-Jun-85	11:03:30  K11INI.MAC	Mods for SET UPDATE, also set do a SET
;					TER VT100 for PRO/3xx systems.
; 30 01-Jun-85	11:02:28  K11ST1.MAC	Added LOGFILE filename.type so we can
;					be more compatible (calls SET LOGFILE)
; 30 01-Jun-85	11:01:45  K11DAT.MAC	Added 'BLIP::' for packet logging ala
;					SET UPDATE n. A SET UPD 0 will disable
;					all packet counts to the terminal.
; 29 18-May-85	14:17:39  K11SER.MAC	Update packet types to symbolic names
; 29 17-May-85	05:08:47  K11ST1.MAC	Add SET FIL [NO]SUPERCEDE to protect
;			  K11REC.MAC	files that already exists.
; 29 14-MAY-85	10:26:33  K11INI.MAC	Fix bug for setting 8bit prefixing.
;					Quite noticable on PRO/RT version.
; 28 09-May-85	07:40:41  K11RTD.MAC	Add support for server REM DIR command
;					for RT and TSX+.
; 28 07-May-85	17:40:06  K11TSX.MAC	Final mods by Ned Rhodes for TSX+
;			  K11PRT.MAC
; 28 01-May-85	16:00:01  K11ST1.MAC	Ignore TYPE in SET FILE [TYPE] arg
; 28 22-Apr-85	10:34:56  K11RT4.MAC	Kludge if RT system does not have a
;			  K11RTT.MAC	clock.
; 28 20-Apr-85	09:22:01  K11ST1.MAC	Added SET BINARY-TYPE .filetype for
;			  K11CVT.MAC	overriding the built-in binary file
;					type list.
; 27 XX-Apr-85		  K11M41.MAC	Fix ASSDEV: for stack problem
; 27 19-Mar-85	15:59:06  K11SEN.MAC	Fix losing attribute packets in case
;					we timed out or were naked.
; 26 28-Feb-85	14:01:08  K11RMS.MAC	Change % to ? in wildcards for RSTS/E
;			  K11SER.MAC	server to kludge around the problem
;					that some Kermits mangle ? in cmdline
; 26 28-Feb-85	14:00:30  K11RT4.MAC	Fixes for TSX+
;			  K11DSP.MAC
;			  K11TSX.MAC
; 26 20-Feb-85	15:13:05  K11E80.MAC	Changed default record format from
;					FILES-11 variable to STREAM ASCII.
; 25 29-Jan-85	09:40:22  K11SEN.MAC	Fix things up for ^e,^x and ^z inter-
;			  K11REC.MAC	upts on getting and sending files.
; 25 28-Jan-85	15:30:01  K11SER.MAC	Get rid of imbedded crlfs in the short
;					server reply string.
; 25 17-Jan-85	10:56:03  K11HLP.HLP	More explanation about BINARY files as
;					there seems to be a lot of confusion
;					about binary file transfer.
; 25 17-Jan-85	10:53:17  K11CON  BDN	Added SET CONSOLE 7, SET CONSOLE 8 to
;			  K11ST1  BDN	force P/OS Kermit11 to junk bit 7 when
;					in terminal mode, thus avoiding DEC's
;					multinational character set.
; 25 17-Jan-85	10:52:38  K11DSP  BDN	Clear PROFLG in ASSDEV if SET LINE is
;					done and device is not X?: for RT11.
; 25 17-Jan-85	10:51:58  K11SEN  BDN	Added abort (^E,^X & ^Z) for SENDing.
; 25 16-Jan-85	13:20:45  K11E80  BDN	Mods for much faster packet reading.
;					Sped file get up by about 35% for RSTS
; 24 26-Nov-84	11:46:53  K11E80  BDN	Fix a UU.TRM call for RSTS T9.0-07.
; 24 09-Nov-84	15:35:17  K11TSX  BDN	Creation from NED RHODE'S modifications
;					to K11RTT for TSX+.  Note that this one
;					I can never test as I do not use TSX.
; 24 09-Nov-84	15:35:05  K11DSP  BDN	Creation.
; 24 09-Nov-84	15:32:36  K11RT?  BDN	Virtual overlays for XM, K11DSP to call
;					the  correct terminal i/o overlay based
;					on the exec and line type (ie, TSX+ and
;					XC/XL). We can now  AVOID  generating a
;					differnt save image for each config.
; 23 25-Oct-84	16:47:20  K11XXX  BDN	This is getting to be a drag having to
;					generate six different versions of the
;					Kermit-11 each time I change something.
; 23 25-Oct-84	16:46:01  K11CON  BDN	Removed break sending code to specific
;					executive support modules.
; 23 25-Oct-84	16:45:36  K11PRT  BDN	Real break sending for the PRO/RT11
; 23 25-Oct-84	16:45:11  K11ST1  BDN	SET REPEAT ON/OFF
; 23 25-Oct-84	16:44:52  K11PAK  BDN	Repeat count prefixing added.
; 23 21-Oct-84	16:37:57  K11???  BDN	Got sick of working on PRO/RT11.
; 23 21-Oct-84	16:38:36  K11CMD  BDN	Moved printing of banner.
; 23 21-Oct-84	16:37:16  K11REC  BDN	Added error logging and got all state
;					switches parameterized.
; 23 21-Oct-84	16:36:51  K11CVT  BDN	Added new filetypes for binary mode.
; 23 16-Oct-84	15:32:31  K11CM1  BDN	Removed	 number of commands from K11CMD
;					to save space for PRO/RT11 version.
; 23 15-Oct-84	13:52:09  K11RT?  BDN	Fixed all the .FETCH stuff
; 23 15-Oct-84	13:39:22  K11ST1  BDN	Creation, split K11STT in half for RT11
; 23 15-Oct-84	13:39:22  K11ST0  BDN	Creation, split K11STT in half for RT11
; 23 15-Oct-84	13:39:05  K11CMD  BDN	Moved C$SET back in
; 23 14-Oct-84	16:01:22  K11PRT  BDN	New  module for XC port communications
;					with PRO/RT11 version 5.1
; 23 14-Oct-84	15:20:13  K11SEN  BDN	Creation, split receive and send state
;			  K11REC	out from K11PAK to save space for  the
;					PRO/RT11 version of Kermit.
; 22 20-Aug-84	14:51:05  K11M41  BDN	Mods for P/OS
; 22 15-Aug-84	09:15:32  K11M41  BDN	Slave the connect line at SET LINE  in
;					routine ASSDEV (restored @ exit). Also
;					add RPOI$S call to  ...BYE for generic
;					logout from server.
; 22 14-Aug-84	10:24:23  K11RTU  BDN	Added code for ASCTIM for RT11 Kermit.
; 22 14-Aug-84	10:21:51  K11ATR  BDN	Add attribute packet type 41 (8) so we
;			  K11RMS	send  the recieving Kermit the size of
;			  K11RT4	the file. Needed for RT11 Kermit since
;					RT11 needs to preallocate files. Could
;					not create file larger than 243 blocks
;					on the PDT150 until this was put in.
; 22 10-Aug-84	13:20:31  K11RT4  BDN	Moved ERROR text and error lookup code
;			  K11RTU	to K11RTE.MAC, also moved RT11 COPY to
;					K11RTU overlay.
; 22 08-Aug-84	15:50:33  K11RTD  BDN	Change the check for RT11 volume valid
;					from home block offset 730 to 760.
; 22 03-Aug-84	10:28:54  K11PAK  BDN	Finish code for talking to half duplex
;			  K11COM	IBM 370 compatible systems.  Added SET
;			  K11STT	IBM ON/OFF, SET LOCAL ON/OFF.  SET LOC
;					is equivalent to SET DUPLEX FULL/HALF.
; 22 03-Aug-84	10:28:23  K11M41  BDN	Hook for single character reads if any
;					handshaking character is set.
; 21 30-Jul-84	16:11:36  K11M41  BDN	Added date and time ascii conversion.
; 21 30-Jul-84	16:11:01  K11COM  BDN	Added commands TIME and DATE
; 21 30-Jul-84	16:08:17  K11M41  BDN	Fix TTPARS to return device name so we
;					can use DECNET/M HTnn: device names.
; 21 30-Jul-84	16:07:44  K11CVT  BDN	Add .EXE and .RTS to binary file list.
; 21 30-Jul-84	11:17:24  K11PAK  BDN	More work for IBM mode
; 21 24-Jul-84	11:35:15  K11RTD  BDN	Extended directory lookup for RT11 to
;					allow '%' in the filename or type.
; 21 23-Jul-84	12:47:03  K11DEF  BDN	New module, an '.include' file to define
;					all the packet types.
; 21 23-Jul-84	12:32:11  K11SER  BDN	Stuff the default device into the server
;					extended reply temp filename (needed for
;					RT11 Kermit).
; 21 23-Jul-84	12:31:47  K11RT4  BDN	Insure that we are NOT running under the
;					SJ monitor.
; 21 19-Jul-84	15:35:00  K11PAK  BDN	Added 8 bit prefixing
; 20 19-Jul-84	10:26:57  K11RTU  BDN	Add support for RENAME and DELETE for RT
;					version 5.
; 19 15-Jul-84	17:14:10  K11E80  BDN	Add checks to be sure that the SET  LINE
;					devicename was a real device for  RSTS/E
;					and not some file name like SET LIN 1.
; 19 11-Jul-84	17:59:20  K11STT  BDN	Add SERVER DETACH command to allow  ser-
;			  K11M41	ver to detach from KB: (or TI:).  In the
;			  K11E80	the case of RSTS/E, spawn new job to log
;			  K11RT4	the caller back in.
; 19 11-Jul-84	17:49:26  K11ATR  BDN	Fix RMS problem with attributes for RSTS
;					non attributed binary files.
; 18 06-Jul-84	15:20:34		Update sent  to Frank Da Cruz  for fubar
;					RT11 code with .FETCH and .DSTAT
;
;
; 18 06-Jul-84	13:29:21  K11RTT  BDN	Add loop to eat any buffered server NAKS
;					in TTYINI().
;
;
; 18 03-Jul-84	10:16:03  K11INI  BDN	Moved INIT and KERINI from K11CMD.MAC to
;					module (K11INI).  Also moved SPAR, RPAR,
;					DSKDMP and FILLOG from K11PAK to here to
;					save space in the root for RT11 version.
; 18 06-Jul-84	12:45:27  K11RT4  BDN	Finally found out that I had gotten  the
;					arguments for .DSTAT swapped, which will
;					explain why the RT11 file opens and cre-
;					ates were being so flakey.
; 18 26-Jun-84	09:06:03  K11LCL  BDN	Optionally slow transfer rate down for
;					user's based on the uic and speed
; 17 22-Jun-84	12:33:15  !!! finally ship new version out to Columbia !!!
;
;
; 17 22-Jun-84	11:20:29  K11M41  BDN	Add SREX$S  call in TTYINI so an aborted
;					server can fix the line back up.
;
; 17 22-Jun-84	09:31:19  K11RMS  BDN	Don't set fb$wri in the FAC field when a
;					file is readonly for binary file reads.
; 17 21-Jun-84	19:33:48  K11RT4  BDN	Final RT11 code modifications.
; 17 21-Jun-84	16:22:12  K11CMD  BDN	Fix open for takefile (missing type arg)
; 17 21-Jun-84	15:19:46  K11STT  BDN	If set line kb: or set line ti: then  we
;			  K11M41	should reset back to remote mode.
;			  K11E80
; 17 19-Jun-84	18:08:56  misc	  BDN	Add xon/xoff support to RT11 connect be-
;					cause the MT service for RT has	 far too
;					much  overhead	for speeds  greater than
;					300 baud.
;					Add wildcard support for RT11 version.
;					Add IO.ATT for slaved terminal re M+ 2.1
;					and RSX v4.1 kits (curse you, K. Olsen).
;					The 'new'  versions of	M+ and M disable
;					typeahead  for	slaved lines  unless the
;					device is attached (?). Rather odd (?)
; 17 11-Jun-84	11:21:51  K11CVT  BDN	Add  code to decide if	a file is binary
;					based on the filetype (ala .SAV, .BAC..)
; 17 10-Jun-84	16:44:50  K11RTT  BDN	Reduce tt read overhead for RT11 version
;			  K11RT4  BDN	Dummy out K11LCL for RT11 to save space.
;			  K11RT4  BDN	Timing bug in file open routine (?)
;			  K11RT4	Fix overlay error  (K11ATR with K11SUB).
; 16 28-May-84	15:55:08  K11PAK  BDN	Insure that 'BUFEMP' does not try to CTL
;					characters that could not have been set.
;					Defensive response to the CPM Kermit 3.9
;					which ALWAYS sends ampersands  over with
;					the CTL quote, '#'.  Note: 20KERMIT does
;					this also.  Fix should be in CPM Kermit,
;					but it's simple to fix at this end.
; 16 28-May-84	09:10:19  K11CMD  BDN	Fix call to TTYRST for Kermit-11/RT
; 16 28-May-84	09:09:40  K11RTT  BDN	Kermit-11 now runs under the FB moniter
;					for Rt11 version 5 with MT support.
; 16 28-May-84	09:08:47		Version 3.0.051 of VMS Kermit  fixed the
;					above problem of ACK length.
; 16 25-May-84	15:40:35  K11PAK  BDN	Problem with VMSKERIT not liking 10 char
;					acks for 'S' packets, changed ACK packet
;					size to 11 for the time being until  the
;					problem can be isolated.
; 16 25-May-84	15:39:26  K11STT  BDN	Moved command definitions for the  'SET'
;					command to K11COM.MAC to save space.
; 16 25-May-84	12:18:08  K11DEB  BDN	Added 'DISPLAY globalsym' command.  This
;					prints out values of variables in module
;					K11DAT.MAC for debugging purposes.
; 16 21-May-84	17:01:56  K11PAK  BDN	Don't retry until MAXTRY the SINFO ('I')
;					packet since older Kermit's will not  be
;					able to understand 'I' packets. The  old
;					Kermits will ALWAYS send NAKS for SINFO.
; 16 18-May-84	10:29:02  K11SER  BDN	The code for response to an  'R'  packet
;					was sending the RMS error text after the
;					routine GETNXT already sent error packet
; 16 14-May-84	09:38:50  K11CON  BDN	Check for errors from the qio's for RSX.
;					In particular, catch the IE.DNR in  case
;					the carrier drops.
; 15 08-May-84	11:15:35  K11PAK  BDN	Insure R0 cleared in BUFEMP in case  the
;					the data packet was null.
; 15 06-May-84	11:33:56  K11PAK  BDN	Moved  the  ACK for the EOF packet to be
;					send AFTER the output file is closed. An
;					occasional RSX problem in that the BREAK
;					packet was lost	 due to timing	required
;					this mod,  though  if the line is set up
;					properly this would not be a problem.
; 15 06-May-84	11:33:38  K11RMS  BDN	Increased record buffersize to 160
; 15 04-May-84	13:56:21  K11M41  BDN	Fixed read  timeouts in RBD's version of
;					BINREA.	 Also hooked BINREA into CANTYP.
; 15 03-May-84	10:29:22  K11E80  BDN	Added UU.SPL stuff for the PRINT command
;			  K11M41	Dummy support for it on RSX since PRINT$
;					macro needs FCS, not RMS, support.  Will
;					check RMS out or else SPAWN a PRINT cmd.
; 15 03-May-84	10:25:46  K11M41  BDN	Fixed the faking of BREAK for RSX.  Pass
;			  K11CON	a LUN to use for the set speed QIO.
; 15 02-May-84	11:03:57  K11RMS  BDN	Found  out that either INIDM from SYSLIB
;					or the GSA code from the RMS v2 kit will
;					fail if th e task size is exactly on a 1
;					KW boundary. In this case the high limit
;					was 113777,  causing $INIDM  to crash at
;					startup.
; 15 01-May-84	11:41:49  K11ATR  BDN	Added support for attribute packets.
;					Allow auto determination of binary mode.
;					Support for getting  the IFAB data  will
;					only work between like Kermits.
;					Added SET ATTRIBUTES OFF command to dis-
;					able  any attribute  sending even if the
;					other Kermit's CAPAS field indicates the
;					support of it (ie,  handle  incompatible
;					protocal versions or bugs)
; 14 18-Apr-84	10:41:34  K11RMS  BDN	Added 'inited' flag for lun being active
; 14 18-Apr-84	10:40:01  K11PAK  BDN	Mods for defered file creates to handle
;					attribute packets
; 14 12-Apr-84	17:07:51  K11CON  BDN	Print speed and escape seq for CONNECT.
; 13 04-Apr-84	18:43:33  K11RMS  BDN	Added ept's FOPEN and  FCREATE to  allow
;					use of multiple	 block buffering for seq
;					files. Desired for use by HELP command.
; 13 04-Apr-84	18:39:38  K11SER  BDN	Calls to SINFO if we expect an	extended
;					reply from a remote server, required  if
;					block checks are type 2 or 3.
; 13 04-Apr-84	18:37:58  K11CON  BDN	Have X command cancel link being xoff'ed
;					by the remote as well as send the remote
;					an xon.
; 13 04-Apr-84	10:13:32  K11PAK  BDN	Debug logging mods. Added calls to TTXON
;					to fix xoff'ed line.  Also added routine
;					SINFO to handle init for expected server
;					reply.
; 13 04-Apr-84	09:36:06  K11STT  BDN	Changes to SET BLOCK
; 13 03-Apr-84	17:11:35  K11M41  BDN	Added TTXON to cancel xoffed line state.
; 13 03-Apr-84	16:22:01  K11E80  BDN	Added TTXON to cancel xoffed line state.
; 13 02-Apr-84	17:14:29  K11E80  BDN	Insure that no single  private delimiter
;					is set for  the terminal, ala the ttyset
;					command SET DELIMITER "ch".  If	 set, an
;					unusual exec bug seems to creep	 in when
;					a .sleep is executed ????
; 13 02-Apr-84	11:14:36  K11CON  BDN	Added support for half duplex link. Also
;					added global 'duplex' to K11DAT.MAC
; 13 02-Apr-84	11:14:12  K11STT  BDN	Added SET DUPLEX HALF, SET DUPLEX FULL
; 13 30-Mar-84	10:45:08  K11E80  BDN	Removed	 hardware parity set code  since
;			  K11M41	we will generate our own if need be.
; 13 30-Mar-84	10:40:35  K11MAC  BDN	Defined a macro	 for XOR which	does not
;					require 'XOR reg,dst' format.  It uses 4
;					instructions  and will	be needed anyway
;					for the RT11 version.
; 13 30-Mar-84	10:34:02  K11PAK  BDN	Fix extended server replies to work when
;					the checksum is type 2 (12bit arith sum)
;					or type 3 (16 bit CRC).
; 13 30-Mar-84	10:33:03  K11E80  BDN	Rewrote DIRECTORY code, disable non-priv
;					users from looking at other accounts. Is
;					patchable via ONLPAT, see K11INS.DOC.
; 13 30-Mar-84	10:32:44  K11LCL  BDN	Modified protection for commands.
; 13 30-Mar-84	10:31:46  K11PAK  BDN	Added software parity generation.  Would
;					be mainly used when connecting out to  a
;					remote system that requires parity.
; 12 23-Mar-84	08:47:08  K11LCL  BDN	Rewrote so commands  can be disabled via
;					ONLPAT for RSTS/E.
; 12 20-Mar-84	20:06:06  K11E80  BDN	Modified control C ast support so it can
;					be compatible  with the	 newly added RSX
;					control C ast processing.
; 12 20-Mar-84	20:04:15  K11M41  BDN	Added control C ast recognition for RSX.
; 12 20-Mar-84	20:03:16  K11CON  BDN	Added  directive SREX$S	 for RSX connect
;					to reset the  TT: lines to  their former
;					states in case of an ABORT.
; 12 20-Mar-84	19:57:16  K11E80  BDN	Conditional'ed out  NAMCVT,  which I re-
;			  K11M41	wrote and put into K11CVT.MAC.
; 12 20-Mar-84	19:55:15  K11CVT  BDN	A new module.  Do  executive independent
;					parsing of file specs to return only the
;					filename.filetype.  This will help those
;					users who  need DAP support.  It's  also
;					overlayed into the ERRDVR region.
; 12 19-Mar-84	16:52:51  K11RMS  BDN	Put  back SY:  defaulting for RSTS only.
;			  K11CPY	Done if	 TST FU$DEF  is <> 0.  FU$DEF is
;					defined in K11E80 to be .word 177777. In
;					K11M41 it is .word 0.
; 12 19-Mar-84	14:15:40  K11CMD  BDN	Add check for device name on CONNECT cmd
;			  K11RMS	Add routine to get MCR/CCL command line.
; 12 17-Mar-84	13:23:45  K11RMS  BDN	Add in Bob Denny's mods for RSX i/o  and
;			  K11CON	doing RMS DAP access correctly.
;			  K11M41
;			  K11CPY
;
; 12 14-Mar-84	16:58:12  K11RMS  BDN	Skip the $SEARCH if there is no wildcard
;					context.  This gets around problems with
;					RSTS sites that modify the exec to alter
;					the way the exec does directory lookup.
;					This option is only executed if the  lo-
;					cation FU$DIR is <> 0 (see K11RMS.MAC)
;
; 12 14-Mar-84	10:49:37  K11E80  BDN	Don't  set 8BIT mode for the cpu console
;					if we are  running Kermit  from it  as a
;					local Kermit dialing out (RSTS/E only).
; 12 14-Mar-84	10:45:39  K11CON  BDN	Added  'BIC #^C177,R1'	in front of both
;					of the	'CMPB R1,CONESC'  to fix problem
;					using Kermit's connect command from  the
;					console (TT00: or KB0:)
; 12 08-Mar-84	12:33:59  K11CMD  BDN	Added default of '.CMD' for TAKE
; 12 08-Mar-84	11:56:14  K11CMD  BDN	Move  'remlst' and 'cmdlst' into  K11COM
;					which is overlayed in the ERROR segment.
;					Added calls to LOACMD and LOAREM to  get
;					the overlay with K11COM resident and  to
;					return a pointer to the command list. It
;					saves about 3000 (8) bytes in task size.
;					Note that  this does  not sit  well with
;					what $AUTO likes to do.
;					If it causes a problem, put K11COM  back
;					into the root.
;					Also had to make all RM$xxx epts in  the
;					module K11CMD global.
; 12 07-Mar-84	12:28:16  K11TRA  BDN	Added routine to 'brute force' a file to
;					a remote line. Needed it to get the  new
;					(and not yet done) RT11 version onto the
;					RT11 system being used for testing which
;					is, would you believe, a real PDT150.
; 12 06-Mar-84	16:05:42  K11CMD  BDN	Mods to override auotmatic use of  local
;					terminal name if we're running in server
;					mode and the user did a SET LINE TTnn:
; 11 05-Mar-84	10:22:48		Sent version 2.11 to  Columbia and  DEC.
;					Did NOT include Bob Denny's RSX mods.
;
; 11 02-Mar-84	11:27:22  K11CMD  BDN	Modified init stuff to look for the init
;					file KERMIT.INI in SY: then if not there
;					to try	LB:[1,2], SY:[1,2] and KERMIT:
;
;
; The following mods were done by:
;	Bob Denny
;	Alisa Systems, Inc.
;	Pasadena, Ca
;
; 10 xx-Mar-84	xx:xx:xx  K11M41	Bob also rewrote much of the RSX i/o
;					support and wrote the connect code for
;					RSX using asynch qios.
; 10 07-mar-84	14:47:00  K11CPY	Close input file if $create failed.
;
; 10 05-Mar-84	15:47:30  K11CPY	Remove defaulting to SY: so Decnet  will
;					work  with systems that don't understand
;					SY:
; 10 04-Mar-84	02:55:47  K11RMS	Many small changes to allow DECNET (DAP)
;					remote file access. See comments in
;					K11RMS.MAC
; 10 04-Mar-84	01:10:03  K11M41	Remove FCS style filename parsing and
;					allow DAp remote file specifications.
; 10 03-Mar-84	20:44:35  DAP11S.ODL	Created this for sequential-only DAP
;					support RMS. General purpose, though.
; 10 03-Mar-84	20:41:10  K11DAP.ODL	Add new odl for Decnet (DAP) remote file
;					support for RSX11M.
; 10 03-Mar-84	20:34:18  K11RSX.ODL	Remove FCS parsing factor
;
;
; The following mods were done by:
;	Brian Nelson
;	Change Software, Inc.
;	Toledo, Ohio
;
; 10 17-Feb-84	15:08:05  K11CMD  BDN	Did some trial	stuff on talking  to IBM
;					mainframes,  but  the CMS  Kermit  makes
;					things difficult as it can't time out.
;					Added Set Handshake and show for it. Not
;					yet done with handshake garbage.
; 10 17-Feb-84	15:07:14  K11PAK  BDN	Mods for  doing ^X and ^Z  things.  Also
;					affected K11M41 and K11E80.
; 09 10-Feb-84	12:25:17  K11M41  BDN	Add HANGUP via IO.HNG qio, added code to
;					spawn  MCR SET /SPEED=TTnn:xxxx:xxxx  if
;					the SF.SMC  call to  change speed  fails
;					with  an IE.PRI error,	also changed the
;					cli for SPWN$S to CLI... from MCR...
;					Also use MCR spawn for disabling echo.
; 08 09-Feb-84	21:33:55  K11RSX.ODL	Overlayed CSI1, CSI2 and PARSE which are
;					used to get the simple filename.ext from
;					the RMS11 expanded name string.
; 07 09-Feb-84	09:20:34  K11E80  BDN	Try to anticipate the DHV11 q bus inter-
;					face for  showing and setting speed.  No
;					changes needed to K11M41 for rsx.
; 07 08-Feb-84	15:19:58  K11SER  BDN	Force mode to be remote if we are to run
;					as a server. Not really needed, but what
;					about doing a SET LINE and then SERVER ?
; 06 06-Feb-84	10:34:04  K11PAK  BDN	Added SETTMO to decide what receive time
;					out to use based on server timeout,  the
;					other  kermit's desired	 timeout and any
;					timeout set via SET TIMEOUT value.
; 06 04-Feb-84	11:55:22  K11CMD  BDN	Added local copy and remote copy, rename
; 06 04-Feb-84	11:54:59  K11SER  BDN	Added remote copy and rename support.
; 06 04-Feb-84	11:53:32  K11CPY  BDN	New module, do file copies using RMS i/o
;					This could be dependent on new	versions
;					of  RMS11 as I access  the IFABS to copy
;					the correct file attributes,
; 06 03-Feb-84	10:06:23  K11RMS  BDN	Rewrote	 the default  directory to  work
;					the way	 it should by using  $PARSE  and
;					the DNS and DNA fields in the FAB.  Also
;					added FPARSE to return an expanded name.
;					Changes to K11CMD, K11SER and K11PAK.
; 06 02-Feb-84	17:24:19  K11E80  BDN	Fix  CANTYP and	 change parameter  list.
;					Mods required to K11SER, K11PAK,  K11CMD
;					and K11M41.
; 06 01-Feb-84	14:25:46  K11RMS  BDN	Insure FB$FID in the FOP is cleared  for
;					the $ERASE call.
; 06 01-Feb-84	13:07:26  K11CMD  BDN	Local and remote WHO commands.
; 06 01-Feb-84	13:07:10  K11SER  BDN	Add support for remote WHO command
; 06 01-Feb-84	13:06:36  K1180S  BDN	New module, do a partial SYSTAT for RSTS
; 06 01-Feb-84	10:37:49  K11SER  BDN	Support remote type in server
; 06 01-Feb-84	10:36:27  K11CMD  BDN	Add  'REMOTE TYPE' and added 'DISK to be
;					same as 'SPACE'
; 06 01-Feb-84	10:22:17  K11SER  BDN	Insure KERMIT.TMP has the default device
;					string inserted in it for create.
; 06 01-Feb-84	10:21:19  K11CMD  BDN	Moved type and rename commands to K11SHO
;					to space space in the root.
; 05 31-Jan-84	09:36:56  K11RMS  BDN	Fixed  help file access	 problem at  the
;					source, ie, insure FB$GET is set only if
;					the file is opened for reading.
; 05 31-Jan-84	08:41:03  K11CMD  BDN	Moved SHOW command to  K11SHO.MAC,  also
;					moved $NAME and COMMAND macros to K11CDF
; 05 30-Jan-84	20:10:28  K11HLP  BDN	Found out  that K11HLP	needs temp privs
;					to get at the help file (K11HLP.HLP). If
;					the sys	 manager installs  the	optional
;					patch to FIP for UU.LOK then a <234>  is
;					needed.
; 05 30-Jan-84	16:38:01  K11SER  BDN	Consolidated remote  server command pac-
;					ket sending and creation.
; 05 30-Jan-84	13:44:28  K11RMS  BDN	Added  RMS $ERASE  code and disk logging
;					of files deleted.
; 05 30-Jan-84	12:01:41  K11CMD  BDN	Add ERASE, DELETE
; 04 27-Jan-84	21:33:21  K11CMD  BDN	Added REM ERASE,  also add synonyms  for
;					SET LOGFILE as LOG_FILE and LOG-FILE.
; 04 27-Jan-84	20:02:34  K11HLP  BDN	Fix keyword match to  match @ position 1
; 04 27-Jan-84	18:55:44  K11PAK  BDN	If datafield.len < 0 then reset checksum
;					type to type '1' in RPACK$
; 04 27-Jan-84	18:45:08  K11SER  BDN	Redo support for remote commands
; 04 27-Jan-84	18:30:07  K11PAK  BDN	Redo support for extended server replies
;
; Version 2
;
;
; I decided that I would like to have the normal TED timestamp on the edit.
;
;
;	03 25-jan-84  K11RMS	BDN	Added support for stream ascii
;	03 25-Jan-84  K11CMD	BDN	Added SET RECORD-FORMAT STREAM and
;					and   SET RECORD-FORMAT VARIABLE
;	03 25-Jan-84  K11HLP	BDN	Finished subtopics for HELP command
;	03 23-Jan-84  K11SER	BDN	Finished  prototype version of extended
;					replies and added the  remote DIRECTORY
;					command (generic D) to test it for RSTS
;	03 23-Jan-84  K11M41	BDN	Modified CANTYP(lun) to force LUN 5  if
;					a value of zero (0) is passed for a lun
;					to  make it  compatible	 with  the RSTS
;					version of CANTYP.
;	03 23-Jan-84  K11E80	BDN	Rewrote NOECHO(line)  and ECHO(line) to
;					set noecho when the remote  link is set
;					via SET LIN  and open in K11CON.  Added
;					calls in K11CMD and K11CON to NOECHO.
;	03 22-Jan-84  K11M41	BDN	Fixed  BINREAD(lun,tmo)	 to work with a
;					passed timout of '-1' to effect a  read
;					without wait (no stalling if no data).
;	03 20-Jan-84  K11M41	BDN	Test and fix TTSPEED, SETSPD and BINREA
;					for RSX11M/M+
;	02 18-Jan-84  K11CMD	BDN	Added  REMOTE,	SPACE and  REMOTE SPACE
;					commands.  Support  added to K11E80 and
;					K11SER for generic U command.
;	02 17-Jan-84  K11CMD	BDN	Added  commands	 NOTE and  COMMENT  for
;					echoing text from indirect files.
;	02 17-Jan-84  K11CMD	BDN	Allow open for KERMIT.INI
;	02 17-Jan-84  K11PAK	BDN	Allow 12 bit and CRC-CCITT Checksums
;					The user should always set the checksum
;					type for both KERMITS.
;	02 16-Jan-84  K11CMD	BDN	Allow  underscore and digits in command
;					names.
;	02 16-Jan-84  K11PAK	BDN	Redo  checksum processing to accomadate
;					12 bit and CRC types.
;	02 16-Jan-84  K11CMD	BDN	Add Set Block-Check-Type and SHOW BLOCK
;	02 13-Jan-84  K11CMD	BDN	Moved C$HELP to module K11HLP
;	02 13-Jan-84  K11M41	BDN	More rsxm/m+ code added
;	02 13-Jan-84  K11CMD	BDN	Added showing speed for SHOW LINE
;	02 13-Jan-84  K11CMD	BDN	Added TAKE and @ commands
;	02 12-Jan-84  K11PAK	BDN	Fix checking for X , Z in ACK for Sdata
;	02 11-Jan-84  K11CMD	BDN	Added RENAME command
;	02 11-Jan-84  K11RMS	BDN	Added RMS rename
;	01 08-Jan-84  K11PAK	BDN	Fix .asicz for ERROR: SPACK
;	01 08-Jan-84  K11CMD	BDN	Added  call to XINIT for initialization
;					based on the operating system.
;	01 08-Jan-84  K11PAK	BDN	Change	timeout to  MYTIME from MAXTIME
;					if remote's SINIT packet had a value of
;					zero for the timeout (CMS kermit?)
;	01 08-Jan-84  K11CMD	BDN	fix SET PARITY


	.sbttl	define macros and things we want for KERMIT-11



	.if ndf, K11INC
	.ift
	.include	/IN:K11MAC.MAC/
	.include	/IN:K11CDF.MAC/
	.endc

	.iif ndf, k11inc, .error ; INCLUDE for IN:K11MAC.MAC failed

	.macro	$NAME junk
	.endm	$NAME
	.psect	$code

	cc$max	==	2

	.enabl	gbl








	.sbttl	the main program
	code

	.enabl	lsb			; For I/D space

kermit::message
	tst	do$ver			; /41/ Always print version #?
	beq	5$			; /41/ No
	call	sho$ve			; print version and edit number
	print	#warn$			; /49/ Warning messages
5$:	call	drpprv			; drop temp privs (for RSTS)
	clr	cccnt			; clear control C count
	mov	#stack	,sp		; initialize a large stack
	clr	exstac			; /41/ Clear exit status now
	clr	exstal			; /41/ Clear exit status now
	call	kerini			; try to open SY:KERMIT.INI
	call	binini			;

10$:	CALLS	setcc	,<#cctrap>	; command loop reading
	call	drpprv			; insure no privs are up now
	mov	argbuf	,argpnt		; insure arg pointer is reset
	call	fixchk			; restore setted crc type
	clr	cccnt			; no control C's
	call	getcmd			; read and parse the command
	tst	r0			; but did it work out ?
	blt	70$			; no
	jsr	pc	,@cmdadr	; dispatch to the command
	cmpb	jobtype	,#JOB$BAT	; /45/ Batch job today ?
	bne	11$			; /45/ No
	tst	status			; /45/ Status OK so far ?
	bne	14$			; /45/ Batch and bad status, DIE
11$:	tst	exireq			; /41/ Server force an exit ?
	bne	15$			; /41/ Yes, do it then
	tst	logreq			; /41/ Logout from CONNECT?
	beq	90$			; /41/ No
14$:	call	c$hang			; /41/ Yes, Send logout string and
					; /41/ Hang the line up
15$:	jmp	c$exit			; /41/ Exit normally now


					; Parse errors or EOF comes here
70$:	cmp	r0	,#cmd$ex	; control Z typed
	bne	80$			; no
	jmp	c$exit			; yes, exit normally

80$:	mov	#-IE.ITS,exstac		; /41/ Assume inconsistent exit
	cmp	r0	,#cmd$ba	; invalid command ?
	bne	85$			; no
	print	#200$			; yes, print out an error message
	br	90$			; and go back for more

85$:	cmp	r0	,#cmd$un	; /39/ not unique?
	bne	90$			; /39/ no
	print	#210$			; /39/ yes

90$:	tst	exstac			; /41/ Take exit with STATUS now ?
	beq	100$			; /41/ No
	tst	cmdlun			; /41/ Indirect command file running?
	beq	100$			; /41/ No, ignore the error
	CALLS	close	,<#LUN.TA>	; /41/ Yes, abort the command file
	clr	cmdlun			; /41/ No more indirect file active
	tst	mcrind			; /41/ Were we running KER @Filename?
	beq	100$			; /41/ No, drop to interactive mode
	jmp	c$exit			; /41/ Yes, exit with STATUS please
100$:	clr	exstac			; /41/ Clear exit status
	br	10$			; back to the command loop


	.save
	.psect	$PDATA	,D
200$:	.asciz	/Unrecognized command/<cr><lf>
210$:	.asciz	/%Command not unique./<cr><lf>
	.even
	.restore
	.dsabl	lsb

	global	<argbuf,argpnt,binini,drpprv,fixchk,stack>
	global	<mcrind,exstac,exstal,cmdlun,exireq,logreq> ; /41/
	global	<jobtyp,status>				    ; /45/



	.sbttl	commands
	.enabl	lsb

c$rec::	$name	<REC>
	call	opentt			; initialize the link line
	mov	pauset	,oldpau		; save old pause settings
	call	throtl			; perhaps thottle the line speed
	tst	outopn			; is an output file already open?
	beq	10$			; no
	CALLS	close	,<#lun.ou>	; yes, close it up please
10$:	CALLS	recsw	,<#'R>		; get the file
	tst	r0			; did it work
	bne	20$			; no
	CALLS	printm	,<#1,#200$>	; yes, say so if we are local
	br	100$			; bye
20$:	CALLS	printm	,<#1,#210$>	; it failed, say so iff local
	inc	status			; /45/ Flag for BATCH exit
100$:	call	clostt			; release the terminal
	mov	oldpau	,pauset		; restore old pause setting
	message
	return

	.enabl	lc
	.save
	.psect	$PDATA	,D
200$:	.asciz	/Complete/<cr><lf>
210$:	.asciz	/Receive failed/<cr><lf>
	.even
	.restore
	.dsabl	lsb


	global	<oldpau	,pauset	,throtl>



	.sbttl	send a file to pc
	.enabl	lsb
	.enabl	lc


c$send::$name	<SEN>
	clr	index			; initialize for directory i/o
	tst	inopn			; is an input file currently open
	beq	5$			; no
	CALLS	close	,<#lun.in>	; yes, pelase close old file up
5$:	call	opentt			; open and initialize the terminal
	mov	argbuf	,r1		; address of command line buffer
	tstb	@r1
	bne	10$			; yes
	message	<?Syntax   SEND Filename.type>,cr
	br	100$
10$:	tst	sermode			; are we a server now ?
	bne	15$			; yes, don't delay sending it.
	tst	remote
	beq	15$
	CALLS	suspend	,<sendly>	; give them a moment to type REC

15$:	mov	#srcnam	,r2		; /36/ destination address
	clrb	asname			; /36/ no SEND f1 [AS] f2
20$:	tstb	@r1			; /36/ and of the line today ?
	beq	40$			; /36/ yes, exit this loop
	cmpb	@r1	,#40		; /36/ if a space they may have typed
	beq	30$			; /36/ SEND file [as] file
	movb	(r1)+	,(r2)+		; /36/ ok so far, copy the name over
	br	20$			; /36/ next please
30$:	inc	r1			; /36/ found a <SPACE> in the cmd line
	cmpb	@r1	,#40		; /36/ assume not trailing control char
	blos	40$			; /36/ no
	clrb	@r2			; /36/ insure source name(s) asciz
	CALLS	iswild	,<#srcnam>	; /36/ check for wildcarding on the name
	tst	r0			; /36/ if NE, then wildcarded
	bne	40$			; /36/ can't rename outgoing if wildcard
	strcpy	#asname	,r1		; /36/ not wildcard, copy it
40$:	clrb	@r2			; /36/ insure source name .asciz
	CALLS	tlog	,<#srcnam>	; /46/ Expand logical if need be
	call	getnxt			; get the first filename please
	tst	r0			; did it work ?
	bne	100$			; no. Getnxt will send the error pak
	CALLS	sendsw	,<#'S>		; now send the file
	tst	r0			; did it work ?
	bne	90$			; no
	CALLS	printm	,<#1,#200$>	; yes
	br	100$			; bye
90$:	CALLS	printm	,<#1,#210$>	; no
	inc	status			; /45/ Flag for BATCH status
100$:	call	clostt			; exit
	message
	clrb	asname			; /36/ insure no more alternate names
	return
	

	global	<cmdbuf	,filsiz	,index	,inopn	,sermod	,srcnam	,sendly>
	
	.save
	.psect	$PDATA	,D
200$:	.asciz	<7><7>/Send complete/<cr><lf>
210$:	.asciz	<CR><LF><7><7>/Send failed/<cr><lf>
	.even
	.restore
	.dsabl	lsb





	.sbttl	open and close a link
	.enabl	lsb



opentt::tst	linksts			; already open ?
	bne	100$			; yes, ignore it then
	tst	remote			; if remote
	beq	10$			;  then ttname := ourname
	tst	inserv			; but not if we are a server
	beq	5$			; and the line number has been
	tstb	ttname			; set already
	bne	10$			;
5$:	CALLS	gttnam	,<#ttname>	; get the terminal name here
10$:	CALLS	ttyini	,<#ttname,#lun.ti,#ter$pa>
	tst	r0
	bne	100$
	CALLS	ttysav	,<#ttname>	; save terminal settings
	CALLS	ttyset	,<#ttname>	; set some things now
	mov	sp	,linksts	; flag it as being open
100$:	return

	.dsabl	lsb

clostt::save	<r0>
	CALLS	ttyfin	,<#ttname,#lun.ti>
	CALLS	ttyrst	,<#ttname>
	clr	linksts
	unsave	<r0>
	return
	
	global	<linksts,remote	,rwdata	,rwsize	,ttname>
	global	<gttnam	,ttyini	,ttyrst	,ttysav	,ttyset>
	global	<chksiz	,chktyp	,defchk	,mx$try	,maxtry>
	global	<inserv>




	.sbttl	exit kermit-11

c$exit::call	sd$off
10$:	tst	outopn
	beq	20$
	CALLS	close	,<#lun.ou>
20$:
	jmp	exit

	global	<exit>



c$nop::	return				; a NO-OP command ???







	.sbttl	bye, finish and get



rmtbye::
c$bye::	$name	<BYE>
	call	ckremote		; must not be remote for this
	bcs	100$			; we are remote, abort this
	call	rembye			; tell a server to logout
100$:	return				; back to command loop


rmtfin::
c$fin::	$name	<FIN>
	call	ckremote		; must not be remote for this
	bcs	100$			; we are remote, abort this
	call	remfin			; tell a server to exit
100$:	return				; back to command loop


	.enabl	lsb

rmtget::
c$get::	$name	<GET>
	call	ckremote		; must not be remote for this
	bcs	100$			; we are remote, abort this
	clrb	asname			; /36/ assume no names
	call	nextarg			; /36/ if two files present use last one
	tstb	@r1			; /36/ for new name (first file only)
	beq	10$			; /36/ nothing present
	strcpy	#asname	,r1		; /36/ something there, copy it please
	clrb	-(r1)			; /36/ get rid of last arg now
10$:	CALLS	tlog	,<argbuf>	; /46/ Do any needed logical xlates
	CALLS	remget	,<argbuf>	; tell a server to get a file
	tst	r0			; success ?
	beq	100$			; yes
	CALLS	printm	,<#1,#gmsg>	; no
	inc	status			; /45/ Failed
	br	110$
100$:	BEEP2
	message	<Kermit: Get complete>,CR
110$:	message
	clrb	asname			; /36/ always fix [as file] name to null
	return				; back to command loop

	.save
	.psect	$PDATA	,D
gmsg:	.asciz	/Get from server aborted/<cr><lf>
	.even
	.restore

	.dsabl	lsb


rmtspa::$name	<SPA>
	call	remspa			; issue a space ('U') generic command
100$:	return


rmthlp::$name	<HEL>
	call	remhlp			; issue a space ('U') generic command
100$:	return


rmthos::$name	<HOS>
	CALLS	remhos	,<argbuf>
	return


rmtdir::$name	<RDI>
	CALLS	remdir	,<argbuf>	; issue a dir ('D') generic command
	return


rmttyp::$name	<TYP>
	CALLS	remtyp	,<argbuf>	; issue a typ ('T') generic command
	return


rmtwho::$name	<WHO>
	CALLS	remwho	,<argbuf>	; issue a who ('W') generic command
	return


rmtdel::$name	<DEL>
	CALLS	remera	,<argbuf>	; issue a erase ('E') generic command
	return


rmtcwd::$name	<CWD>			; Change Working Directory
	mov	argbuf	,r1		; check for optional password
10$:	tstb	@r1			; find eos yet ?
	beq	30$			; yes exit
	cmpb	(r1)+	,#40		; look for a space
	bne	10$			; nothing
20$:	tstb	@r1			; null here ?
	beq	30$			; yes, no password present
	CALLS	remcwd	,<argbuf,r1>	; send password over also
	br	100$			; and exit
30$:	CALLS	remcwd	,<argbuf,#null>	; send the command to the server
100$:	return				; without any password trash


rmtlgi::$name	<LOG>			; Login
	mov	argbuf	,r1		; check for optional password
10$:	tstb	@r1			; find eos yet ?
	beq	30$			; yes exit
	cmpb	(r1)+	,#40		; look for a space
	bne	10$			; nothing
20$:	tstb	@r1			; null here ?
	beq	30$			; yes, no password present
	clrb	-1(r1)			; insert null over the <space>
	CALLS	remlgi	,<argbuf,r1>	; send password over also
	br	100$			; and exit
30$:	CALLS	remlgi	,<argbuf,#null>	; send the command to the server
100$:	return				; without any password trash


rmtren::$name	<REN>			; do a remote rename please
	call	gettwo			; insure both arguments are here
	tst	r0			; but did that work out ok ?
	bne	100$			; no, just exit then please
	CALLS	remren	,<cmdbuf,argbuf>; send a generic 'r' please
100$:	return				; bye


rmtcop::$name	<COP>			; do a remote Kopy please
	call	gettwo			; insure both arguments are here
	tst	r0			; but did that work out ok ?
	bne	100$			; no, just exit then please
	CALLS	remcop	,<cmdbuf,argbuf>; send a generic 'K' please
100$:	return				; bye



ckremo:	tst	remote			; are we local or remote
	bne	100$			; local, ok
	clc				; ok
	return				; bye
100$:	message	<KERMIT is not running as a LOCAL Kermit>,cr
	sec
	return

	global	<asname	,cmdbuf	,argbuf>
	global	<rembye	,remdir	,remera	,remfin	,remget	,remhlp>
	global	<remspa	,conesc	,remote	,ttdial	,ttname>
	global	<remcop	,remren>






	.sbttl	get the next command
	.enabl	lsb

;	R E A D C M D
;
;	input:	@r5	buffer address
;		2(r5)	prompt address
;	output:	r0	error
;		r1	byte count


readcmd:mov	r2	,-(sp)		; /41/
10$:	tst	cmdlun			; reading from indirect file
	beq	50$			; no, do a read on the terminal
	inc	exstal			; /41/ Increment command file line#
	CALLS	getrec	,<@r5,#lun.ta>	; yes, try to read a record
	tst	r0			; did it work ?
	bne	30$			; yes

	tst	tkecho			; should we echo the prompt and
	beq	100$			; the command string read ?
	tst	infomsg			; /41/ Echo this ?
	beq	100$			; /41/ No
	print	2(r5)			; yes, print the passed prompt
	tst	r1			; /56/ Anything there?
	beq	20$			; /56/ No
	print	@r5	,r1		; and also echo the command.
20$:	message				; /56/ crlf
	mov	@r5	,r2		; Check for comment
	cmpb	@r2	,#';		; Well?
	beq	10$			; Yes, ignore then
	cmpb	@r2	,#'!		; Well?
	beq	10$			; Yes, ignore then
	br	100$			; and exit with a success read

30$:	cmp	r0	,#ER$EOF	; hopefully, it's end of file
	beq	40$			; yes
	message	<Read error on TAKE file: >
	direrr	r0			; no, print the RMS error number
40$:	tst	sy.ini			; from kermit.ini ?
	bne	45$			; yes, don't print the message
	tst	infomsg			; /41/ Really print the message
	beq	45$			; /41/ no
	message	<TAKE file closed>,cr
45$:	CALLS	close	,<#lun.ta>	; close the file on any errors
	clr	mcrind			; /41/ No longer KER @Filename
	clr	sy.ini			; no longer a kermit.ini
	clr	cmdlun			; and read a command from TI:

50$:	tst	mcrcmd			; did we ever get a mcr command
	beq	60$			; no
	tst	exieof			; /45/ Do we really want EOF returned?
	beq	70$			; /45/ No, just do a terminal READ
	mov	#-1	,r0		; yes, fake end of file then
	br	100$			; bye
60$:	CALLS	getmcr	,<@r5>		; no mcr command yet, check for it
	mov	r0	,r1		; did we get any characters there?
	clr	r0			; say no errors
	mov	r1	,mcrcmd		; flag if we got a mcr command
	beq	70$			; /41/ Nothing was there
	mov	@r5	,r2		; /41/ Check if KER @Filename.type
	cmpb	@r2	,#'@		; /41/ Well
	bne	80$			; /41/ No
	mov	sp	,mcrind		; /41/ Yes, we will exit on error then
80$:	br	100$			; /41/ And take an exit bow
	
70$:	CALLS	kbredi	,<2(r5),@r5>	; read a record from the terminal
100$:	mov	(sp)+	,r2		; /41/
	return				; bye


	.save
	.psect	$PDATA	,D
tkecho::.word	-1			; if <> then echo the take file
	.restore

	global	<cmdlun	,argbuf	,cmdbuf	,er$eof	,lun.ta	,mcrcmd>
	global	<mcrind,infomsg>

	.dsabl	lsb




	.sbttl	the LOCAL command (basically, a NOP)


c$loc::	$name	<LOC>
	call	loacmd
	CALLS	getcm0	,<argbuf,r0>
	tst	r0
	bmi	110$
	mov	r0	,r3
	call	loacmd
	CALLS	getcm1	,<argbuf,r0,r3>
	tst	r0
	bmi	110$
	jsr	pc	,@r1
110$:	return


	global	<argbuf>




	.sbttl	the REMOTE command
	.enabl	lsb

c$rem::	$name	<REM>
	call	ckremo			; insure that we are remote
	bcs	120$			; no, exit then
	call	loarem			; get the command overlay in
	CALLS	getcm0	,<argbuf,r0>	; and try it please
	tst	r0			; did we find the remote command
	bmi	110$			; no
	mov	r0	,r3		; save the index (can't use r1)
	call	loarem			; get the overlay resident
	CALLS	getcm1	,<argbuf,r0,r3>	; get any required args for command
	tst	r0			; now could we get command arguements?
	bmi	120$			; no
	jsr	pc	,@r1		; dispatch on it now please
	return
110$:	message	<Unrecogized REMOTE command>,cr
120$:	return

	.dsabl	lsb

	global	<loarem>


c$cwd::	strcpy	#defdir	,argbuf		; CWD command, same as SET DEF command
	clr	r0			; no errors
	return				; exit




	global	<sdirini,sdodir>

c$home::clrb	defdir
	clr	r0
	return
c$test::
xxsdia::call	shodia
	return

	GLOBAL	<shodia>


	.sbttl	get command from the attached terminal

;	G E T C M D
;
;	input:	nothing
;	output:	r0	command index in dispatch table
;		r0	-1 (CMD$BAD) for invalid command
;			-2 (CMD$EX)  for exit
;	side effects:	cmdbuf written into

	cvtarg	=	4 + 10 + 20 + 40 + 200

	.name	=	0
	.minle	=	2
	.cmdad	=	4
	.cmdar	=	6
	.cmdat	=	10

	cmd$un	==	-4
	cmd$ab	==	-3
	cmd$ex	==	-2
	cmd$bad	==	-1

getcmd::clrb	@argbuf
10$:	clr	cmdnum
	mov	cmdbuf	,r4		; point to the command buffer
	CALLS	readcmd	,<r4,#prompt>	; get from current input stream
	tst	r0			; and exit if it failed for whatever
	bne	120$			; oops
	tst	cccnt			; time to exit on control C ?
	bne	120$			; yep
	CALLS	cvt$$	,<r4,r1,#cvtarg>; remove junk, convert to upcase
	tst	r0			; anything left ?
	beq	10$			; no, reprompt and try again
	add	cmdbuf	,r0		;
	clrb	@r0			; .asciz
	call	loacmd			; get the command list overlay
	CALLS	getcm0	,<r4,r0>	; search for the command
	mov	r1	,cmdadr		; store address of routine away
	mov	r0	,cmdnum		; store index of command away
	mov	r0	,r3		; did we actually find a command ?
	bmi	110$			; no
	call	loacmd
	CALLS	getcm1	,<r4,r0,r3>	; now get the rest of the commandline
	tst	r0			; or prompt for extra. Did it work
	bmi	110$			; no
100$:	mov	cmdnum	,r0
110$:	return

120$:	mov	#cmd$ex	,r0
	return


	global	<loacmd	,prompt>



	.sbttl	getcm1	check for additional input needed

;	G E T C M 1
;
;	input:	@r5	current command buffer
;		2(r5)	command table address
;		4(r5)	index of the current command
;
;	output:	r0	index of current command or < 0 for error
;		argbuf	any additional input or rest of the command line

	.enabl	lsb			; /55/

getcm1:	save	<r1,r2,r3>		; Save registers that we destroy
	sub	#100	,sp		; /55/ Allocate a small buffer for
	mov	sp	,r2		; /55/ saving the command prompt.
	tst	wasnul			; /45/ Was the command for ?
	beq	10$			; /45/ No
	clr	wasnul			; /45/ Not null anymore
	clr	r0			; /45/ Yes, return index 0
	br	110$			; /45/ Exit
10$:	mov	@r5	,r1		; Get command line address
	scan	#40	,r1		; Look for a space that might delimit
	tst	r0			; the command name from an argument
	beq	30$			; Nothing there
	add	r1	,r0		; Point to the string after the space
	COPYZ	r0,argbuf,#200		; Copy the command arg over please
	br	100$			; And exit

30$:	mov	4(r5)	,r3		; Get the command index
	mul	#$listl*2,r3		; If no arg given, see if one is needed
	add	2(r5)	,r3		; Add in base address of command table
	mov	.cmdar(r3),r3		; Get the argument prompt now
	tstb	@r3			; Anything there that is required ?
	beq	100$			; No, so take a normal exit then.
	STRCPY	r2	,r3		; /55/ Copy the prompt over now
40$:	CALLS	kbredi	,<r2,argbuf>	; /55/ Read a command from the keyboard
	tst	r0			; And exit if it failed for whatever
	bne	90$			; The read failed (control Z typed).
	tst	cccnt			; No, but is there a Control C?
	bne	90$			; Yes, treat as end of file
	CALLS	cvt$$,<argbuf,r1,#cvtarg>;Remove junk, convert to upcase
	tst	r0			; Is there anything left ?
	beq	40$			; No, reprompt and try again
	mov	r0	,r1		; Something is left, point to the
	add	argbuf	,r1		; end of the line and null terminate
	clrb	@r1			; ...
	br	100$			; Take normal exit


90$:	MESSAGE				; /55/ Insure a carriage return
	mov	#cmd$ab	,r0		; Control Z on keyboard read.
	br	110$			; And exit
100$:	mov	4(r5)	,r0		; Return command index
110$:	add	#100	,sp		; /55/ Pop the temporary buffer
	unsave	<r3,r2,r1>		; Restore registers we used
	return				; And exit

	.dsabl	lsb			; /55/

	global	<argbuf	,cmdadr	,cmdbuf	,cmdnum>




	.sbttl	getcm0	find the command in the table


;	input:	@r5	command buffer
;		2(r5)	first command descriptor block
;	output:	r0	command index
;		r1	dispatch address
;
;	errors:	r0	-1 (CMD$BAD)	unrecognized command
;		r0	-4 (CMD$UN)	not unique
;
;	descriptor block:
;
;		.word	commandname text
;		.word	minimum length
;		.word	address of command itself
;		.word	required argument prompt or a null for nothing
;		.word	type of argument

	.enabl	lsb			; /45/

getcm0::save	<r2,r3,r4>
	clr	wasnul			; /45/ Not NULL (ie, ?) anymore
	clr	-(sp)			; /39/ temp
	mov	@r5	,r1		; the passed command buffer
	strlen	r1			; get the command length
	mov	r0	,r3		; error if nothing is there
	beq	110$			; oops

	cmpb	@r1	,#'?		; /45/ Help desired today ?
	bne	9$			; /45/ No
	mov	2(r5)	,r4		; /45/ Yes, get start of list
	message				; /45/ A crlf
5$:	mov	.name(r4),r1		; /45/ Anything to dump?
	beq	8$			; /45/ No, exit
	print	r1			; /45/ The command text allowed
	print	#300$			; /45/ Move over
	mov	.cmdar(r4),r1		; /45/ Get address of prompt
	tstb	@r1			; /45/ Prompting text?
	beq	7$			; /45/ No
	print	.cmdar(r4)		; /45/ The prompt text next
7$:	message				; /45/ A crlf
	add	#$listl*2,r4		; /45/ Jump to the next entry
	br	5$			; /45/ Yes, dump it
8$:	mov	#nulcmd	,r1		; /45/ No, return NULCMD
	mov	sp	,wasnul		; /45/ Flag as having been NULL
	clr	r0			; /45/ No errors from GETCM0
	br	200$			; /45/ Exit please

9$:	clr	r2			; length := 0
10$:	scan	(r1)+	,#cmdch		; is this character ok in name?
	tst	r0			; find it in the list ?
	beq	20$			; no, we have found enough
	inc	r2			; command name len and pointer
	sob	r3	,10$		; next

20$:	tst	r2			; anything useful in cmd line
	ble	110$			; No leading letters ????
	mov	2(r5)	,r4		; the list of edit commands
	clr	r3			; R3 will have the command #

30$:	tst	.name(r4)		; anything left in the command list
	beq	110$			; no
	strlen	.name(r4)		; get the length of the command name
	CALLS	instr, <.name(r4),r0,@r5,r2> ; the next command?
	cmp	r0	,#1		; /39/ find anything ?
	bne	35$			; /39/ no
	mov	r0	,@sp		; /39/ save it
35$:	cmpb	r2	,.minle(r4)	; check if command length is ok
	blo	40$			; no, not enough for the command
	 dec	r0			; if match = position 1 we have it
	 beq	100$			;  then 'found the command'
40$:	inc	r3			; commandnum := commandnum + 1
	add	#$listl*2,r4		; cmdsaddr   := succ( cmdsaddr)
	br	30$


100$:	mov	r3	,r0		; return command index and exit
	mov	.cmdad(r4),r1		; return the command address also
	br	200$

110$:	mov	#cmd$ba	,r0		; bad command
	dec	@sp			; /39/ command not unique?
	bne	120$			; /39/ no
	mov	#cmd$un	,r0		; /39/ yes, say so
120$:	br	200$

200$:	tst	(sp)+			; /39/ pop it
	unsave	<r4,r3,r2>
	return

	.save
	.psect	$PDATA	,D
300$:	.asciz	/   /
	.even
cmdch:	.asciz	/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-@_./
	.even
	.restore

	.dsabl	lsb


	.sbttl	cctrap	the control C trap
	.enabl	lsb

cctrap::cmp	cccnt	,#cc$max
	bhi	100$
	CALLS	setcc	,<#cctrap>
	inc	cccnt
	return

100$:	tst	inserv
	beq	110$
	call	rstsrv
110$:	tst	infomsg					; /43/
	beq	120$					; /43/
	message	<Exiting due to control C interupt>,cr	; /43/
120$:	jmp	c$exit

	global	<cccnt	,exit	,inserv	,rstsrv	,infomsg>


	.dsabl	lsb



;	D I R E R $
;
;	called from DIRERR value    macro

	.enabl	lsb


direr$::mov	r0	,-(sp)		; direrr will select whether or not
	mov	4(sp)	,r0		; to call rms error or FIP (or DIR)
	beq	10$			; error based on whether the error
	CALLS	syserr	,<r0,#errtxt>	; code is < 0 (implies RMS) or > 0
	print	#errtxt			; which  implies either FIP  (RSTS)
	message				; or a DIRECTIVE error (RSX).  Thus
10$:	mov	(sp)+	,r0		; for RSX all error codes should be
	mov	@sp	,2(sp)		; made > 0 for non RMS errors.
	tst	(sp)+			; error 0 is a no-op.
	return

	.dsabl	lsb





	
nextar::mov	argbuf	,r1
10$:	tstb	@r1
	beq	100$
	cmpb	(r1)+	,#40
	bne	10$
100$:	return


nulcmd::clr	r0			; /45/ No errors
	return				; /45/ Exit


	.end	kermit
