/ OS/8 HELP PROGRAM
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/ AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/ CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/ THE SOFTWARE DESCRIBED HEREIN IS FURNISHED TO THE PURCHASER
/ UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/ (WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/ SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT ASSUMES NO RESPONSIBILITY FOR THE USE
/ OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED
/ BY DIGITAL.
/
/ COPYRIGHT (C) 1977 BY DIGITAL EQUIPMENT CORPORATION
/

/
/ VERSION #1 	B. M.		1/1/77
/ VERSION #2A	M. H.		4/22/77
/ (CHANGE TAG VERS WHEN CHANGING VERSION NUMBERS)
/
/ THIS PROGRAM CAN BE CALLED DIRECTLY OR CHAINED TO BY CCL TO
/ PRINT INFORMATION ON RANDOM SUBJECTS THE USER ASKS ABOUT.
/
/ START ADDRESS:200	JSW:3401
/ CORE LIMITS:200-7377
/
/ THIS PROGRAM REQUIRES AN INPUT FILE TO RUN. FOR OS/8 THE FILE
/ SHOULD BE NAMED "HELP8.HL" FOR OS/78 THE NAME SHOULD BE "HELP78.HL".
/
/ THE FORMAT OF THE FILE IS:
/	<SP><CR><LF>
/	&COMMAND NAME
/	&ADDITIONAL COMMAND NAMES(IF ANY)
/	TEXT OF HELP INFO
/	&NEXT COMMAND NAME
/	TEXT OF NEXT HELP INFO
/	ETC.
/
/ NOTE: TOO SPEED UP PROCESSING A HASHING ALGORITHM IS USED
/ WHICH REQUIRES THAT WHEN MULTIPLE COMMANDS REFERENCE A 
/ SINGLE SUBFILE, THE SUBFILE MUST APPEAR IN THE HELP FILE
/ ALPHABETICALLY ACCORDING TO THE 1ST COMMAND STRING LETTER
/ CLOSEST TO Z.
/ THAT IS, SUBFILES MUST BE ARRANGED ALPHABETICALLY ACCORDING TO
/ THE HIGHEST LETTERED 1ST CHARACTER OF THE COMMAND.
/

USR=	200	/ADDRESS OF USR
OS78=	7771	/ADDRESS OF WD WITH OS/78 FLAG BIT(4)	(MH)
FETCH=	1	/FETCH A HANDLER
LOOKUP=	2	/LOOKUP A FILE NAME
ENTER=	3	/ENTER A FILE
CLOSE=	4	/CLOSE A FILE
DECODE= 5	/CALL THE COMMAND DECODER
HASH=	3	/HASH CODE SUBTRACTION FACTOR(MH)

*10
NAMPTR,	0	/POINTER TO CMD DECODER INPUT NAMES
XR1,	0	/RANDOM INDEX REGISTER
XR2,	0	/ANOTHER RANDOM INDEX REGISTER

*30
COUNT,	0	/RANDOM WORD COUNT FOR ANYTHING
CHAR,	0	/TEMPORARY PLACE TO PUT A CHARACTER
WILD,	0	/IF NONZERO, NAME HAS '*' OR '?' IN IT
WASHLP,	0	/NONZERO IF HELP WAS FOUND ON THIS WORD
NAME,	ZBLOCK 6 /NAME HELP WAS REQUESTED ON
TXTNAM,	ZBLOCK 10 /CURRENT SCRIPT FILE NAME BEING LOOKED AT
NAMCNT,	0	/NUMBER OF NAMES IN THE COMMAND DECODER AREA
BLKCNT,	0	/NUMBER OF AVAILABLE BLOCKS ON OUTPUT
OUTADR,	0	/ADDRESS OF OUTPUT HANDLER
LINCNT,	0	/COUNT OF NUMBER OF NAMES ON '*' OR 'HELP' LINE
LINMAX,	-5	/MAXIMUN NUMBER OF NAMES/LINE ON '*' OR 'HELP' LINE
FILNAM,	ZBLOCK	4 /OUTPUT FILE NAME
WDCTR,	0	/WORD COUNTER IN INPUT BLOCK
CHTEM,	0	/TEMPORARY SPOT FOR CHARACTER IN 2/3 UNPACK
DEVHND,	0	/OUTPUT DEVICE HANDLER ADDRESS
CHPTR,	0	/BUFFER POINTER FOR READING CHARACTERS
TEMP,	0	/TEMP STORE

/ MAIN LOOP OF PROGRAM
STADR=200
*STADR
START,	SKP CLA		/NORMAL ENTRY POINT
	JMP	START1	/CHAINED ENTRY (CMD DECODE DONE BY CCL)
	CIF 10		/SEE WHAT TO DO
	JMS I	(USR
	DECODE
	5200
	0
START1,	JMS I	(INIT	/DO ALL INITIALIZATION AND SETUP
MAINLP,	JMS I	(NXTNAM	/GET NEXT NAME FROM COMMAND DECODER AREA
	JMP I	(EXIT	/NO NAMES LEFT
	JMS I	(RESET	/RESET THE INPUT FILE POINTERS TO THE BEGINNING
	TAD	NAME	/CHECK FOR '*' OR 'HELP" NAME INDICATING LIST OF HELPS
	TAD	(-"*
	SNA!CLA
	JMP	HELPLS	/NAME BEGAN WITH '*'
	TAD	NAME	/NOT '*' LOOK FOR HELP (MH)
	TAD	(-"H
	SZA!CLA
	JMP	MAIN1	/NO 'HELP'
	TAD	NAME+1
	TAD	(-"E
	SZA!CLA
	JMP	MAIN1
	TAD	NAME+2
	TAD	(-"L
	SZA!CLA
	JMP	MAIN1
	TAD	NAME+3
	TAD	(-"P
	SNA!CLA
	JMP	HELPLS	/WAS 'HELP" GO PRINT LIST (MH)
	TAD	NAME	/IS 1ST CHAR A "?"?(MH)
	TAD	(-"?	/(MH)
	SNA!CLA		/(MH)
	JMP	MAIN1	/YES -- DON'T TRY TO HASH FILE (MH)
	TAD	NAME	/NO -- HASH START BLK OF FILE BY (MH)
	AND	(77	/MAKING 1ST CHAR OF NAME SIXBIT (MH)
	DCA	TEMP	/MULTIPLY BY 1.5 (MH)
	TAD	NAME	/THEN SUBTRACT "HASH"(3) (MH)
	AND	(77	/(MH)
	CLL!RAR		/(MH)
	TAD	TEMP	/(MH)
	TAD	(-HASH	/(MH)
	SPA		/(MH)
	CLA		/IF RESULT IF MINUS, SET TO ZERO (MH)
	TAD I	(BLK	/ADD REAL START BLK OF FILE (MH)
	DCA I	(BLK	/REPLACE NEW BLOCK(MH)
MAIN1,	JMS I	(FINDNM	/GET A NAME FROM THE SCRIPT FILE
	JMP	NOHELP	/HIT THE END OF THE FILE INSTEAD OF NAME
	JMS I	(COMPAR	/COMPARE THIS NAME WITH THE ONE HE HAD
	JMP	MAIN1	/NOT A MATCH, TRY NEXT ONE
	JMS I	(PRINT	/PRINT THE HELP INFORMATION FOR THAT NAME
	TAD	WILD	/IF A WILD CARD TYPE NAME (I.E. '?') THEN
	SZA CLA		/  THEN KEEP SEARCHING PAST 1ST MATCH SINCE THERE
	JMP	MAIN1	/  MAY BE MORE.
	JMP	MAINLP	/NOT A WILD CARD, GET NEXT CMD DECODER NAME

/ HIT THE END OF THE SCRIPT FILE
/ IF DOING A WILD CARD NAME, SOME HJELP MAY HAVE ALREADY BEEN PRINTED.  IF
/ NOT, PRINT AN ERROR MESSAGE ON THE TELETYPE (OR WHATEVER)
NOHELP,	TAD	WASHLP	/SEE IF HELP WAS ADMINISTERED
	SZA CLA
	JMP	MAINLP	/YES IT WAS, TRY NEXT NAME ON LIST
	JMS I	(TYPE	/TYPE THE ERROR MESSAGE ON THE TTY
	SORRY-1
	DCA	TXTNAM	/PUT ON ZERO TERMINATER
	JMS I	(TYPE
	NAME-1		/TYPE WHAT HELP MISSED
	JMS I	(TYPE
	CRLF-1		/TYPE CARR RETURN, LINE FEED
	JMP	MAINLP	/NOW CONTINUE ON WITH IT
  
  
/ IF A '*' OR 'HELP' WAS TYPED AS HELP NAME, THEN PRINT A LISTING
/ OF ALL THE INFO IN THE HELP FILE FOR THE USER TO PICK FROM.
HELPLS,	JMS I	[OUTSTR	/PRINT THE HEADING MESSAGE
	AVAIL-1
	TAD	LINMAX	/MAX NO. NAMES PER LINE
	DCA	LINCNT	/INITIAL COUNT OF NAMES PER LINE
HELP1,	JMS I	(FINDNM	/GET NEXT NAME
	JMP	HELP2	/AT END OF FILE
	JMS I	(NAMLST	/PRINT THE NAME
	JMP	HELP1
HELP2,	TAD	LINCNT	/CHECK IF LAST CHAR WAS CRLF
	SNA!CLA
	JMP	MAINLP	/IT WAS, DON'T DO ANOTHER
	JMS I	[OUTSTR
	CRLF-1
	JMP	MAINLP
	PAGE
 
/ CLOSE ALL FILES AND RETURN TO MONITOR
/
EXIT,	TAD	(32	/WRITE AN AND OF FILE TO THE OUTPUT
	JMS I	[PCH
	TAD	(-600	/CLOSE FILE BY WRITING 600(8) NULLS
	DCA	COUNT
	JMS I	[PCH	/WRITE IT
	ISZ	COUNT
	JMP	.-2
	TAD I	[BLKSRT	/COMPUTE ACTUAL FILE LENGTH FOR CLOSE
	CIA
	TAD I	[OUTBLK	/CURRENT BLOCK NUMBER
	IAC
	DCA	OLEN
	CIF CDF 10
	TAD I	[7600
	CDF 0
	JMS I	(USR	/CLOSE THE FILE
	CLOSE
	FILNAM
OLEN,	0		/THE LENGTH
	NOP		/ERROR ON CLOSE... CAN'T HAPPEN(MH)
	JMP I	(7605	/RETURN TO OS/8

/ SEARCH FOR A <LF>& IN THE FILE
/ THIS IS THE START OF SOME HELP INFO FOR A SUBJECT WHICH IS NAMED AFTER
/ THE &.  COPY THE NAME INTO 'TXTNAM' SO COMPARES CAN BE DONE LATER.
/ SKIP IF THE END OF FILE ISN'T FOUND ON THE WAY.
FINDNM,	0
	DCA	TXTNAM	/CLEAR THE NAME OUT
	DCA	TXTNAM+1
	DCA	TXTNAM+2
	DCA	TXTNAM+3
	DCA	TXTNAM+4
	DCA	TXTNAM+5
	DCA	TXTNAM+6
FIND1,	JMS I	[GCH	/LOOK FOR A <LF>& IN THE FILE
	TAD	(-232	/CHECK FOR END OF FILE
	SNA 
	JMP I	FINDNM	/RETURN IF FOUND
	TAD	(232-212	/CHECK FOR LINE FEED
	SZA CLA
	JMP	FIND1	/NOT IT
FIND5,	JMS I	[GCH	/TRY FOR THE & NOW
	TAD	(-"&
	SNA CLA
	JMP	FIND2	/FOUND A LF,&
	TAD	("&-232	/MAKE SURE THIS ISNT THE END OF FILE
	SNA CLA
	JMP I	FINDNM	/END OF FILE FOUND, RETURN
	JMP	FIND1	/KEEP LOOKING FOR NAME
FIND2,	TAD	(TXTNAM-1 /MOVE THE NAME INTO 'TXTNAM'
	DCA	XR1
	TAD	(-7	/MAX OF 7 CHARACTERS
	DCA	COUNT
FIND3,	JMS I	[GCH	/GET A NAME CHARACTER
	TAD	(-215	/CHECK IF THE END OF LINE <CR>
	SNA CLA
	JMP	FIND4	/END OF LINE, THATS IT
	TAD	CHAR
	DCA I	XR1	/SAVE CHARACTER IN TXTNAM
	ISZ	COUNT
	JMP	FIND3	/IF MORE CHARACTERS LEFT
FIND4,	ISZ	FINDNM	/BUMP RETURN ADDRESS FOR FOUND RETURN
	JMP I	FINDNM
	PAGE

/ COMPARE TWO STRINGS, ONE IN NAME AND ONE IN TXTNAM.  CHECK FOR WILD
/ CARD STUFF LATER WHEN THIS PART IS WORKING.
/ SKIP IF NAMES ARE EQUAL
COMPAR,	0
	TAD	[NAME-1	/SET UP REGISTERS FOR COMPARE
	DCA	XR1
	TAD	(TXTNAM-1
	DCA	XR2
	TAD	(-6
	DCA	COUNT
COMP1,	TAD I	XR1	/GET A CHARACTER AND COMPARE WITH ONE FROM
	DCA	CHAR
	TAD	CHAR
	TAD	(-"?	/WILDCARD
	SZA CLA
	JMP	COMP3	/NO WILDCARD
	ISZ	XR2
	ISZ	WILD
	JMP	COMP2
COMP3,	TAD	CHAR
	CIA		/   THE OTHER STRING
	TAD I	XR2
	SZA CLA
	JMP I	COMPAR	/NO MATCH, NORMAL RETURN
COMP2,	ISZ	COUNT
	JMP	COMP1
	ISZ	COMPAR	/EQUAL RETURN IS RETRN ADDR+1
	JMP I	COMPAR

/ GET THE NEXT NAME FROM THE COMMAND DECODER AREA
/ STOP ON EITHER A ZERO OR THE NAME GOING TO ZERO
NXTNAM,	0
	ISZ	NAMCNT	/COUNT NAMES, ONLY 5 IN THE AREA
	SKP
	JMP I	NXTNAM	/RETURN, NO MORE NAMES
	CLA CLL CMA RTL	/NUMBER OF WORDS OF NAME(-3)
	DCA	COUNT
	TAD	[NAME-1
	DCA	XR1
	CDF 10
	TAD I	NAMPTR	/GET 1ST CHARACTER OF NAME
	CDF 0
	SNA
	JMP	NXTN3	/MAYBE OUT OF NAMES(MH)
NXTN1,	DCA	CHAR	/SAVE THE WORD
	TAD	CHAR
	RTR
	RTR
	RTR		/ISOLATE HIGH 6 BITS
	JMS	SIXTO8
	DCA I	XR1	/PUT IN NAME BUFFER
	TAD	CHAR	/NOW DO OTHER HALF
	JMS	SIXTO8
	DCA I	XR1	/2ND CHARACTER OF WORD
	ISZ	COUNT
	SKP
	JMP	NXTN2	/NO MORE CHARACTERS IN NAME
	CDF 10
	TAD I	NAMPTR	/LOOP IS STRANGE (SHOULD USE DEVICE WORD FOR CHECK)
	CDF 0
	JMP	NXTN1
NXTN2,	ISZ	NAMPTR	/BUMP POINTER TO NEXT NAME IN AREA
	ISZ	NAMPTR
	ISZ	NXTNAM	/BUMP RETURN ADDRESS FOR FOUND NAME
	JMP I	NXTNAM
NXTN3,	TAD	NAMCNT	/CHECK FOR "HELP<CR>" OR "TTY:<<CR>"(MH)
	TAD	(4	/IF 1ST TRY AT A NAME THEN NULL COMMAND WAS INPUT(MH)
	SZA!CLA
	JMP I	NXTNAM	/WASN'T NULL -- RETURN, END OF NAMES
	DCA	NAME	/WAS NULL -- CLEAR OUT NAME BUFFER
	DCA	NAME+1
	DCA	NAME+2
	DCA	NAME+3
	DCA	NAME+4
	DCA	NAME+5
	JMP	NXTN2	/PREPARE TO RETURN(MH)

SIXTO8,	0		/CONVERT 6BIT TO 8BIT
	AND	(77
	SNA		/SNA IF NOT A NULL
	JMP I	SIXTO8	/ELSE RETURN 8BIT NULL
	TAD	(240
	AND	(77
	TAD	(240
	JMP I	SIXTO8

/ PRINT ALL THE STUFF BETWEEN LINES OF THE OUTPUT DEVICE
/ THIS CONTINUES UNTIL A <LF>& IS SEEN OR AND OF FILE IS READ
PRINT,	0
	ISZ	WASHLP	/SET FLAG SAYING HE WAS HELPED
PRINT3,	JMS I	[GCH	/FIND 1ST LF WITHOUT FOLLOWING &, THEN PRINT(MH)
	TAD	(-212	/WAS CHAR LF?(MH)
	SZA!CLA		/(MH)
	JMP	PRINT3	/NO -- READ NEXT CHAR(MH)
	JMS I	[GCH	/YES -- LOOK FOR &(MH)
	TAD	(-"&	/(MH)
	SNA!CLA		/(MH)
	JMP	PRINT3	/IT WAS & SO CONTINUE(MH)
	JMS I	(OUTSTR	/IT WASN'T & SO BEGIN PRINTING(MH)
	CRLF-1
	TAD	CHAR	/(MH)
	SKP		/(MH)
PRINT1,	JMS I	[GCH	/GET A CHARACTER
	JMS I	[PCH	/PRINT THE CHARACTER
	TAD	CHAR	/CHECK FOR <LF>
	TAD	(-212
	SZA CLA
	JMP	PRINT1
	JMS I	[GCH	/TRY FOR EITHER & OR END OF FILE OR FF
	TAD	(-"&	/CHECK FOR A &
	SNA
	JMP I	PRINT	/STOP ON <LF> & FOUND
	TAD	(+32	/CHECK FOR <FF>  ("&-"<FF>  (MH)
	SNA		/(MH)
	JMP I	PRINT	/(MH)
	TAD	(-16	/-<EOT>+<FF> (MH)
	SNA
	JMP I	PRINT	/RETURN IF END OF FILE
	TAD	(232-"@
	SNA CLA
	JMP	PRINT1	/SKIP "@" IF 1ST CHAR ON LINE
	TAD 	CHAR	/GET THE CHARACTER BACK TO PRINT
	JMS I	[PCH	/PRINT IT
	JMP	PRINT1
	PAGE
/ TYPE A MESSAGE ON THE TELETYPE
/ THE MESSAGE IS ONE CHARACTER PER WORD, TERMINATED WITH A ZERO
TYPE,	0
	TAD I	TYPE	/GET THE MESSAGE ADDRESS
	ISZ	TYPE	/BUMP RETURN ADDRESS
	DCA 	XR1
TYPE1,	TAD I	XR1	/GET A CHARACTER
	SNA
	JMP I	TYPE	/END OF THE MESSAGE
	TLS		/PRINT THE CHARACTER
TYPE2,	TSF
	JMP	TYPE2
	CLA
	JMP	TYPE1	/LOOP
  
  
/PRINT THE NEXT NAME ON THE OUTPUT DEVICE AND CHECK TO SEE IF
/ A CRLF IS NEEDED. EACH NAME IS TERMINATED WITH A TAB CHAR
NAMLST,	0
	TAD	TXTNAM	/CHECK FOR NULL NAME (MH)
	SZA!CLA		/(MH)
	JMP	NAMLS1	/NOT NULL NAME (MH)
	JMS	OUTSTR	/WAS NULL -- PRINT "<NONE>" (MH)
	NULNAM-1	/(MH)
	JMP	NAMLS2	/PROCEED (MH)
NAMLS1,	JMS 	OUTSTR	/PRINT THE NAME ON THE DEVICE
	TXTNAM-1
NAMLS2,	JMS 	OUTSTR	/PRINT A TAB AFTER NAME
	TAB-1
	ISZ	LINCNT	/BUMP NUMBER PRINTED SO FAR
	JMP I	NAMLST	/NO YET, JUST RETURN
	TAD	LINMAX	/RESET TO MAX NUMBER OF NAMES PER LINE
	DCA	LINCNT
	JMS	OUTSTR	/TYPE CRLF
	CRLF-1
	JMP I	NAMLST	/NOW RETURN


/ PRINT A STRING ON THE OUTPUT DEVICE BY STUFFING THE CHARACTERS
/ IN THE OUTPUT FILE.  THE ADDRESS-1 IS FOLLOWING THE JMS
OUTSTR,	0
	TAD I	OUTSTR	/GET THE ADDRESS
	ISZ	OUTSTR
	DCA	XR1	/POINTER TO NAME
OUTS1,	TAD I	XR1	/GET A CHARACTER
	SNA
	JMP I	OUTSTR	/RETURN IF DONE
	JMS I	[PCH	/PRINT THE CHARACTER
	JMP	OUTS1

	PAGE
/ GET A CHARACTER FROM THE INPUT FILE
GCH,	0
	TAD	CHAR	/RETURN A EOF IF THE LAST WAS EOF
	TAD	(-232
	SZA CLA
	JMP I	GIVCH	/NOT EOF, GET NEXT CHARACTER
	TAD	(232	/GET END OF FILE
	JMP I	GCH

GIVCH,	INITBF		/INITIALLY SET UP BUFFERS
	AND	(377	/MASK THE CHARACTER
	DCA	CHAR	/SAVE CHARACTER
	TAD	CHAR
	JMP I	GCH	/RETURN

INITBF,	TAD	(-2000	/SET WORD COUNT FOR BLOCK(MH)
	DCA	WDCTR
	TAD	BUFAD
	DCA	CHPTR	/CHARACTER POINTER FOR BUFFER
	TAD I	(BLKBGN	/FIND OUT IF DATA TRANSFER WILL(MH)
	CMA!IAC		/PASS END OF FILE, IF SO REDUCE(MH)
	TAD I	(FSIZE	/SIZE OF TRANSFER.(MH)
	DCA	TEMP	/SAVE -ST. BLK.-FILE SIZE(MH)
	TAD	RDFCT	/GET TRANSFER LENGTH IN BLKS(MH)
	CLL!RTL		/(MH)
	RTL		/(MH)
	RTL		/(MH)
	TAD	BLK	/ADD CURRENT BLK(MH)
	TAD	TEMP	/SUBTRACT (ST. BLK OF FILE + SIZE)(MH)
	SPA!SNA		/(MH)
	JMP	INITOK	/PROCEED -- DON"T CHG. TRANSFER LEN(MH)
	CLL!RTR		/CHANGE TRANSFER LENGTH SO IT WON'T(MH)
	RTR		/PASS END OF FILE(MH)
	RTR		/(MH)
	CMA!IAC		/(MH)
	TAD	RDFCT	/(MH)
	DCA	RDFCT	/ENTER THIS INTO FUNCTION WD.(MH)
INITOK,	JMS I	DEVHND	/CALL THE HANDLER TO READ A BLOCK
RDFCT,	2000		/8 BLOCKS(MH)
BUFAD,	BUFFER
BLK,	0		/BLOCK NUMBER
	JMP	RDERR	/ERROR RETURN(MH)
NXTCH,	TAD I	CHPTR
	JMS	GIVCH
	TAD	(7400
	AND I	CHPTR	/GET THE HIGH ORDER PART
	DCA	CHTEM
	ISZ	CHPTR
	TAD I	CHPTR
	JMS	GIVCH
	TAD I	CHPTR
	AND	(7400
	CLL RTR
	RTR
	TAD	CHTEM	/GET OTHER HALF
	RTR
	RTR
	JMS	GIVCH	/GIVE THIRD CHARACTER OF GROUP
	ISZ	CHPTR
	ISZ	WDCTR	/BUMP WORD COUNTER
	JMP	NXTCH	/LOOP
	TAD	RDFCT	/INCREMENT BLOCK NUMBER(MH)
	CLL!RTL		/(MH)
	RTL		/(MH)
	RTL		/(MH)
	TAD	BLK	/(MH)
	DCA	BLK	/ENTER INTO FUNCTION WD(MH)
	JMP	INITBF	/READ IT IN

	PAGE
/ ROUTINE TO INITIALIZE ALL OF THIS STUFF
/ POINTERS GET SET AND THE FILES OPENED.
INIT,	0
	TAD	(OUTHSP+1
	DCA	OUTHND
	TAD	(OUTHSP+1	/HANDLER ADDRESS
	DCA	OUTHN1
	CDF 10
	TAD I	[7600	/GET OUTPUT DEVICE
	SNA
	JMP	TTYDFL
	CIF 10
	CDF 0
	JMS I	(USR	/FETCH THE HANDLER
	FETCH
OUTHN1,	OUTHSP+1
	JMP	FETERR	/ERROR RETURN(MH)
	TAD	OUTHN1	/GET HANDLER ADDRESS
	JMP	COMMON	/COMMON CODE FOR BOTH FETCHES

/ DEFAULT TO THE TTY WHEN NO OUTPUT DEVICE IS SPECIFIED
TTYDFL,	TAD	TTYNM	/SET UP THE DEVICE NAME
	DCA	TTY
	TAD	TTYNM+1
	DCA	TTY+1
	CIF 10		/FETCH THE OUTPUT HANDLERS
	CDF 0
	JMS I	(USR
	FETCH
TTY,	DEVICE	TTY	/DEFAULT TO THE TTY
OUTHND,	OUTHSP+1		/PLACE TO PUT THE HANDLER
	JMP	NOTTY	/IF TELETYPE HANDLER DOESNT EXIST
	TAD	TTY+1	/SET UP DEVICE NUMBER FOR COMMON CODE
	CDF 10
	DCA I	[7600
	CDF 0
	TAD	OUTHND	/GET HANDLER ENTRY POINT
COMMON,	DCA	OUTADR
	TAD	(OUTBUF
	DCA I	(OCPTR
	TAD	(-200	/OUTPUT BUFFER COUNT
	DCA I	(OUWDCT
	TAD	(7600
	DCA	XR1	/COPY NAME FROM FIELD 1 CMD DEC AREA
	CDF 10
	TAD I	XR1
	SNA
	TAD	(1014	/HL.LS IS DEFAULT NAME IF NONE THERE
	DCA	FILNAM
	TAD I	XR1
	DCA	FILNAM+1
	TAD I	XR1
	DCA	FILNAM+2
	TAD I	XR1	/COPY EXTENSION
	SNA
	TAD	(1423	/USE .LS AS DEFAULT EXTENSION
	DCA	FILNAM+3
	CDF 0
	TAD	(FILNAM	/INITIALIZE THE ENTER
	DCA	BLKSRT
	CDF CIF 10
	TAD I	(7600
	CDF 0
	JMS I	(USR	/DO ENTER WITH DEVICE NO IN AC
	ENTER
BLKSRT,	0		/STARTING BLOCK
FILLNG,	0		/LENGTH OF FILE
	JMP	NOROOM	/DEVICE FULL
	TAD	BLKSRT
	DCA I	[OUTBLK	/INITIAL OUTPUT BLOCK
	TAD	FILLNG
	DCA	BLKCNT	/NEGATIVE FILE LENGTH IN BLOCKS

	TAD	(7605	/SET NXTNAM POINTER TO THE NEXT NAME
	DCA	NAMPTR
	TAD	(-5
	DCA	NAMCNT	/NUMBER OF CHARACTERS IN NAME
	CIF 10
	JMS I	(USR	/FETCH THE SYSTEM DEVICE HANDLER
	FETCH		/  TO GET THE DEVICE NUMBER TO LOOKUP HELP FILE
DEVNAM,	DEVICE	SYS	/(MH)
DEVH,	0		/HANDLER ADDRESS FOR READING
	JMP	FETERR	/FETCH ERROR(MH)
	TAD	DEVNAM+1 /GET THE SYS DEVICE NUMBER
	CIF 10		/LOOKUP HELP FILE WITH IT
	JMS I	(USR
	LOOKUP
BLKBGN,	HELP8		/STARTING BLOCK OF THE FILE(MH)	
FSIZE,	0		/-NUMBER OF BLOCKS(MH)
	JMP	NOSCRP	/THE SCRIPT FILE (HELP FILE) ISNT THERE
	TAD	DEVH
	DCA	DEVHND	/COPY TO PG 0 FOR ADDRESSABILITY
	JMP I	INIT	/THATS IT

NOSCRP,	JMS I	(TYPE	/TYPE MESSAGE SAYING HELP FILE NOT THERE
	NOSC-1
	JMP I	(7605	/RETURN TO NONITOR
NOTTY,	JMS I	(TYPE
	TTYMIS-1
	JMP I	(7605
TTYNM,	DEVICE	TTY
NOROOM,	JMS I	[TYPE	/DEVICE FILL
	DEVFUL-1
	JMP I	(7605	/RETURN TO MONITOR
	PAGE

/ RESET THE INPUT FILE TO THE FIRST BLOCK AND RESET ALL THE CHARACTER
/ UNPACKING STUFF TO THE 1ST CHARACTER OF THE FILE
RESET,	0
	TAD I	(BUFFER	/RESET BUFFER POINTER TO START
	DCA	CHPTR
	DCA	WASHLP	/SET NOT YET HELPED
	DCA	CHAR	/SET TO STOP EOF STUFF
	TAD	(-2000	/RESET WORD COUNT FOR 8 BLOCKS(MH)
	DCA	WDCTR
	TAD I	(BLKBGN	/RESET STARTING BLOCK OF FILE
	DCA I	(BLK
	TAD	(2000	/RESET TRANSFER LEN FOR 8 BLOCKS(MH)
	DCA I	(RDFCT	/(MH)
	TAD	(INITBF	/SET UP TO REREAD BLOCK 0 OF FILE
	DCA I	(GIVCH
	JMP I	RESET

/ PUT A CHARACTER OUT TO THE OUTPUT DEVICE
/ THIS IS A COOROUTINE TYPE GUY JUST LIKE THE INPUT HANDLER

PCH,	0
	JMP I	RPOS	/DISPATCH

RPOS1,	DCA I	OCPTR	/PUT 1ST CHARACTER IN BUFFER
	JMS	RPOS

RPOS2,	DCA	HOLD	/SAVE THE 2ND CHARACTER
	JMS	RPOS

RPOS3,	RTL		/PACK THE CHARACTERS
	RTL
	DCA	HOLD2
	TAD	HOLD2
	AND	(7400
	TAD I	OCPTR
	DCA I	OCPTR	/PART WAY DONE
	ISZ	OCPTR
	TAD	HOLD2
	RTL
	RTL
	AND	(7400	/NOW THE 2ND WORD
	TAD	HOLD
	DCA I	OCPTR
	ISZ	OCPTR	/BUMP POINTER AGAIN
	ISZ	OUWDCT
	SKP
	JMS	DUMP	/IF AT THE END OF THE BUFFER
RPOS4,	JMS	RPOS
	JMP	RPOS1
RPOS,	RPOS1		/INITIALLY SET TO THE 1ST CHARACTER
	JMP I	PCH	/RETURN TO THE USER

OUWDCT,	0	/OUTPUT BUFFER WORD COUNTER
OCPTR,	0	/OUTPUT CHARACTER BUFFER POINTER
HOLD,	0	/TEMPORARY PLACE TO PUT A CHARACACTER
HOLD2,	0	/SAME AS ABOVE

/ DUMP THE OUTPUT BUFFER TO THE OUTPUT FILE

DUMP,	0
	ISZ	BLKCNT	/SEE IF ANY ROOM LEFT TO DUMP TO
	SKP
	JMP	DUMPER	/IF OUT OF ROOM
	JMS I	OUTADR	/CALL THE HANDLER
	4200
OUTBFA,	OUTBUF		/OUTPUT BUFFER ADDRESS
OUTBLK,	0		/OUTPUT BUFFER BLOCK NUMBER
	JMP	WRERR	/WRITE ERROR(MH)
	TAD	OUTBFA	/RESET INPUT POINTER
	DCA	OCPTR
	TAD	(-200	/RESET THE WORD COUNT
	DCA	OUWDCT
	ISZ	OUTBLK	/BUMP OUTPUT BLOCK NUMBER
	JMP I	DUMP	/RETURN
DUMPER,	JMS I	(TYPE	/TYPE ERROR MESSAGE
	DEVFUL-1	/FILE FULL ERROR
	JMP I	(7605
WRERR,	JMS I	(TYPE		/WRITE ERROR (MH)
	MWRERR-1	/(MH)
	JMP I	(7605	/(MH)
FETERR,	JMS I	(TYPE	/FETCH ERROR (MH)
	MFEERR-1	/(MH)
	JMP I	(7605	/(MH)
RDERR,	JMS I	(TYPE	/(READ ERROR (MH)
	MRDERR-1	/(MH)
	JMP I	(7605	/(MH)
MWRERR,	"W; "R; "I; "T; "E; 240; "E; "R; "R; 215; 212; 0
MFEERR,	"F; "E; "T; "C; "H; 240; "E; "R; "R; 215; 212; 0
MRDERR,	"R; "E; "A; "D; 240; "E; "R; "R; 215; 212; 0
	PAGE

TTYMIS,	"N;"O;" ;"T;"T;"Y;" ;"H;"A;"N;"D;215;212;0
NOSC,	"N;"O;" ;"H;"E;"L;"P; 240; "F; "I; "L; "E; 215;212;0
NULNAM,	242; "N; "O; "N; "E; 242; 0
AVAIL,	"	; "H; "E; "L; "P; ".; "S; "V; 215; 212
	240; 215; 212
	"C; "A; "L; "L; "I; "N; "G; 240; "C; "O; "M; "M; "A; "N; "D; "S; ":
	215; 212; ".; "H; "E; "L; "P; 240; "P; "A; "R; "A; "M; "E; "T; "E; "R
	215; 212
	240; 215; 212
	"P; "A; "R; "A; "M; "E; "T; "E; "R; "S; ":; 215; 212; 0
CRLF,	215;212;0
TAB,	211;0
SORRY,	215;212;"N;"O;240;"H;"E;"L;"P;240;"-;240;0
DEVFUL,	"D;"E;"V;"I;"C;"E;240;"F;"U;"L;"L;215;212;0
HELP8,	FILENAME HELP.HL
VERS,	0201		/VERSION 2A    (MH)
	PAGE
OUTHSP,	ZBLOCK	400	/OUTPUT HANDLER SPACE
OUTBUF,	ZBLOCK	400	/OUTPUT BUFFER FOR LISTING
BUFFER=.		/INPUT BUFFER FOR HELP FILE, 8 BLKS OR 4000 WDS (MH)
$
