Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-02 - decus/20-0028/ebcdic.mac
There are 2 other files named ebcdic.mac in the archive. Click here to see a list.
	TITLE EBCDIC ASCII CONVERSION PROGRAM 11-13-69
	SUBTTL BY LARRY WADE/TAKEN FROM CODE BY VALDEANE ALUSIC

;	THE CHANGES HAVE ONLY BEEN MADE FOR THE EBDIC-ASCII DIRECTION
;
	LOC 137
	1
	RELOC
	I=1		;INPUT CHAN
	OU=2		;OUTPUT CHAN
	TAPE=3		;TAPE SPIN CHAN
	T=4		;TTY CHAN
	AC1=1		;CHAC READIN MTA	
	MSG=2		;MESSAGES
	AC3=3
	AC4=4		;CHAR COUNT
	AC5=5		;CHAR READ IN TTY
	AC6=6		;STATUS CHECK
	AC7=7		;UTILITY
	AC10=10		;UTILITY
	P=17		;PUSHDOWN POINTER
	ASCI=1		;ASCII INPUT
	ASCO=2		;ASCII OUTPUT
	FMT=12		;FORMAT WORD

START:	CALL [SIXBIT/RESET/]
	MOVE	P,[IOWD 12,PDLST]	;SET UP PDPNTR
	PUSHJ	P,REINIT
CODES:	SETZ	FMT,
	JSR	INTTY
	HRRI	MSG,CODESI
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	CODES
	CAIN	AC5,15
	JRST	CODES1
	MOVE	AC6,IFMT
	TRZ	AC6,1014	;ASCII MODE BITS SET ODD PAR 556 BPI
	TRO	FMT,ASCI		;SET ASCII INPUT FLG
	CAIN	AC5,"A"
	JRST	.+5		;LEAVE THE FLG SET
	CAIE	AC5,"B"		;CLR FLG IF BCD
	JRST	ILLCHR
	TRZ	FMT,ASCI
	TRO	AC6,1014	;BINARY MODE BITS SET, EVEN PAR 556 BPI
	MOVEM	AC6,IFMT

CODES1:	HRRI	MSG,CODESO
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	CODES1
	CAIN	AC5,15
	JRST	COMND
	MOVE	AC6,OFMT
	TRZ	AC6,1014		;ASCII MODE BITS SET
	TRO	FMT,ASCO
	CAIN	AC5,"A"
	JRST	.+5
	CAIE	AC5,"B"
	JRST	ILLCHR
	TRZ	FMT,ASCO
	TRO	AC6,1014
	MOVEM	AC6,OFMT


COMND:	JSR	INTTY
	HRRI	MSG,STAND	;TYPE OUT "STANDARD FORMAT"
	JSR	TYPE
	INPUT	T,
	JSR	INCHR	;READ IN A CHAR
	JRST	.-3		;ERROR RETURN
	CAIE	AC5,12		;LF
	CAIN	AC5,15		;CR
	JRST	TAPCON-1		;GO TO TAPE CONTROL, STANDARD
				;FORMAT.
	CAIE	AC5,"N"	;NON STANDARD FORMAT
	JRST	COMND

;GET 6 CHARACTERS, PUT THEM IN OFLNAM AS OUTPUT
;FILE NAME

	CAIN	AC5,"R"		;TEST FOR RESET
	PUSHJ	P,REINIT		;REINITIALIZE
INAME:	MOVNI	AC4,7
	JSR	INTTY
	HRRI	MSG,FILEI
	JSR	TYPE
	INPUT	T,

INAME1:	JSR	INCHR
	JRST	INAME
	CAIN	AC5,"/"
	JRST	ILLCHR
	CAIN	AC5,"."
	JRST	IEXT
	CAIN	AC5,15
	JRST	FILNAM
	CAIN	AC5,12
	JRST	FILNAM
	AOJGE	AC4,IEXT

INMSTO:	SUBI	AC5,40
	IDPB	AC5,INMPTR
	JRST	INAME1

IEXT:	MOVNI	AC4,4
	JSR	INCHR
	JRST	INAME
	CAIN	AC5,"/"
	JRST	ILLCHR
	CAIN	AC5,"."
	JRST	IEXT+1
	AOJGE	FILNAM
	CAIN	AC5,15
	JRST	FILNAM
	CAIN	AC5,12
	JRST	FILNAM

