Google
 

Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 7,3/sed/sedeco.mac
There are 9 other files named sedeco.mac in the archive. Click here to see a list.
TITLE	SEDECO - ECHO PROGRAM TO HELP SED IMPLEMENTORS
SUBTTL	A CHRISTOPHER HALL FECIT

;THIS PROGRAM IS USED TO FIND OUT WHAT CHARACTERS ARE SENT FROM A
;TERMINAL WHEN KEYS ARE PRESSED.

;IF CONV==0 CHARACTERS ARE ECHOED BACK TO THE TERMINAL EXACTLY AS THEY
;           COME (CONTROL-A BEGETS CONTROL-A, NOT "^A")
;IF CONV==1 THE CODES FOR THE CHARACTERS ARE ECHOED
;           (CONTROL-A BEGETS "CONTROL-A (001)"

TOPS10==0
CONV==	1

;TWO SPECIAL CASES: CONTROL-C CAUSES EXIT FROM PROGRAM
;		    CONTROL-M OUTPUTS A <CRLF> IN ADDITION TO EVERYTHING ELSE

	SEARCH	UUOSYM
IFE TOPS10,<
	SEARCH	MONSYM
>

T1=1
T2=2
T3=3
T4=4

IFN TOPS10,<
START:	RESET
	SETO	T1,
	TRMNO.	T1,
	  HALT
	MOVEM	T1,BRKADR+1
	MOVEM	T1,TSTIN+1
	MOVEM	T1,IN+1

	OPEN	1,INADR
	  HALT
	OPEN	2,OUTADR
	  HALT
	MOVE	T3,[XWD	3,BRKADR]
	TRMOP.	T3,		;SET UP PIM BREAK SET (ALL CHARS)
	  HALT

IO:	MOVE	T1,[XWD	2,IN]	;YES - READ A CHARACTER
	TRMOP.	T1,
	  HALT

	ANDI	T1,177		;KEEP ONLY 7 BITS
	CAIN	T1,3		;GOT A CONTROL-C?
	JRST	CTLC		;YES - DONE
	MOVE	T2,T1		;ELSE GET CHARACTER
	MOVE	T3,T1		;HERE, TOO
IFN CONV,<
	CAIL	T1,40		;SPECIAL CHARACTER?
	JRST	SKIP		;NO - SKIP THIS
	OUTSTR	[ASCIZ / CTRL-/]
	ADDI	T2,100
SKIP:
>
	OUTCHR	T2		;ELSE OUTPUT THE CHARACTER
IFN CONV,<
	OUTCHR	["("]
	ROT	T1,-6		;GET HIGH DIGIT
	ADDI	T1,"0"		;CONVERT TO ASCII
	OUTCHR	T1
	ROT	T1,3		;GET LOW DIGIT
	TRZ	T1,777770	;KEEP ONLY THE RIGHT BITS
	ADDI	T1,"0"		;CONVERT TO ASCII
	OUTCHR	T1
	ROT	T1,3		;GET LOW DIGIT
	TRZ	T1,777770	;KEEP ONLY THE RIGHT BITS
	ADDI	T1,"0"		;CONVERT TO ASCII
	OUTCHR	T1
	OUTCHR	[")"]		;OUTPUT IT
SKIP1:
>
	CAIE	T3,15		;GET A <CR>?
	JRST	IO		;NO - LOOP
	OUTCHR	T3		;YES - GIVE WITH A <CRLF>
	OUTCHR	[12]
	JRST	IO		;THEN LOOP

CTLC:	RELEAS	1,
	RELEAS	2,
	EXIT	1,
	JRST	IO

;TOPS10 DATA

INADR:	XWD	.IOPIM
	SIXBIT	/TTY/
	0,,INHDR
INHDR:	BLOCK	3

OUTADR:	XWD	.IOPIM
	SIXBIT/TTY/
	OUHDR,,0
OUHDR:	BLOCK	3

BRKADR:	2037
	0
	0
TSTIN:	1
	0
IN:	20
	0
>
IFE TOPS10,<
START:	MOVEI	T1,-1		;MAKE 	LKJHKJ     GIVE THEIR CODE
	MOVE	T2,[525252,,525252]
	MOVE	T3,T2
	SFCOC

	MOVEI	T1,.PRIIN	;READ MODE WORD
	RFMOD
	MOVEM	T2,FMDSAV	;SAVE IT FOR EXIT
	TDZ	T2,[37777,,4022] ;ZERO PAGE LENGTH, WIDTH; MAKE NOTHING ECHO
	TDO	T2,[200000,,300] ;TURN ON FORMF, NO-TRANS-OUTP BITS
	SFMOD
	STPAR

	MOVEI	T1,-5		;DISABLE INTERRUPTS ON ALL CHARACTERS
	SETZ	T2,		;  SO MONITOR WON'T TRAP ANYTHING
	STIW

IO:	PBIN			;READ A CHARACTER

	CAIN	T1,T3		;GOT A CONTROL-C?
	JRST	CTLC		;YES - DONE
	MOVE	T2,T1		;ELSE GET CHARACTER
	MOVE	T3,T1		;HERE, TOO
IFN CONV,<
	CAIL	T1,40		;SPECIAL CHARACTER?
	JRST	SKIP		;NO - SKIP THIS
	MOVEI	T1,[ASCIZ / CTRL-/]
	PSOUT
	MOVEI	T1,100(T2)
SKIP:
>
	PBOUT			;ELSE OUTPUT THE CHARACTER IN T1
IFN CONV,<
	MOVEI	T1,"("
	PBOUT
	MOVE	T1,T2
	ROT	T1,-6		;GET HIGH DIGIT
	ADDI	T1,"0"		;CONVERT TO ASCII
	PBOUT
	ROT	T1,3		;GET LOW DIGIT
	TRZ	T1,777770	;KEEP ONLY THE RIGHT BITS
	ADDI	T1,"0"		;CONVERT TO ASCII
	PBOUT
	ROT	T1,3		;GET LOW DIGIT
	TRZ	T1,777770	;KEEP ONLY THE RIGHT BITS
	ADDI	T1,"0"		;CONVERT TO ASCII
	PBOUT
	MOVEI	T1,")"		;OUTPUT IT
	PBOUT
SKIP1:
>
	CAIE	T3,15		;GET A <CR>?
	JRST	IO		;NO - LOOP
	MOVE	T1,T3		;YES - GIVE WITH A <CRLF>
	PBOUT
	MOVEI	T1,12
	PBOUT
	JRST	IO		;THEN LOOP

CTLC:	MOVEI	T1,.PRIIN
	MOVE	T2,FMDSAV	;GET BACK THE ORIGINAL FMOD WORD
	SFMOD
	STPAR
	HALTF
	JRST	IO

;TOPS20 DATA

FMDSAV:	BLOCK	1		;SAVED RFMOD WORD
>
	END	START