This file contains the work that was done on eight bit quoting.
All changes are denoted by the ;[29] change number.


spar:	ildb t2, t4		; Get the first argument.
	subi t2, " "		; Convert it to a real number.
	movem t2, spsiz		; Set the maximum packet size to send.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		; Get the second argument.
	subi t2, " "		; Convert it to a real number.
	movem t2, stimou	; Set the time out interval.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		; Get the next argument.
	subi t2, " "		; Convert it to a real number.
	movem t2, spadnm	; Set the padding.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		; Get the next argument.
	addi t2, ^o100
	andi t2, ^o177
	movem t2, spadch	; Set the padding char.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		; Get the next argument.
	subi t2, " "		; Convert it to a real number.
	movem t2, seolch	; Set the EOL char.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		; Get the next argument.
	movem t2, squote	; Set the quote char.
	sojle t3, r		;[29] If there is no more data return.
	ildb t2, t4		;[29] Get the next argument.
	cail t2, ^o40		;[29] Is the quote char within range?
	 caig t2, ^o176		;[29]
	  setz t2,		;[29]   If out of range make it zero.
	cail t2, ^o76		;[29] Is the quote char within range?
	 caig t2, ^o140		;[29]
	  skipa			;[29]   No, it is OK.
	 setz t2,		;[29]  If out of range make it zero.
	movem t2, quote8	;[29] Set the quote char.
	ret

rpar:	saveac <q1>
	move q1, rpsiz		; Get the packet size.
	addi q1, " "		; Make the char printable.
	idpb q1, t4		; Put it in the data block.
	move q1, rtimou		; Get the time out interval.
	addi q1, " "		; Make the char printable.
	idpb q1, t4		; Put it in the data block.
	move q1, rpadnm		; Get the padding.
	addi q1, " "		; Make the char printable.
	idpb q1, t4		; Put it in the data block.
	move q1, rpadch		; Get the padding char.
	addi q1, ^o100		; De-controlify it.
	andi q1, ^o177
	idpb q1, t4		; Put it in the data block.
	move q1, reolch		; Get the EOL char.
	addi q1, " "		; Make the char printable.
	idpb q1, t4		; Put it in the data block.
	move q1, rquote		; Get the quote char.
	idpb q1, t4		; Put it in the data block.
	movei q1, "Y"		;[29] Say we can play the 8-bit quote game.
	idpb q1, t4		;[29] Put it in the data block.
	movei t3, 7		;[29] Seven pieces of data.
	ret



gtchr:	saveac <q1,q2,q3,q4>
	stkvar <len,tmpac>
	subi t1, 1		; So we don't mess up on quoting.
	skipe quote8		;[29] Any eight bit quoting?
	 subi t1, 1		;[29]  Be even more careful not to mess up.
	movem t1, len		; Save the length.


gtchr2:	caml q1, len		; Have we exceeded the length?
	 jrst [	move t1, q1	;  Return the length.
		movem q4, mapptr ;  Save the pointer.
		retskp]
	caml schr, filbyt	; Any more chars?
	 jrst [	setom eoflag	;  Set the end of file flag.
		seto t1,	;  Indicate unmap.
		movx t2, <.fhslf,,mappag> ;  This process.
		setz t3,
		PMAP%		;  Unmap the page.
		 %jsker (Error unmapping page,r)
		setzm mapflg	;  Say nothing mapped in.
		move t1, q1	;  Return the size in the right AC.
		retskp]
	ildb t2, q4		; Get the next byte.
	movei t1, <mappag+1>*1000 ; Are we at the end yet
	caig t1, (q4)
	 jrst [	seto t1,	;  Indicate unmap.
		movx t2, <.fhslf,,mappag> ;  This process.
		setz t3,
		PMAP%		;  Unmap the page.
		 %jsker (Error unmapping page,r)
		move t1, prepag	;  Get the present page number.
		addi t1, 1	;  Increment it.
		caml t1, filpag	;  Any more pages?
		 jrst [	setom eoflag ;   Set the end of file flag.
			move t1, q1 ;   Return the size in the right AC.
			setzm mapflg ;   Say nothing mapped in.
			retskp]
		movem t1, prepag ;  Save the new number.
		hrl t1, filjfn	;  <file JFN,, page 0>
		movx t2, <.fhslf,,mappag> ;  <our fork,,mapping page>
		movx t3, pm%rd	;  Just want to read it.
		PMAP%		;  Map it in.
	 	 %jsker (Unable to map in the file,r) ;   Error close up.
		move q4, [point 7, mappag*1000]	;  Get a pointer to it.		
		skipe ebtflg	;[17]  Eight bit access?
		 move q4, [point 8, mappag*1000] ;[17]  Get a pointer to it.
		ildb t2, q4	;  Get the next byte.
		jrst .+1]
	addi schr, 1		; Increment the file chars sent total.
	addi q1, 1		; Increment char count.
;[29] Begin relocation (used to be at the end of this subroutine)
	move q3, schr		; Get the char count.
	skipe ebtflg		;[17] Eight bit mode?
	 jrst gtchr4		;[17]  If so don't fool with this hack.
	movem q4, tmpac		; Save the AC.
	idivi q3, 5
	skipn q4		; Is this the last char in the word?
	 jrst [	hrr q4, tmpac	;  Get the address of the word.
		move q4, (q4)	;  Get its contents.
		andi q4, 1	;  Get just bit 35.
		lsh q4, 7	;  Shift it over into bit 8.
		ior t2, q4	;  Or in that bit to the char.
		jrst .+1]
	move q4, tmpac		; Restore the AC.