IEXSTO:	SUBI	AC5,40
	IDPB	AC5,IEXPTR
	JRST	IEXT+1

FILNAM:	MOVNI	AC4,7		;ACCEPT 6 CHARS
	JSR	INTTY
	HRRI	MSG,FILEO
	JSR	TYPE
	INPUT	T,
FILNM1:	JSR	INCHR	;GET A CHAR
	JRST	FILNAM
	CAIN	AC5,"/"		;IS IT A /?
	JRST	ILLCHR
	CAIN	AC5,"."
	JRST	EXT		;GO TO EXTENSION READ IN
	CAIN	AC5,15
	JRST	PARITY
	CAIN	AC5,12
	JRST	PARITY
	AOJGE	AC4,EXT		;6 CHARS
FILSTO:	SUBI	AC5,40		;CONVRT TO SIXBIT
	IDPB	AC5,NAMPTR	;STOR IT
	JRST	FILNM1

;READ IN 3 CHARS FOR FILE EXTENSION

EXT:	MOVNI	AC4,4		;ACCEPT 3 CHARS
	JSR	INCHR	;GET A CHAR
	JRST	FILNAM		;ERROR, GO TO BEGINNING
	CAIN	AC5,"/"
	JRST	ILLCHR		;EVENTUALLY GOES TO BEGINNING
	CAIN	AC5,"."
	JRST	EXT+1
	AOJGE	AC4,PARITY
	CAIN	AC5,15
	JRST	PARITY
	CAIN	AC5,12
	JRST	PARITY

EXTSTO:	SUBI	AC5,40		;CHNG TO 6BIT
	IDPB	AC5,EXTPTR	;STOR EXT
	JRST	EXT+1		;GET NXT CHR

;TYPE OUT PARITY MESSAGES AND READ IN INPUT
;AND OUTPUT PARITY.

PARITY:	JSR	INTTY
	HRRI	MSG,PARITO
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	PARITY
	CAIN	AC5,15
	JRST	PRTY1
	CAIN	AC5,12
	JRST	PRTY1
	MOVE	AC6,OFMT		;GET STATUS WORD FOR
				;OUTPUT CHANNEL
	TRO	AC6,1000
	CAIN	AC5, "E"	;SET BIT 26 FOR
			;EVEN PARITY TO 1
	JRST	.+4
	CAIN	AC5, "O"	;CLEAR BIT 26 FOR
	TRZA	AC6, 1000	;ODD PARITY
	JRST	ILLCHR		;ERROR,START@ PARITY
	MOVEM	AC6,OFMT	;SET PARITY BIT

PRTY1:	JSR	INTTY
	HRRI	MSG,PARIT
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	.-5
	CAIN	AC5,15
	JRST	INDEN
	CAIN	AC5,12
	JRST	INDEN
	MOVE	AC6,IFMT
	TRO	AC6,1000
	CAIN	AC5, "E"
	JRST	.+4
	CAIN	AC5, "O"
	TRZA	AC6, 1000
	JRST	ILLCHR
	MOVEM	AC6,IFMT

;SETTING DENSITY BITS 27,28

INDEN:	JSR	INTTY
	HRRI	MSG,INDENM
	JSR	TYPE
	INPUT	T,
	JSR	 INCHR	;GET DENSITY CHAR
	JRST	INDEN		;ERROR RETURN
	MOVE	AC6,IFMT		;GET INPUT STATUS WORD
	CAIE	AC5,15
	CAIN	AC5,12
	JRST	.+2
	PUSHJ	P,SETDEN		;SET DENSITY BITS IN AC6
	TRNN	FMT,1			;SKIP IF 1 OR 3 =>ASC IN
	TRO	AC6,14			;BCD IN!
	MOVEM	AC6,IFMT	;SET BITS ON CHANNEL

