Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-08 - decus/20-0177/micom.mac
There are no other files named micom.mac in the archive.
;Edit number 7 by SST.D-BIGELOW on 19-Mar-84
;	Make program be wheel-only.
;
;Edit number 6 by SST.D-BIGELOW on  8-Mar-84
;	Add new command to select Micom port, and don't ask with each manual
;	load.
;
;Edit number 5 by SST.D-BIGELOW on  6-Mar-84
;	Change delay time to four seconds and take explicit terminal number
;	out of help message.
;
;<SST.D-BIGELOW>MICOM.MAC.53, 20-Jan-84 11:08, Edit by SST.D-BIGELOW
; 4	Change delay time to six seconds and correct error in timer routine.
;
;<SST.D-BIGELOW>MICOM.MAC.51, 19-Jan-84 11:34:01, Edit by SST.D-BIGELOW
; 3	Change response I/O to use SIN% with timer interrupt catching the
;	last response.	Also set interrupt system and temporary high priority.
;
;<SST.D-BIGELOW>MICOM.MAC.43, 18-Jan-84 16:18:28, Edit by SST.D-BIGELOW
; 2	First working version of program.
;
Subttl	Program Initialization


Search	Symbol				; Universal file for symbols
Sall					; Supress macro expansion


;Version information
	Vmajor==1			; Major version
	Vminor==0			; Minor version
	Vedit==7			; Edit number
	Vcust==4			; WCC edit code


;==========================================================================

.TTL.	Micom, Program to control the MICOM port contender

;==========================================================================


;Program feature test switches

	Use	Comman			;Comnd jsys routines
	Omit	Memory			;no need for memory management
	Omit	Sorter			;or sorting either
	Omit	String			;no string package

	Include F..UUO			; Local uuo features
					; If included, requires UUOCON.REL



;*			===   Abstract	 ===
;*
;*
;* Written by SST.D-BIGELOW on 17-Jan-84
;*
;* Files required: SYMBOL.UNV, MACSYM.UNV, MONSYM.UNV, MACREL.REL, UUOCON.REL
;*
;* Description: This program downloads the Micom port selector from a file on
;*	the DEC-20.  The program may be used interactively or through input
;*	and output files.
;*
;Symbols and storage


Switch	F.Term				;input from terminal
Switch	F.Timo				;timeout encountered

Delay==^D4000				;6.0 second pause
Strlen==300				;length of strings

Ifile:	block	1			;input file
Ofile:	block	1			;output file
Mdev:	block	1			;micom device
Intmsk: block	1			;interrupt mask word
Intblk: block	3			;interrupt levels
Stak..: block	stksiz			;standard stack
Txtlin: block	strlen/5+1		;input line storage


;Strings

Infile: asciz	/SYSTEM:MICOM.COMMANDS/
Outfil: asciz	/SYSTEM:MICOM.RESPONSE/
Micdev:	asciz	/TTY100:/		;default terminal

Pmttxt: asciz	.Micom cmd--.		;input from tty

;Comnd parsing blocks

Keyfld: flddb.	.cmkey,,keytab,<Command,>

Keytab: xwd	keylen,keylen
	cmdt	Auto-load,,.auto	;automatically load w/o dialog
	cmdt	Exit			;exit command
	cmdt	Help			;program help
	cmdt	Manual-load,,.man	;manually load
	cmdt	Port			;command to set micom port
	keylen==.-keytab-1


;Priority interrupt storage

Chntab: xwd	1,ctrlc 		;channel 1 for control-C
	xwd	2,timint		;channel 2 for timer interrupts

Levtab: exp	intblk,intblk+1,intblk+2
Subttl Start of main program


Micom:	reset%
	cmdstk				;initialize cmd stack
	setzb	f,p1			;initialize flags and line counter
	setzm	mdev			;no micom device yet
	print	asc<Micom %V%C> 	;type version
	movei	a,.fhslf		;set this fork's capabilities
	rpcap%				;read them first
	txnn	c,sc%whl	 	;must be able to set wheel
	 noerr	(<? Insufficient capabilities to run program>,EXIT)
	call	inipi			;set interrupts
	call	setpri			;set job priority