gtchr4:
;[29] End relocation
	movem t2, tmpac		;[17] Save the char.
;[29] Begin addition
	caige t2, ^o200		; Is the parity bit on?
	 jrst [	skipn q3, quote8 ; Is there a quote char?
		 jrst .+1
		addi q1, 1	;  Increment char count.
		idpb q3, q2	;  Put in the quote character.
		andi t2, ^o177	;  Turn off the 8th bit.
		movem t2, tmpac	;  Make believe we saved it earlier.
		jrst .+1]
;[29] End addition
	andi t2, ^o177		;[17] Turn off the 8th bit.
	cail t2, " "		; Is it a control char?
	 cain t2, .chdel	;  Or a delete?
	  jrst [move q3, squote	;   Get the quote character.
		addi q1, 1	;   Increment char count.
		idpb q3, q2	;   Put in the quote character.
		move t2, tmpac	;[17] Restore the char.
		xori t2, ^o100	;   Make the char noncontrol.
		jrst gtchr3]
	camn t2, squote		; Is it the quote character?
	 jrst [	addi q1, 1	;  Increment char count.
		idpb t2, q2	;  Put in the quote character.
		jrst .+1]
;[29] Begin addition
	camn t2, quote8		; Is it the quote character?
	 jrst [	addi q1, 1	;  Increment char count.
		move t2, squote	;  Get the regular quote
		idpb t2, q2	;  Put in the quote character.
		jrst .+1]
;[29] End addition
	move t2, tmpac		;[17] Restore the char.
gtchr3:	idpb t2, q2		; Put in the character.
	jrst gtchr2		; Loop




ptchr:	saveac <q1,q2,q3,q4>
	stkvar <siz,tmp,par>	;[29]
	movem t2, siz		; Save the size.
	move q1, t1		; Save the arguments.
	move q2, t2
	skipn mapflg		; Is there a page mapped in?
	 jrst [	move q3, [point 7, mappag*1000]	;  Get a pointer to it.
		skipe ebtflg	;[17]  Eight bit access?
		 move q3, [point 8, mappag*1000] ;[17]  Get a pointer to it.
		setzm prepag	;  Present page is zero.
		setom mapflg	;  Say we've got a page mapped in.
		jrst ptchr1]
	move q3, mapptr		; Get a pointer to the buffer.
ptchr1:	setz q4,		; Zero quote char count.
ptchr2:	skipg q2		; Are we done?
	 jrst [	movem q3, mapptr ;  Save the byte pointer.
		retskp]
	addi rchr, 1		; Add to the character count.
	subi q2, 1		; Decrement char count.
	ildb t2, q1		; Get the char.
;[29] Begin addition
	setzm par		; Set the parity bit to zero.
	camn t2, quote8		; Is it the parity bit quote character?
	 jrst [	subi q2, 1	;  Decrement char count.
		addi q4, 1	;  Increment quote char count.
		movei t2, ^o200	;  Get the parity bit.
		movem t2, par	; Save it.
		ildb t2, q1	;  Get the quoted character.
		jrst .+1]
;[29] End addition
	camn t2, rquote		; Is it the quote character?
	 jrst [	subi q2, 1	;  Decrement char count.
		addi q4, 1	;  Increment quote char count.
		ildb t2, q1	;  Get the quoted character.
		move t1, t2	;  Save the parity bit.
		andi t1, ^o177	;  Save modulo 200 of the number.
		camn t1, rquote	;  Is it the quote character?
		 jrst .+1	;   Yes, don't convert it.
		camn t1, quote8	;[29]  Is it the parity quote character?
		 jrst .+1	;[29]   Yes, don't convert it.
		xori t2, ^o100	;  Make the char noncontrol.
		jrst .+1]
	or t2, par		;[29] Or in the possible parity bit.
	idpb t2, q3		; Put it in the page.
	skipn ebtflg		;[17] Eight bit mode?
	 caige t2, ^o200	; Is the parity bit on?
	 skipa			;[17]
	 jrst [	move t3, rchr	;  If so, get the char count.
		idivi t3, 5
		skipn t4	;  Is this the last char in the word?
		 jrst [	move t4, (q3) ;   If so, get its contents.
			iori t4, 1 ;   Turn on bit 35.
			movem t4, (q3)
			jrst .+1]
		jrst .+1]
	movei t1, <mappag+1>*1000 ; Are we at the end yet?
	caig t1, (q3)
	 jrst [	movem t2, tmp	;  Save char we just put in the wrong place.
		movx t1, <.fhslf,,mappag> ;  <our fork,,mapping page>
		hrl t2, filjfn ;  <file JFN,, page #>
		hrr t2, prepag
		movx t3, pm%rd!pm%wr ;  Read and write.
		PMAP%		;  Map it out.
	 	 %jsker (Unable to map out file page,r) ;   Error close.
		move t1, prepag	;  Get the present page number.
		addi t1, 1	;  Increment it.
		movem t1, prepag ;  Save the new number.
		move q3, [point 7, mappag*1000]	;  Get a pointer to it.		
		skipe ebtflg	;[17]  Eight bit access?
		 move q3, [point 8, mappag*1000] ;[17]  Get a pointer to it.
		move t2, tmp	;  Get back our char.
		idpb t2, q3	;  Put it into the new page.
		jrst .+1]
	jrst ptchr2		; Loop.


rquote:	drquot			; Quote character I want.
quote8:	0			;[29] No, quoting by default.
delay:	ddelay			; How long before I send the first packet.