ODEN:	JSR	INTTY
	HRRI	MSG, ODENM
	JSR	TYPE
	INPUT	T,
	JSR	 INCHR	;GET DEN CHAR
	JRST	ODEN		;ERROR
	MOVE	AC6,OFMT		;GET OUTPUT STATUS WORD
	CAIE	AC5,15
	CAIN	AC5,12
	JRST	.+2
	PUSHJ	P,SETDEN		;
	CAIG	FMT,1			; 0 & 1 => BCD OUT
	TRO	AC6,14			;BCD OUT !
	MOVEM	AC6,OFMT

;TO FIND OUT LOGICAL AND PHYSICAL END OF RECORDS

RECORD:	JSR	INTTY
	HRRI	MSG,RECDM
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	RECORD
	CAIN	AC5,"Y"		;LOGICAL EOR NOT PHYSEOR
	JRST	WHATIS		;
	CAIN	AC5,"N"
	JRST	CDIMG
	CAIE	AC5,12		;LF? LOG EOR=PHSEOR
	CAIN	AC5,15		;CR? LOG EOR=PHSEOR
	JRST	CDIMG		;YES, GO TO NEXT QUESTION
	JRST	ILLCHR
;IF LOGICAL EOR DOES NOT=PHYS EOR, FIND OUT WHAT THE
;EOR OR BOR MARKER IS AND PUT IT IN CONVRT+3.

WHATIS:	MOVE	AC1,RECPTR
	MOVEM	AC1,RECPTR
	MOVNI	AC4,2	;ACCEPT 2 CHARS
	JSR	INTTY
	HRRI	MSG, WHATM
	JSR	TYPE
	INPUT	T,
	JSR	 INCHR
	JRST	WHATIS+1		;BAD CHAR
	CAIE	AC5,15
	CAIN	AC5,12
	JRST	BOR		;NO LOG EOR MARKER
WHAT:	JSR	LEGDIG		;CHECK FOR LEGAL DIGIT
	IDPB	AC5,RECPTR	;AND CONVRT TO OCTAL
	AOJL	AC4,.-7
	MOVEM	AC1,RECPTR
	JRST	CDIMG

BOR:	MOVNI	AC4,2		;2 CHARS FOR BOR
	JSR	INTTY
	HRRI	MSG,BORM
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	WHATIS+1
	CAIE	AC5,15
	CAIN	AC5,12
	JRST	WHATIS		;CRLF,ERROR
	JRST	WHAT		;DO CHECKS OVER

;IS A PHYS RECORD ONE CD IMAGE?

CDIMG:	JSR	INTTY
	HRRI	MSG,CDIMGM
	JSR	TYPE
	INPUT	T,
	JSR	INCHR
	JRST	CDIMG+1
	CAIN	AC5,"Y"
	JRST	BITS
	CAIN	AC5,"N"
	JRST	TAPCON-1	;LOG EOR =PHYS EOR
	CAIE	AC5,12
	CAIN	AC5,15
	JRST	TAPCON-1	;LOG REC =PHYS REC
	JRST	ILLCHR

BITS:	JSR	INTTY
	HRRI	MSG,BITM
	JSR	TYPE
	INPUT	T,
BITS1:	PUSHJ	P,DECIN
	MOVEM	AC7,BITSTR
	JSR	INTTY
	HRRI	MSG,WORDM
	JSR	TYPE
	INPUT	T,
WORD1:	PUSHJ	P,DECIN
	IMUL	AC7,BITSTR	;NO BITS/WORD * NO WDS/REC
	IDIVI	AC7,6		;SET UP CHAR CNT ACCORDING
	MOVEM	AC7,BITSTR		;TO HOW MANY BITS

	JRST	TAPCON

LEGDIG:	0
	CAIE	AC5,"."
	CAIN	AC5,"/"
	JRST	ILLCHR
	CAIL	AC5,60
	CAILE	AC5,67
	JRST	ILLCHR
	SUBI	AC5,60
	JRST	@LEGDIG