;Prepare for commands

Noprom: prompt	asc<Micom-->		;use stored micom prompt above

Getkey: rfield	keyfld			;get a keyword
	hrrz	a,(b)			;get the dispatch address
	call	(a)			;and go to it
	jrst	noprom			;and loop
Subttl Help command and Exit command

.Help:	noise	asc<with program commands>
	confrm				;confirm the command
	print	asc<%CMicom %V%C>	;version typout
	hrroi	a,hlpmes		;get help message
	psout%
	ret				;done


.Exit:	noise	asc<from program>
	confrm				;confirm the command
Exit2:	call	clrpri			;clear priority
	call	dispi			;disable pi system
	haltf%				;done
	 jrst	micom			;if continued


;Help message storage

Hlpmes: asciz	\
Micom loading commands:

	Auto	Load Micom from file SYSTEM:MICOM.COMMANDS, sending responses
		to file SYSTEM:MICOM.RESPONSES, using standard line for
		Micom command port.  Exit when finished.

	Manual	As above, but command file and response file are specified in
		the command line.  For interactive Micom configuration, use:
		     Micom-- MANUAL TTY: TTY: <cr>

	Exit	Terminate program.

	Help	Type this message.

	Port	Select TTY port to be used for Micom commands.

\
Subttl	Port selection

.Port:	noise	asc<to use for Micom commands is>
	cfield	[flddb. .cmfil,cm%sdh,,<TTY device>]
	movem	b,mdev			;store it
	move	a,b			;copy it
	dvchr%				;get characteristics
	ldb	a,[point 9,b,17]	;get proper bits
	cain	a,.dvtty		;tty?
	 ret				;yes, return for next command
	print	asc<%QPort specifier must be of the form TTYn:%C>
	move	a,mdev			;get device
	rljfn%				;release the jfn
	 erjmp	.+1			;ignore errors
	setzm	mdev			;clear port word
	ret				;done
Subttl Auto mode handling

