CMDIO	MACRO M1110  22-AUG-78 01:56

TABLE OF CONTENTS



     3-   34	COMAND -- COMMAND INPUT

     3-   87	EOL -- WRITE LINE TO CONSOLE LOG

     3-  118	CHRESC

     3-  141	CHROUT

     3-  172	CHRIN

     3-  200	TRMIO

     3-  235	ATTACH,DETACH

     3-  254	NOCTLO

     3-  269	ENDLIN

     3-  295	OUTC

     3-  338	PAD

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3





      1						.TITLE	CMDIO

      2						.IDENT	/000032/

      3

      4					; COPYRIGHT (C) 1976, 1977,

      5					; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

      6					;

      7					; THIS SOFTWARE IS  FURNISHED  UNDER A LICENSE  FOR USE ONLY ON A

      8					; SINGLE  COMPUTER  SYSTEM  AND  MAY  BE  COPIED  ONLY  WITH  THE

      9					; INCLUSION OF THE ABOVE  COPYRIGHT NOTICE. THIS SOFTWARE, OR ANY

     10					; OTHER  COPIES  THEREOF,  MAY NOT BE PROVIDED  OR OTHERWISE MADE

     11					; AVAILABLE TO ANY OTHER PERSON EXCEPT FOR USE ON SUCH SYSTEM AND

     12					; TO  ONE  WHO  AGREES  TO  THESE  LICENSE  TERMS.  TITLE TO  AND

     13					; OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

     14					;

     15					; THE INFORMATION IN  THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT

     16					; NOTICE AND SHOULD NOT  BE CONSTRUED AS  A COMMITMENT BY DIGITAL

     17					; EQUIPMENT CORPORATION.

     18					;

     19					; DEC ASSUMES  NO  RESPONSIBILITY  FOR  THE  USE  OR  RELIABILITY

     20					; OF ITS  SOFTWARE  ON  EQUIPMENT  WHICH IS NOT  SUPPLIED BY DEC.

     21					;

     22					; WRITTEN BY

     23					;	D. KNIGHT

     24					;

     25					; MODULE FUNCTION

     26					;	COMMAND I/O MODULE

     27

     28	000000					.PSECT

     29

     30						.MCALL	DIR$,WTSE$S

     31						.NLIST	BEX

     32

     33

     34						.SBTTL	COMAND -- COMMAND INPUT

     35					;

     36					; FUNCTION

     37					;	READ A COMMAND

     38					;

     39					; INPUTS

     40					;	(SP) OF <>0 USE ALTERNATIVE (#) PROMPT CHARACTER

     41					;		(USED BY INSERT) AND SPECIAL EOF

     42					;

     43					; OUTPUTS

     44					;	CMLLEN - LENGTH OF THE COMMAND IN BYTES(-1 IF EOF ON INSERT)

     45					;	CMLADR - BUFFER CONTAINING COMMAND STRING IN ASCII

     46					;	VALUE - NONE

     47					;

     48	000000				COMAND::

     49	000000	010546 				MOV	R5,-(SP)

     50	000002	010446 				MOV	R4,-(SP)

     51	000004	010346 				MOV	R3,-(SP)

     52	000006	004767 	000440 			CALL	NOCTLO		;TURN OFF CTRL-O

     53	000012	005766 	000010 			TST	8.(SP)		;CHECK FOR ALTERNATE PROMPT

     54	000016	003014 				BGT	5$		;YES

     55	000020	001403 				BEQ	2$		;NORMAL PROMPT

     56	000022	012705 	000000G			MOV	#QUEST,R5	;PROMPT FOR QUERY

     57	000026	000402 				BR	3$

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-1

COMAND -- COMMAND INPUT



     58	000030	012705 	000000G		2$:	MOV	#STAR,R5	;NORMAL PROMPT

     59	000034	012704 	000000G		3$:	MOV	#ODPB,R4	;GET OUTPUT DPB ADDRESS

     60	000040	012703 	000000G			MOV	#STPSCL,R3	;AND LENGTH

     61	000044	004767 	000302 			CALL	TRMIO		;DO THE OUTPUT

     62	000050	012704 	000000G		5$:	MOV	#IDPB,R4	;INPUT DPB

     63	000054	016705 	000000G			MOV	CMLADR,R5	;BUFFER ADDRESS

     64	000060	016703 	000000G			MOV	LINSIZ,R3	;BUFFER LENGTH FOR INPUT

     65	000064	004767 	000262 			CALL	TRMIO		;GET THE LINE

     66	000070	016405 	000000G			MOV	Q.IOSB(R4),R5	;GET

     67	000074	016505 	000002 			MOV	2(R5),R5	;CHARACTER COUNT

     68	000100	010567 	000000G			MOV	R5,CMLLEN	;REMEMBER LENGTH

     69	000104	066705 	000000G			ADD	CMLADR,R5	;POINT TO END OF LINE

     70	000110	105015 				CLRB	(R5)		;TERMINATE LINE

     71					;LOOK FOR ABNORMAL LINE TERMINATOR

     72	000112	126727 	000000G	000000G		CMPB	IOSB,#IE.EOF	;LOOK FOR END OF FILE

     73	000120	001404 				BEQ	7$

     74	000122	026727 	000000G	000000G		CMP	IOSB,#IS.ESC	;ALT MODE OR ALTERNATE ESCAPE?

     75	000130	001003 				BNE	10$

     76	000132	012767 	177777 	000000G	7$:	MOV	#-1,CMLLEN	;MAKE IT LOOK LIKE EOF

     77	000140				10$:

     78						.IF NDF	RSTS

     79	000140	004767 	000314 			CALL	ENDLIN		;ADVANCE LINE

     80						.ENDC	;RSTS

     81	000144	012603 				MOV	(SP)+,R3

     82	000146	012604 				MOV	(SP)+,R4

     83	000150	012605 				MOV	(SP)+,R5

     84	000152	000207 				RETURN

     85

     86

     87						.SBTTL	EOL -- WRITE LINE TO CONSOLE LOG

     88					;

     89					; FUNCTION

     90					;	WRITE A LINE TO THE CONSOLE LOG

     91					;

     92					; INPUTS

     93					;	OUTPTR - POINTER TO NEXT FREE BYTE IN OUTBUF

     94					;	OUTBUF - POINTER TO PRINT LINE

     95					;

     96					; OUTPUTS

     97					;	OUTPTR - RESET

     98					;	VALUE - NONE

     99					;

    100	000154				EOL::

    101	000154	010546 				MOV	R5,-(SP)

    102	000156	010446 				MOV	R4,-(SP)

    103	000160	010346 				MOV	R3,-(SP)

    104	000162	012705 	000000G			MOV	#OUTBUF,R5	;GET BUFFER ADDRESS

    105	000166	016703 	000000G			MOV	OUTPTR,R3	;AND CURRENT POSITION

    106	000172	160503 				SUB	R5,R3		;CONVERT TO LENGTH

    107	000174	012704 	000000G			MOV	#ODPB,R4	;OUTPUT

    108	000200	004767 	000146 			CALL	TRMIO		;DO IT

    109	000204	004767 	000250 			CALL	ENDLIN		;TERMINATE THE LINE PROPERLY

    110	000210	012767 	000000G	000000G		MOV	#OUTBUF,OUTPTR	;RESET POINTER

    111	000216	005067 	000000G			CLR	CURPOS		;RESET POSITION IN LINE

    112	000222	012603 				MOV	(SP)+,R3

    113	000224	012604 				MOV	(SP)+,R4

    114	000226	012605 				MOV	(SP)+,R5

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-2

EOL -- WRITE LINE TO CONSOLE LOG



    115	000230	000207 				RETURN

    116

    117

    118						.SBTTL	CHRESC

    119					;

    120					; FUNCTION

    121					;	GENERATE AN ESCAPE SEQUENCE FOR THE DISPLAY

    122					;

    123					; INPUTS

    124					;	CHAR - SINGLE CHARACTER TO BE CONVERTED TO ESCAPE SEQ.

    125					;

    126					; OUTPUTS

    127					;	VALUE - NONE

    128					;

    129		000016 			CHAR=16

    130

    131	000232				CHRESC::

    132						.IF NDF	RSTS

    133	000232	012746 	000033 			MOV	#33,-(SP)	;PUT OUT ESCAPE

    134						.IFF

    135						MOV	#233,-(SP)	;RSTS STYLE ESCAPE

    136						.ENDC	;RSTS

    137	000236	004767 	000002 			CALL	CHROUT		;

    138	000242	005726 				TST	(SP)+		;AND FALL THROUGH TO CHROUT

    139

    140

    141						.SBTTL	CHROUT

    142					;

    143					; FUNCTION

    144					;	IMMEDIATELY OUTPUT CHARACTERS TO TERMINAL.

    145					;	DUMP LINE BUFFER FIRST IF ANYTHING IN IT.

    146					;

    147					; INPUTS

    148					;	CHAR - CHARACTER TO BE OUTPUT

    149					;		IF 0 THEN DUMP EXISTING BUFFER WITHOUT

    150					;		OUTPUTTING EXTRA CHARACTER.

    151					;

    152					; OUTPUTS

    153					;	VALUE - NONE

    154					;

    155	000244	004167 	000000G		CHROUT::JSR	R1,$SAV5

    156	000250	012704 	000000G			MOV	#ODPB,R4	;OUTPUT DPB

    157	000254	012705 	000000G			MOV	#OUTBUF,R5	;GET BUFFER ADDRESS

    158	000260	016703 	000000G			MOV	OUTPTR,R3	;AND CURRENT POSITION

    159	000264	160503 				SUB	R5,R3		;SEE IF ANYTHING REMAINS

    160	000266	001405 				BEQ	10$		;NO

    161	000270	004767 	000056 			CALL	TRMIO		;DUMP ANYTHING LEFT OVER

    162	000274	012767 	000000G	000000G		MOV	#OUTBUF,OUTPTR	;RESET POINTER

    163	000302	010605 			10$:	MOV	SP,R5		;POINT TO

    164	000304	062705 	000016 			ADD	#CHAR,R5	;CHARACTER TO BE OUTPUT

    165	000310	005715 				TST	(R5)		;ANYTHING THERE?

    166	000312	001403 				BEQ	20$		;NO, GO AWAY QUIETLY

    167	000314	012703 	000001 			MOV	#1,R3		;COUNT IS 1

    168	000320	000414 				BR	TRMIO		;AND OUTPUT IT

    169	000322	000207 			20$:	RETURN

    170

    171

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-3

CHRIN



    172						.SBTTL	CHRIN

    173					;

    174					; FUNCTION

    175					;	SINGLE CHARACTER INPUT FOR CHANGE COMMAND

    176					;

    177					; INPUTS

    178					;	NONE

    179					;

    180					; OUTPUTS

    181					;	VALUE - CHARACTER FOUND

    182					;

    183	000324				CHRIN::

    184	000324	004767 	000000G			CALL	GRCHAR		;GET A RSTS CHARACTER

    185						.IF DF	RSTS

    186						CMPB	R0,#15		;<CR>?

    187						BNE	5$		;NO

    188						CALL	GRCHAR		;YES, A <LF> IS SURE TO FOLLOW

    189						MOVB	#15,R0		; SO THROW IT AWAY AND RECOVER <CR>

    190					5$:

    191						.ENDC	;RSTS

    192	000330	120027 	000003 			CMPB	R0,#3		;^C WILL CAUSE ERROR TO AVOID LOOP

    193	000334	001401 				BEQ	10$

    194	000336	000207 				RETURN

    195	000340	012746 	000000G		10$:	MOV	#ERCTLC,-(SP)	;ANY ERROR WILL DO FOR NOW

    196	000344	004767 	000000G			JSR	PC,PRTERR

    197	000350	000000 				HALT

    198

    199

    200						.SBTTL	TRMIO

    201					;

    202					; FUNCTION

    203					;	DO THE REQUESTED QIO FUNCTION

    204					;

    205					; INPUTS

    206					;	R3 - BUFFER LENGTH

    207					;	R4 - QIO BLOCK ADDRESS

    208					;	R5 - BUFFER ADDRESS

    209					;

    210					; OUTPUTS

    211					;	VALUE - NONE

    212					;

    213	000352				TRMIO::

    214						.IF DF	VAX

    215	000352	010446 				MOV	R4,-(SP)	;SAVE DPB POINTER

    216	000354	005767 	000000G			TST	CHRIO		;CHARACTER MODE I/O?

    217	000360	001405 				BEQ	5$		;->NO

    218	000362	020427 	000000G			CMP	R4,#ODPB	;YES, "IO.WLB" REQUEST?

    219	000366	001002 				BNE	5$		;->NO

    220	000370	012704 	000000G			MOV	#OCDPB,R4	;YES, MAKE "IO.WAL" REQUEST

    221	000374				5$:

    222						.ENDC	;VAX

    223	000374	010564 	000000G			MOV	R5,Q.IOPL(R4)	;REMEMBER THE START

    224	000400	010364 	000002G			MOV	R3,Q.IOPL+2(R4)	;AND HOW LONG IT IS

    225	000404					DIR$	R4		;EXECUTE THE REQUEST

    226	000410	103402 				BCS	10$

    227	000412	004767 	000024 			CALL	WAIT

    228	000416				10$:

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-4

TRMIO



    229						.IF DF	VAX

    230	000416	012604 				MOV	(SP)+,R4	;RESTORE DPB POINTER

    231						.ENDC	;VAX

    232	000420	000207 				RETURN

    233

    234

    235						.SBTTL	ATTACH,DETACH

    236					;

    237					; FUNCTION

    238					;	ATTACH OR DETACH TERMINAL

    239					;

    240					; INPUTS

    241					;	NONE

    242					;

    243					; OUTPUTS

    244					;	VALUE - NONE

    245					;

    246	000422				ATTACH::DIR$	#QIOATT

    247	000430	000403 				BR	DET001

    248	000432				DETACH::DIR$	#QIODET		;DETACH THE TERMINAL

    249	000440	103403 			DET001:	BCS	WAITR

    250	000442				WAIT::	DIR$	#WAIT01		;WAIT FOR COMPLETION

    251	000450	000207 			WAITR:	RETURN

    252

    253

    254						.SBTTL	NOCTLO

    255					;

    256					; FUNCTION

    257					;	TURN OFF CONTROL-O

    258					;

    259					; INPUTS

    260					;	NONE

    261					;

    262					; OUTPUTS

    263					;	VALUE - NONE

    264					;

    265	000452	004767 	177754 		NOCTLO::CALL	DETACH		;DETACH TERMINAL

    266	000456	000761 				BR	ATTACH		;AND RE-ATTACH IT TO TURN OFF ^O

    267

    268

    269						.SBTTL	ENDLIN

    270					;

    271					; FUNCTION

    272					;	PUT OUT <CR><LF> TO THE TERMINAL

    273					;

    274					; INPUTS

    275					;	NONE

    276					;

    277					; OUTPUTS

    278					;	VALUE - NONE

    279					;

    280	000460	012705 	000000'		ENDLIN::MOV	#EOLSTR,R5	;ADDRESS OF TERMINATOR

    281	000464	012703 	000002 			MOV	#EOLLGT,R3	;LENGTH

    282	000470	012704 	000000G			MOV	#ODPB,R4	;QIO BLOCK

    283	000474	004767 	177652 			CALL	TRMIO

    284						.IF NDF	RSTS

    285	000500	004767 	000104 			CALL	PAD		;PUT IN NULL PADDING IF NEEDED

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-5

ENDLIN



    286						.ENDC	;RSTS

    287	000504	000207 				RETURN

    288

    289	000000					.PSECT	IMPURE,D

    290	000000	   015 	   012 		EOLSTR:	.BYTE	15,12

    291		000002 			EOLLGT	=	.-EOLSTR

    292	000506					.PSECT

    293

    294

    295						.SBTTL	OUTC

    296					;

    297					; FUNCTION

    298					;	OUTPUT A CHARACTER WITH SPECIAL EMPHASIS ON SIMULATING

    299					;	TABS ON HARD COPY, NON-RSTS TERMINALS

    300					;

    301					; INPUTS

    302					;	CHAR - CHARACTER TO BE OUTPUT

    303					;

    304					; OUTPUTS

    305					;	VALUE - NONE.

    306					;	OUTPTR - UPDATED.

    307					;

    308		000006 			CHAR	=	6

    309

    310	000506				OUTC::

    311						.IF NDF	RSTS

    312	000506	010146 				MOV	R1,-(SP)		;SAVE

    313	000510	010246 				MOV	R2,-(SP)		; SCRATCH REGISTERS

    314	000512	126627 	000006 	000011 		CMPB	CHAR(SP),#11		; TAB?

    315	000520	001023 				BNE	30$			; NO

    316	000522	126727 	000000G	000000G		CMPB	TRMTYP,#VT05		; HARD COPY?

    317	000530	002017 				BGE	30$			; NO

    318	000532	016701 	000000G			MOV	CURPOS,R1		; GET POSITION

    319	000536	010102 				MOV	R1,R2			; AND

    320	000540	062702 	000010 			ADD	#10,R2			; ADVANCE TO

    321	000544	042702 	000007 			BIC	#7,R2			; NEXT TAB-STOP

    322	000550	012746 	000040 			MOV	#' ,-(SP)		; FAKE IT WITH BLANKS

    323	000554	004767 	000000G		10$:	JSR	PC,OUTC1		;

    324	000560	005201 				INC	R1			; FILL IN

    325	000562	020102 				CMP	R1,R2			; ENOUGH BLANKS TO

    326	000564	103773 				BLO	10$			; LOOK LIKE A TAB

    327	000566	000404 				BR	50$			;

    328	000570	016646 	000006 		30$:	MOV	CHAR(SP),-(SP)		; ANY OTHER CHARACTER

    329	000574	004767 	000000G		40$:	JSR	PC,OUTC1		; CAN BE OUTPUT EASILY

    330	000600	005726 			50$:	TST	(SP)+

    331	000602	012602 				MOV	(SP)+,R2		; RESTORE SCRATCH

    332	000604	012601 				MOV	(SP)+,R1

    333	000606	000207 				RETURN

    334						.IFF

    335						JMP	OUTC1			;NO NEED FOR SIMULATION HERE

    336						.ENDC	;RSTS

    337

    338						.SBTTL	PAD

    339					;

    340					; FUNCTION

    341					;	GENERATE FILLER PADDING (NULLS) FOR VT05 AND VT50

    342					;	TERMINALS UNDER RSX

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-6

PAD



    343					;

    344					; INPUTS

    345					;	FASTVT - NUMBER OF NULLS TO PAD

    346					;	TRMTYP - TERMINAL TYPE

    347					;

    348					; OUTPUTS

    349					;	VALUE - NONE.

    350					;

    351						.IF NDF	RSTS

    352	000610	026727 	000000G	000000G	PAD::	CMP	TRMTYP,#VT05	;PADDING NECESSARY?

    353	000616	001013 				BNE	10$		;NO

    354	000620	004167 	000000G			JSR	R1,$SAV5	;DON'T SCREW UP CALLER'S REGISTERS

    355	000624	012705 	000002'			MOV	#PADSTR,R5	;ADDRESS

    356	000630	016703 	000000G			MOV	FASTVT,R3	;NUMBER OF CHARACTERS

    357	000634	001404 				BEQ	10$		;DON'T TRY TO PAD ZERO

    358	000636	012704 	000000G			MOV	#ODPB,R4	;QIO BLOCK

    359	000642	004767 	177504 			CALL	TRMIO

    360	000646	000207 			10$:	RETURN

    361						.ENDC	;RSTS

    362

    363	000002					.PSECT	IMPURE,D

    364	000002				PADSTR:

    365						.IF NDF	RSTS

    366	000002	   000 	   000 	   000 		.BYTE	0,0,0,0,0

    367						.ENDC	;RSTS

    368		000005 			MAXPAD	==	.-PADSTR

    369						.EVEN

    370	000650					.PSECT

    371

    372		000001 				.END

CMDIO	MACRO M1110  22-AUG-78 01:56  PAGE 3-7

SYMBOL TABLE



ATTACH  000422RG 	DET001  000440R  	IOSB  = ****** GX	OUTPTR= ****** GX	STAR  = ****** GX

CHAR  = 000006   	ENDLIN  000460RG 	IS.ESC= ****** GX	PAD     000610RG 	STPSCL= ****** GX

CHRESC  000232RG 	EOL     000154RG 	LINSIZ= ****** GX	PADSTR  000002R     002	TRMIO   000352RG

CHRIN   000324RG 	EOLLGT= 000002   	MAXPAD= 000005 G 	PRTERR= ****** GX	TRMTYP= ****** GX

CHRIO = ****** GX	EOLSTR  000000R     002	NOCTLO  000452RG 	QIOATT= ****** GX	VAX   = 000001

CHROUT  000244RG 	ERCTLC= ****** GX	OCDPB = ****** GX	QIODET= ****** GX	VT05  = ****** GX

CMLADR= ****** GX	FASTVT= ****** GX	ODPB  = ****** GX	QUEST = ****** GX	WAIT    000442RG

CMLLEN= ****** GX	GRCHAR= ****** GX	OUTBUF= ****** GX	Q.IOPL= ****** GX	WAITR   000450R

COMAND  000000RG 	IDPB  = ****** GX	OUTC    000506RG 	Q.IOSB= ****** GX	WAIT01= ****** GX

CURPOS= ****** GX	IE.EOF= ****** GX	OUTC1 = ****** GX	RSXD  = 000001   	$SAV5 = ****** GX

DETACH  000432RG



. ABS.	000000	   000

      	000650	   001

IMPURE	000010	   002

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  537 WORDS  ( 3 PAGES)

DYNAMIC MEMORY:  2772 WORDS  ( 10 PAGES)

ELAPSED TIME:  00:00:06

OBJ$:CMDIO,LIS$:CMDIO/-SP=SRC$:VAX,RSXD,CMDIO