SETDEN:	TRZ	AC6,607		;CLEAR DINSITY AND MODE BITS
	CAIN	AC5,"5"		;556 BPI,DENSITY BITS=00
	TRO	AC6,7		;SET MODE BITS
	CAIN	AC5,"8"		;800 BPI DENSITY BITS=11
	TRO	AC6,607		;SET DEN AND MODE BITS
	CAIN	AC5,15		;556 BPI
	TRO	AC6,7		;SET MODE BITS
	CAIN	AC5,12	
	TRO	AC6,7		;MODE BITS
	CAIN	AC5,"2"		;200 BPI DENSITY BITS=01
	TRO	AC6,207		;SET DEN AND MODE BITS
	TRZN	AC6, 7		;SKIP IF MODE BITS SET, CLEAR.
	JRST	ILLCHR		;OTHERWISE ILLEGAL CHAR
	POPJ	P,		;RETURNS WITH STATUS IN AC6
				; (MODE BITS =0)


IOINIT:	RELEAS	TAPE,
	RELEAS	I,
	RELEAS	OU,
	MOVE	AC10,IFMT
	HRRM	AC10,.+1
	INIT	I,
	SIXBIT	/INN/
	XWD	0,INBUF
	JRST	MSG1

	MOVE	AC10,OFMT
	HRRM	AC10,.+1
	INIT	OU,
	SIXBIT	/OUT/
	XWD	OUTBUF,0
	JRST	MSG3
	POPJ	P,


INCHR:	0
	MOVE	16,INCHR
	ILDB	AC5,TIBUF+1	;GET A CHAR
	CAIN	AC5,"#"
	JRST	1(16)
	CAIGE	AC5,56		;BETWEEN . AND 9.
	CAIG	AC5,75
	JRST	1(16)		;LEGAL DIGIT
	CAIGE	AC5,101
	CAIG	AC5,132
	JRST	1(16)		;LEGAL LETTER
	CAIE	AC5,15
	CAIN	AC5,12
	JRST	1(16)
ILLCHR:	JSR	INTTY		;BAD CHAR
	HRRI	MSG,ILCHM
	JSR	TYPE
	JRST	(16)		;ERROR RETURN
;MESSAGES TO TTY.

STAND:	ASCIZ !
 STANDARD I/O FORMAT? !
FILEO:	ASCIZ /
OUTPUT FILE NAME:  /
FILEI:	ASCIZ/
INPUT FILE NAME:  /
PARIT:	ASCIZ /
 PARITY IN:  /
INDENM:	ASCIZ /
 DENSITY IN:  /
ODENM:	ASCIZ /
 DENSITY OUT:  /
RECDM:	ASCIZ /
DO YOU WISH TO SPECIFY RECORD MARK?  /
WHATM:	ASCIZ /
 LOGICAL EOR IS:  /
BORM:	ASCIZ /
 LOGICAL BOR IS:  /
CDIMGM:	ASCIZ /
DO YOU WISH TO SPECIFY BYTES PER RECORD?  /
BITM:	ASCIZ /
 NUMBER OF BITS PER BYTE:  /
WORDM:	ASCIZ /
 MAX NUMBER BYTES PER LOGICAL RECORD: /
ASTRM:	ASCIZ /
 * /
TAPCNM:	ASCIZ /
 TAPE CONTROL SECTION

/
ILCHM:	ASCIZ /
 ILLEGAL CHARACTER IN INPUT STRING.
/
DEVN:	ASCIZ !
 I/0 DEVICE NOT AVAILABLE.
!
PARITO:	ASCIZ /
PARITY OUT:  /

REINIT:	SETZB	AC7,BITSTR		;CLR WD&BITSIZE
	HRRI	AC10,NAMPTR
	HRLI	AC10,NAMPTS		;BLK TRANSFER POINTERS
	BLT	AC10,NAMPTR+3
	MOVEI	AC10,32
	MOVEM	AC10,RECMK
	SETZB	AC10,IFLNME
	HRRI	AC10,IFLNME+1	;TO
	HRLI	AC10,IFLNME	;FROM
	BLT	AC10,IFLNME+13	;CLEAR FILE NAME STORAGE
	POPJ	P,


	SETOB	AC7,BITSTR
TAPCON:	JSR	INTTY
	HRRI	MSG, TAPCNM
	JSR	TYPE
ASTYPE:	JSR	INTTY
	HRRI	MSG, ASTRM
	JSR	TYPE
	INPUT	T,