.Auto:	noise	asc<using standard control files>
	confrm				;confirm command
	movx	a,gj%sht!gj%old 	;input
	hrroi	b,infile		;existing filename
	gtjfn%				;get jfn
	 dblerr (<Can't open input file>,JUMP,exit2)
	movem	a,ifile 		;store it
	movx	a,gj%sht!gj%fou 	;output
	hrroi	b,outfil		;new filename
	gtjfn%				;get jfn
	 dblerr (<Can't open output file>,JUMP,exit2)
	movem	a,ofile 		;store jfn

;Now rejoin manual code
	jrst	loadit
Subttl Manual mode questions

;Ask a series of questions about where to read from and write to.


.Man:	noise	asc<from input file>
	rfield	[flddb. .cmifi,cm%sdh,,<File containing Micom commands>]
	movem	b,ifile 		;store jfn
	noise	asc<writing responses to>
	cfield	[flddb. .cmofi,cm%sdh,,<File to contain Micom responses>]
	movem	b,ofile 		;store jfn
	move	a,ifile 		;get input jfn
	dvchr%				;get characteristics
	ldb	a,[point 9,b,17]	;pick up device code
	cain	a,.dvtty		;tty?
	 flgon	f.term			;yes, flag for later


;Now we can proceed.  No user intervention from this point unless TTY:
; was specified as the input device.

Loadit: ifoff.	f.term			;input from terminal?
	  move	  a,ifile		;input file
	  movx	  b,fld(7,of%bsz)!of%rd
	  openf%			;open the file
	   dblerr (<Can't open input file>,JUMP,exit2)
	endif.
	move	a,ofile 		;output file
	movx	b,fld(7,of%bsz)!of%wr
	openf%				;open the file
	 dblerr (<Can't open output file>,JUMP,exit2)
	skipe	a,mdev			;device set for micom?
	ifskp.				;no, get one
	  movx	a,gj%sht!gj%old		;flags
	  hrroi	b,micdev		;standard device
	  gtjfn%			;get a jfn
	   dblerr (<Can't obtain Micom port JFN>,JUMP,exit2)
	  movem	a,mdev			;store jfn
	endif.
	movx	b,fld(.gsimg,of%mod)!fld(7,of%bsz)!of%rd!of%wr
	openf%				;open the device
	 dblerr	(<Unable to open Micom command port>,JUMP,exit2)
	skpon	f.term			;terminal mode?
	 jrst	getfil			;nope
	type	<Please type ^Z when finished entering commands>
Subttl Read input file lines

Micsnd: skpon	f.term			;terminal input?
	 jrst	getfil			;no, get from file
Gettrm: type				;blank line first
	hrroi	a,pmttxt		;prompt
	move	c,a			;copy for rescan buffer
	psout%				;type it
	hrroi	a,txtlin		;point to text input buffer
	movx	b,rd%brk!rd%bel!strlen	;end on ^Z or return
	rdtty%				;read from terminal
	 dblerr (<Please retry>,JUMP,gettrm)
	txne	b,rd%btm		;break char ended it?
	 jrst	gtt.a			;yes, next check which one
	movei	a,.cttrm		;clear input buffer
	cfibf%
	type	<% Line too long, please retry...>
	jrst	gettrm			;try again

;Check for a ^Z
Gtt.a:	ldb	b,a			;get terminating character
	cain	b,"Z"-100		;control-Z?
	 jrst	eof			;yes, done
	jrst	sndlin			;no, send the line to the micom
;Here to read from a file


Getfil: aoj	p1,			;count lines
	move	a,ifile 		;get jfn
	hrroi	b,txtlin		;point to buffer
	movei	c,strlen		;number of characters to read
	movei	d,12			;ending on a lf
	sin%				;read a line
	 erjmp	eofchk			;check for eof
	jumpn	c,sndlin		;non-zero if properly terminated

;Here if we read until string ran out without a lf
	print	p1,asc<%PInput line %N too long -- discarded%C>
	move	a,ifile 		;get jfn
	setz	b,			;output to nul:
	movei	c,-1			;large number
	movei	d,12			;read to lf
	sin%				;read rest of line and discard
	 erjmp	eof			;assume error means eof
	jrst	getfil			;try the next


;Check for eof here

Eofchk: move	a,ifile 		;get jfn
	gtsts%				;status
	txne	b,gs%eof		;end of file?
	ifskp.				;nope, error
	  print a,asc<%QError reading file %J -- %E%C>
	  jrst	eof			;done
	endif.
	caie	c,strlen		;did we input anything?
	 print	asc<%PMissing CRLF on last input line, not sent...%C>


;End of input file

Eof:	move	a,ifile 		;input files
	closf%				;close all files
	 erjmp	.+1			;ignore errors
	move	a,ofile 		;output file
	closf%				;close that one
	 dblerr (<Can't close response file>,AUTO)
	jrst	exit2			;quit
Subttl Sndlin - Send the text line to the Micom

;An optional between-character delay may be inserted at the end of this
;  routine if there develops a problem with force-feeding the Micom.

Sndlin: move	t1,[point 7,txtlin]	;pointer to text
	ildb	b,t1			;get first char
	caie	b,"!"			;comment line?
	 jrst	snd.a+1 		;no, send this line
	move	a,ofile 		;output file
	hrroi	b,txtlin		;point to text
	movei	c,strlen		;max length
	movei	d,12			;ending on a lf
	sout%				;send comment line to output file
	jrst	micsnd			;and get next input

Snd.a:	ildb	b,t1			;get a char
	cain	b,12			;line feed?
	 movei	b,15			;make it a cr
	move	a,mdev			;micom line
	bout%				;send it
	cain	b,15			;final cr?
	 jrst	getrsp			;yes, get response
	jrst	snd.a			;now do next
Subttl Getrsp - Get response from Micom


;Now get the response.	This algorithm allows the Micom to send as much as
;  it wishes, until enough time goes by without any data activity.  When a
;  SIN% is terminated by a timer interrupt, we are done.  Allow (delay)
;  seconds per input line, at least.

Getrsp: flgoff	f.timo			;no timeout yet
	move	a,[.fhslf,,.timel]	;elapsed timer
	movei	b,delay 		;delay time
	movei	c,1			;channel one
	timer%
	 dblerr (<Can't set timer interrupt>,JUMP,exit2)
	move	a,mdev			;micom device
	hrroi	b,txtlin		;where to put input
	movei	c,strlen		;max size
	movei	d,12			;until lf
	sin%				;read a line

;INTPC is a sacred location!  The timer interrupt trap looks for a PC set
;  to this location and sets monitor to user mode if there, causing us to
;  return from a SIN which never terminated.

INTPC:	 jfcl				;wait here

	move	a,[.fhslf,,.timal]	;remove all requests
	timer%				;done
	 erjmp	.+1			;ignore errors

	move	a,ofile 		;output jfn
	hrroi	b,txtlin		;text
	subi	c,strlen		;create negative number of chars read
	jumpe	c,micsnd		;done, next line
	sout%				;send the line
	skpoff	f.timo			;timed out?
	 jrst	micsnd			;yes, next line
	jrst	getrsp			;no, so get next input line
Subttl Interrupt processing routines

;Here to intercept a ^C

Ctrlc:	push	p,a			;save accumulators
	push	p,b
	push	p,c
	push	p,d
	call	clrpri			;clear our priority setting
	haltf%				;and exit

;If continued..

	call	setpri			;set priority again
	pop	p,d			;restore acs
	pop	p,d
	pop	p,b
	pop	p,a
	debrk%				;dismiss the interrupt


;Here for a timer interrupt

Timint: push	p,a			;save an ac
	hrrz	a,intblk+1		;get interrupt pc from location two
	caie	a,intpc 		;are we at interrupt pc?
	ifskp.				;yes
	  flgon f.timo			;timeout encountered
	  movx	a,1B5			;user mode bit
	  iorm	a,intblk+1		;set user mode to return
	endif.
	pop	p,a
	debrk%				;and dismiss
Subttl Job Priority Setting routiness

;Here to set high priority

Setpri: gjinf%				;get our job number
	move	a,c			;copy into a
	movei	b,jp%sys		;make us a temporary system job
	sjpri%				;set job priority
	 erjmp	.+1			;ignore errors
	ret


;Here to clear it

Clrpri: gjinf%				;get our job number
	move	a,c			;copy into a
	setz	b,			;clear assignments
	sjpri%				;set job priority
	 erjmp	.+1			;ignore errors
	ret
Subttl Priority Interrupt System routines

;Routine to initialize the pi system

Inipi:	movei	a,.fhslf		;init levtab and chntab
	move	b,[levtab,,chntab]
	sir%
	movei	a,.fhslf		;turn on desired channels
	movx	b,1B0!1B1		;channels 0 and 1
	aic%
	movei	a,.fhslf		;enable interrupt system
	eir%
	movei	a,.fhjob		;job code
	rtiw%
	movem	b,intmsk		;save mask
	movx	b,1B3			;control-C
	stiw%
	 erjmp	.+1			;ignore errors
	move	a,[3,,0]		;enable for control-c
	ati%				;to channel zero
	 erjmp	.+1			;ignore errors
	ret				;done


;Routine to disable the pi system

Dispi:	movei	a,.fhslf		;disable the pi system
	dir%
	movei	a,.fhjob		;this job
	move	b,intmsk		;interrupt mask
	stiw%				;reset terminal interrupt mask
	 erjmp .+1
	movei	a,.fhslf		;disable all channels
	movei	b,0
	aic%
	ret				;done


;End of program

	end	micom