READSW:	JSR	INCHR
	JRST	TAPCON		;ERROR RETURN
	CAIN	AC5,"O"		;OUT
	JRST	OUTSW
	CAIN	AC5, "I"		;INN
	JRST	INSW
	CAIN	AC5,"S"		;START
	JRST	GO
	CAIN	AC5,"R"		;RESTART
	JRST	START		;REIDENTIFICATION
	JRST	ILLCHR

;SET UP TAPE MOVE FUNCTIONS ACCORDING TO OUTPUT SWITCHES

OUTSW:	ILDB	AC5,TIBUF+1
	CAIE	AC5,"U"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,"T"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,":"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,"/"
	JRST	BADCHR
	MOVE	0,[SIXBIT/OUT/]		;INITIALIZE OUT PUT TAPE
	MOVEM	0, MTANAM	;FOR TAPE MOVE
	JRST	SWITCH		;GO READ SWITCHES

;INPUT TAPE MOVE FUNCTIONS
INSW:	ILDB	AC5, TIBUF+1
	CAIE	AC5,"N"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,"N"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,":"
	JRST	BADCHR
	ILDB	AC5, TIBUF+1
	CAIE	AC5,"/"
	JRST	BADCHR
	MOVE	0,[SIXBIT/INN/]		;SET INN NAME
	MOVEM	0,MTANAM

SWITCH:	RELEAS	OU,
	RELEAS	I,
	RELEAS	TAPE,
	INIT	TAPE,0
MTANAM:	0
	0
	JRST	DEVNA		;DEVICE NOT AVAILABLE
	ILDB	AC5, TIBUF+1	;GET SWITCH
	CAIN	AC5,"#"
	PUSHJ	P,DECIN
	CAIN	AC5,"W"
	JRST	REWIND
	CAIN	AC5,"U"
	JRST	RANDU
	CAIN	AC5,"A"
	JRST	AFILE
	CAIN	AC5,"B"
	JRST	BFILE
	CAIN	AC5,"D"
	JRST	ARECD
	CAIN	AC5,"P"
	JRST	BRECD
	CAIN	AC5,"T"
	JRST	EOT
BADCHR:	HRRI	MSG, ILCHM	;ONE SWITCH AT A TIME
	JSR	TYPE
	JRST	ASTYPE		;RETURN TO TAPE CONTROL SECT.

REWIND:	MTAPE	TAPE, 1
	MTAPE	TAPE,0
	JRST	ASTYPE

RANDU:	MTAPE	TAPE, 11
	MTAPE	TAPE,0
	JRST	ASTYPE

AFILE:	MOVE	AC5,NUMBER
AFIL:	MTAPE	TAPE,16		;ADVANCE A FILE
	MTAPE	TAPE,0
	SOJG	AC5,AFIL
	JRST	ASTYPE

;BACKSPACE FILE

BFILE:	MOVE	AC5,NUMBER
BFIL:	MTAPE	TAPE, 17		;BACKSPACE A FILE
	MTAPE	TAPE, 0		;WAIT
	STATO	TAPE, 4000	;BOT?
	SOJG	AC5, BFIL		;NO, DECREMENT FILE COUNT
	STATO	TAPE, 4000	;BOT OR FINISHED?
	MTAPE	TAPE, 16		;NOT BOT SKIP OVER FILE MARK.
	MTAPE	TAPE,0
	JRST	ASTYPE
ARECD:	MOVE	AC5,NUMBER
AREC:	MTAPE	TAPE, 6
	MTAPE	TAPE,0
	SOJG	AC5,AREC
	JRST	ASTYPE

BRECD:	MOVE	AC5,NUMBER
BREC:	MTAPE	TAPE, 7		;BACKSPACE ONE RECORD
	MTAPE	TAPE, 0		;WAIT
	STATO	TAPE, 4000	;BOT?
	SOJG	AC5, BREC		;NO,FINISHED?
	JRST	ASTYPE



EOT:	MTAPE	TAPE, 10
	MTAPE	TAPE,0
	JRST	ASTYPE

DEVNA:	JSR	INTTY
	HRRI	MSG,DEVN
	JSR	TYPE
	JRST	ASTYPE

DECIN:	SETZB	AC5,NUMBER
	ILDB	AC5,TIBUF+1		;TTY CHAR
	CAIL	AC5,60
	CAILE	AC5,71			;DIGIT
	JRST	NOTNUM
	SUBI	AC5,60
	ADD	AC5,NUMBER
	IMULI	AC5,12
	MOVEM	AC5,NUMBER
	SETZ	AC5,
	JRST	DECIN+1
NOTNUM:	MOVE	AC7,NUMBER
	IDIVI	AC7,12
	POPJ	P,

GO:	PUSHJ	P,IOINIT
	INBUF	I,1
	OUTBUF	OU,1
	LOOKUP	I,IFLNME
	JRST	MSG2
	ENTER	OU,OFLNME
	JRST	MSG4
	OUTPUT	OU,
	STATZ	OU,740000
	JRST	ERROUT

; 0=> BCD TO BCD, 1=> ASC TO BCD, 2=> BCD TO ASC, 3=> ASC TO ASC IN FMT.

IN:	CAIN	FMT,ASCI		;ASC TO BCD?
	JRST	ASCIN			;YES
	CAIE	FMT,0			;BCD TO BCD
	CAIN	FMT,3			;ASC TO ASC
	JRST	SAME


;BCD TO ASCII CLOSES ON EOF STATUS  OR  EOF CHARACTER


BCDIN:	STATZ	I,20000		;EOF BIT?
	JRST	BFIN
	MOVEI	AC10,6		;6 BIT BYTE
	DPB	AC10,[POINT 6,INBUF+1,11]
	IMULM	AC10,INBUF+2		;CHANGE 1 BYTE TO 6
	INPUT	I,
	STATZ	I,740000		;ERRORS
	JRST	ERRIN

	JUMPN	AC7,CRLF
CONVRT:	JUMPG	AC7,.+2		;ARE TESTING NO. BITS/RECORD
	MOVE	AC7,BITSTR	;RESET NO CHARS/REC
	SOSGE	INBUF+2
	JRST	BCDIN
	SETZ	AC1,
	ILDB	AC1,INBUF+1
	CAME	AC1,RECMK		;RECORD MARK OR GROUPMARK?
	CAMN	AC1,GRPMK
	JRST	CRLF			;YES
	CAMN	AC1,EOFBCD
	JRST	BFIN			;IF EOF CHAR,CLOSE FILE
	CAIN	AC1,0
	JRST	CONVRT
	MOVE	AC1,TAB(AC1)		;GET ASCII CHAR
	PUSHJ	P,OUT		;OUTPUT IT
	SOJE	AC7,CRLF		;INSERT CRLF IF NO CHARS/REC HAS BEEN OUTPUT
	JRST	CONVRT

;ASCII TO BCD IGNORES NULLS, ENTERS EOF CHARACTER AND CLOSES ON EOF 
;STATUS ONLY

ASCIN:	MOVEI	AC10,6
	DPB	AC10,[POINT 6,OUTBUF+1,11]
	IMULM	AC10,OUTBUF+2
	STATZ	I,20000
	JRST	FIN
	INPUT	I,
	STATZ	I,740000
	JRST	ERRIN
	MOVEI	AC10,6
ACONVT:	JUMPG	AC7,.+2
	MOVE	AC7,BITSTR
	SOSGE	INBUF+2
	JRST	DOOUT
	SETZ	AC1,
	ILDB	AC1,INBUF+1
	CAIN	AC1,0			;NULLS?
	JRST	ACONVT			;YES,IGNORE
	CAIN	AC1,32			;^Z => EOF
	JRST	ASCIN
	CAIN	AC1,100			;LOOK FOR NULLS
	JRST	ACONVT
	CAIN	AC1,175			;ALTMODE
	SUBI	AC1,36			;WILL SEND IT TO TAB+77
	CAIN	AC1,15			;IF CR GET NXT CHR
	JRST	EOL
	CAIN	AC1,12
	JRST	ACONVT
	CAIN	AC1,13			;VT
	JRST	EOL
	CAIN	AC1,14			;FF
EOL:	TROA	AC1,77
	SUBI	AC1,40			;CONVERT TO 6BIT
	CAIL	AC1,0			;NON-TRANSLATABLE CHARS
	CAILE	AC1,77			;TRANSLATABLE CHARS
	SETZ	AC1,			;REPLACE NON-TRANSLATABLE CHARS WITH BLANKS
	MOVE	AC1,BTAB(AC1)		;GET BCD CHAR
	CAIN	AC1,32
	JRST	OUTBSP
	PUSHJ	P,OUTB
	JRST	ACONVT

OUTB:	SOSG	OUTBUF+2
	PUSHJ	P,OUTPTB
	IDPB	AC1,OUTBUF+1
	POPJ	P,

OUTPTB:	MOVEI	AC10,6
	DPB	AC10,[POINT 6,OUTBUF+1,11]
	IMULM	AC10,OUTBUF+2
	OUTPUT	OU,
	STATZ	OU,740000
	JRST	ERROUT
	POPJ	P,

;DEPOSIT EOR CHARACTER OR ELSE OUTPUT RECORD BUT NOT BOTH

DOOUT:	JUMPN	AC7,ASCIN+3		;OUTPUT ONE REC FOR EVERY INPUT
	PUSHJ	P,OUTPTB		;HERE
	JRST	ASCIN


;IF OUTBUF NOT FULL DEPOSIT CHAR& CONT. IF FULL OUTPUT & IGNORE CHAR

OUTBSP:	SOSG	OUTBUF+2
	JRST	.+3
	IDPB	AC1,OUTBUF+1
	JRST	ACONVT
	PUSHJ	P,OUTPTB
	JRST	ACONVT





;SAME READS IN ASC OR BCD FILES AND TRANSFERS THEM WITHOUT TRANSLATION
;TO ANOTHER CODE

SAME:	STATZ	I,20000		;EOF
	JRST	FIN
	INPUT	I,
	STATZ	I,740000	;ERRORS
	JRST 	ERRIN
SAME1:	SOSGE	INBUF+2
	JRST	SAME
	SETZ	AC1,
	ILDB	AC1,INBUF+1
	PUSHJ	P,OUT
	JRST	SAME1

OUT:	SOSG	OUTBUF+2
	PUSHJ	P,OUTPT
	IDPB	AC1,OUTBUF+1
	POPJ	P,

;PUTS EOF CHARACTER IN 1ST WORD OF NEW BUFFER AND CLOSES
AFIN:	MOVE	AC1,EOFBCD		
	PUSHJ	P,OUTB
	JRST	FIN
;FILLS BUFFER WITH NULLS AND CLOSES
BFIN:	MOVEI	AC1,0
	SOSG	OUTBUF+2
	JRST	FIN
	IDPB	AC1,OUTBUF+1
	JRST	BFIN

IGNORE:	IBP	OUTBUF+1	;INC BYTE PTR
	JRST	ACONVT


OUTPT:	OUTPUT	OU,
	STATZ	OU,740000
	JRST	ERROUT
	POPJ	P,

CRLF:	MOVEI	AC1,15
	PUSHJ	P,OUT
	MOVEI	AC1,12
	PUSHJ	P,OUT
	JRST	CONVRT

FIN:	CLOSE	I,
	CLOSE	OU,
	JRST	ASTYPE
	CALL	[SIXBIT /EXIT/]

ERRIN:	JSR	INTTY
	HRRI	MSG,ERIN
	JSR	TYPE
	STATZ	I,400000		;IMPROPER MODE
	JRST	IMODE
	STATZ	I,200000		;PARITY
	JRST	IPAR
	STATZ	I,100000		;DATA ERROR
	JRST	IDATA
	STATZ	I,40000
	JRST	IBLOCK			;BLOCK TOO LARGE
	CALL	[SIXBIT /EXIT/]

ERROUT:	JSR	INTTY
	HRRI	MSG,EROUT
	JSR	TYPE
	STATZ	OU,400000
	JRST	IMODE
	STATZ	OU,200000
	JRST	IPAR
	STATZ	OU,100000
	JRST	IDATA
	STATZ	OU,40000
	JRST	IBLOCK
	CALL	[SIXBIT /EXIT/]

INTTY:	0
	INIT	T,1
	SIXBIT	/TTY/
	XWD	TOBUF,TIBUF
	JRST	.-3
	INBUF	T,1
	OUTBUF	T,2
	JRST	@INTTY

TYPE:	0
	HRLI	MSG,440700
	ILDB	AC3,MSG
	JUMPE	AC3,FINTTY
	SOSG	TOBUF+2
	OUTPUT	T,
	IDPB	AC3,TOBUF+1
	JRST	TYPE+2
FINTTY:	CLOSE	T,
	JRST	@TYPE

IMODE:	JSR	INTTY
	HRRI	MSG,MSG5
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

IPAR:	JSR	INTTY
	HRRI	MSG,MSG6
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

IDATA:	JSR	INTTY
	HRRI	MSG,MSG7
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

IBLOCK:	JSR	INTTY
	HRRI	MSG,MSG10
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

MSG1:	JSR	INTTY
	HRRI	MSG,MSG1A
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

MSG2:	JSR	INTTY
	HRRI	MSG,MSG2A
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]

MSG3:	JSR	INTTY
	HRRI	MSG,MSG3A
	JSR	TYPE
	CALL	[SIXBIT /EXIT/]
MSG4:	JSR	INTTY
	HRRI	MSG,MSG4A
	JSR	TYPE
	CALL	[SIXBIT/EXIT/]

MSG1A:	ASCIZ	/
INPUT DEVICE NOT AVAILABLE.
/
MSG2A:	ASCIZ	/
NO INPUT FILE NAMED.
/
MSG3A:	ASCIZ	/
OUTPUT DEVICE NOT AVAILABLE.
/
MSG4A:	ASCIZ	/
NO OUTPUT FILE NAMED.
/
MSG5:	ASCIZ	/
IMPROPER MODE.
/
MSG6:	ASCIZ	/
PARITY ERROR.
/


MSG7:	ASCIZ	/
DATA ERROR.
/
MSG10:	ASCIZ	/
BLOCK TOO LARGE.
/
EROUT:	ASCIZ	/
OUTPUT ERROR.
/

ERIN:	ASCIZ /
INPUT ERROR.
/
CODESI:	ASCIZ /
INPUT CODE:  /
CODESO:	ASCIZ /
OUTPUT CODE:  /
IFLNME:	OCT	0,0,0,0
OFLNME:	OCT	0,0,0,0

INBUF:	BLOCK 3
OUTBUF:	BLOCK 3
TIBUF:	BLOCK 3
TOBUF:	BLOCK 3

TAB:	EXP	60,61,62,63,64,65,66,67,70,71,60,43,140,47,75,42
	EXP	40,57,123,124,125,126,127,130,131,132,41,54,45,137,76
	EXP	77,55,112,113,114,115,116,117,120,121,122,141,44,52
	EXP	51,73,76,46,101,102,103,104,105,106,107,110,111,77,56
	EXP	74,50,53,41



BTAB:	EXP	20,52,20,20,53,20,60,14,34,74
	EXP	54,60,33,40,73,21,12,01,02,03
	EXP	04,05,06,07,10,11,20,20,20,20
	EXP	20,72,14,61,62,63,64,65,66,67
	EXP	70,71,41,42,43,44,45,46,47,50
	EXP	51,22,23,24,25,26,27,30,31,20
	EXP	20,20,20,32

NAMPTR:	POINT 6,OFLNME-1,35
EXTPTR:	POINT 6,OFLNME,35
INMPTR:	POINT 6,IFLNME-1,35
IEXPTR:	POINT 6,IFLNME,35
RECPTR:	POINT 3,RECMK, 29
BITPTR:	POINT 3,BITSTR,17
BITSTR:	0
IFMT:	1014
OFMT:	0
RECMK: 134
EOFBCD:	134
GRPMK:	134
NAMPTS: POINT 6,OFLNME-1,35
EXTPTS: POINT 6,OFLNME,35
INMPTS:	POINT 6,IFLNME-1,35
IEXPTS:	POINT 6,IFLNME,35
RECPTS: POINT 3,RECMK,29
BITPTS: POINT 3,BITSTR,17
IFMTS:	1014
OFMTS:	0
NUMBER:	0

PDLST: BLOCK 12


	END START