Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-09 - 43,50466/reccnv.mac
There are 2 other files named reccnv.mac in the archive. Click here to see a list.
;THIS PROGRAM WAS WRITTEN AT WESTERN MICHIGAN UNIVERSITY.
;
	TITLE RECCNV VERSION 1

	SUBTTL PARAMETERS, AC ASIGNS, MEM ASIGNS, ETC.

	EXTERN .JBFF
;	EXTERN USAGE	;IN NGLIB

MESSA:	ASCIZ/
WMU RECORD CONVERSION PROGRAM
/

;PROGRAMMED BY RUSSELL R. BARR - 26 JAN 1973
;	20 DEC 74 - R. BARR - DATE75 PATCHES

	;AC ASSIGNMENTS

FLAGS=7
OUTCLK=10
INCLK=11
NIRCK=12
NORCK=13
LNOUTK=14

	;PARAMETERS

BLANK=40	;40 IS A BLANK

	;MEMORY ASSIGNMENTS

BUFSIZ:	0
INCL:	0
OUTCL:	0
NIRC:	0
NORC:	0
BUFMAJ:	0	;LENGTH OF SET OF OUT RECS
BUFMIN:	0	;NO. OF CHR SO FAR
LNOUT:	0
WORD:	0
RENFLG:	0
	BLKSIZ:	0	;FILLED BY PROG
STFLG:	1	;NO RESTART
IB:	BLOCK 3
ZERO:	BLOCK 4
TMPFIL:	SIXBIT/RECCNV/
	SIXBIT/TMP/
	BLOCK 2
NAME:	ASCIZ/RECCNV/

	;BYTE POINTERS

PNT:	POINT 7,0
OPNT:	POINT 7,0
WPNT:	POINT 6,WORD

	;FLAG ASSIGNMENTS

BMTFLG=1	;RH
LNCFLG=2	;RH
DOTSEN=1	;LH
LBKSEN=2	;LH

	SUBTTL START OF MAIN PROGRAM

START:	RESET
	MOVEI 0,200
	MOVEM 0,BLKSIZ
	SOSGE STFLG
	JRST NOSTRT	;CANT RESTART
	TTCALL 3,MESSA
;	JSA 16,USAGE
;	EXP NAME
INTAX: RETA:	TTCALL 3,MESS4
	MOVEI INFIL
	JSA 16,GTFILE
	JRST INTAX	;ERROR RETURN
	JRST .+5
INFIL:	BLOCK 4
	INIT 0,0
	SIXBIT/DSK/
	XWD IB
	JRST NITERR
	INBUF 0,2
	LOOKUP 0,INFIL
	JRST CANTFI
	HRRZ 0,.JBFF
	HRRM 0,PNT
	ADDI 0,201	;SLOP FOR ZERLUP
	HRRM 0,OPNT
	SOJ 0,
	HRRM 0,OUTLST
OUTTAX: RETB:	TTCALL 3,MESS5
	MOVEI OUTFIL
	JSA 16,GTFILE
	JRST OUTTAX	;ERROR RETURN
	MOVE 0,OUTFIL
	CAME 0,INFIL
	JRST NOREN
	HRRZ 1,OUTFIL+1
	HRRZS INFIL+1
	CAME 1,INFIL+1
	JRST NOREN
	EXCH 0,TMPFIL
	EXCH 1,TMPFIL+1
	SETOM RENFLG
	JRST .+5
OUTFIL:	BLOCK 4
NOREN:	INIT 1,16
	SIXBIT/DSK/
	0
	JRST NITERR
	ENTER 1,OUTFIL
	JRST CANTFO
	MOVE 0,OUTFIL+5
	DEVCHR 0,
	TLNE 0,100	;DECTAPE?
	SOS BLKSIZ	;YES - 177 WORD BUFFERS
SIZTRY:	TTCALL 3,MESS1
	JSA 16,INPTTY
	MOVEM 1,INCL
	TTCALL 3,MESS2
	JSA 16,INPTTY
	MOVEM 1,NIRC	;NO OF INPUT RECS PER
	JSA 16,INPTTY
	MOVEM 1,NORC	;	OUTPUT RECS
	TTCALL 3,MESS3
	JSA 16,INPTTY
	MOVEM 1,LNOUT
	SUBTTL CORE ALLOCATION

	MOVE 0,NIRC
ADDT:	IMUL 0,INCL
	MOVE 1,NORC
	IMUL 1,LNOUT
	MOVEM 1,LNOUTA
	SKIPA
LNOUTA:	0
	CAMLE 0,1
	JRST MATHER
	IDIV 0,NORC
	CAIE 1,
	AOJ 0,
	MOVEM 0,OUTCL
	MOVE 0,LNOUT
	ADDI 0,2
	MOVEM 0,BUFMAJ
	CAILE 0,^D4096	;NO. OF CHRS/OUT REC
	JRST TOOBIG
	IDIVI 0,5
	IDIV 0,BLKSIZ
	CAIE 1,
	AOJ 0,
	IMUL 0,BLKSIZ	;ROUNDED UP WORDS/OUT REC
	HRRM 0,BUFSIZ
	MOVN 2,0
	HRLM 2,OUTLST	;1ST PART
	HRRZ 1,.JBFF
	CAMGE 0,BLKSIZ
	JRST COREOK	;NO STRETCH NEEDED
	HRRM 1,PNT	;LINE POINTER
	ADD 1,0	;LINE

	AOJ 1,		;SLOP FOR ZERLUP
	HRRM 1,OPNT	;OLINE POINTER
	HRRM 1,OUTLST	;OTHER PART
	SOS OUTLST	;ADR-1, REMEMBER?
	ADD 1,0	;OLINE
	AOJ 1,		;SLOP FOR ZERLUP
	CORE 1,		;STRETCH IT
	JRST NOCORE	;OOOPS - ERROR RETURN
	SUBTTL RECORD CONVERSION

COREOK:	MOVE 3,OPNT
	TRZ FLAGS,BMTFLG!LNCFLG
	SETZM BUFMIN
RECST:	SETZB 0,
NINREC:	MOVE 2,PNT
	SETZB LNOUTK,NIRCK
CRL:	CAILE 0,	;CLR ONLY ON CRLF
	SETZ 0,
	SETZB INCLK,NORCK
INCHRS:	CAIN 0,
	JSA 16,INPCHR
	CAIN 0,
	TRZ FLAGS,LNCFLG
	TRNE FLAGS,BMTFLG	;0 IF BUF NOT MT OR AT START
	JUMPL 0,THTSAL
	TRNE FLAGS,LNCFLG	;0 IF LINE NOT COMPLETE OR START
	JUMPL 0,ZERLUP
	TRZ FLAGS,LNCFLG!BMTFLG
	CAILE 0,
	TRO FLAGS,LNCFLG
	CAML INCLK,INCL
	JRST NEWREC
	CAIE 0,		;BLANKS FOR EOF OR CRLF
	MOVEI 1,BLANK
	IDPB 1,2
	AOJ INCLK,
	AOJ LNOUTK,
	JRST INCHRS
NEWREC:	CAIN 0,
	JRST INCHRS
	AOJ NIRCK,
	CAMGE NIRCK,NIRC
	JRST CRL
FILLER:	CAML LNOUTK,LNOUTA
	JRST OUTREC
	MOVEI 1,BLANK
	IDPB 1,2
	AOJA LNOUTK,FILLER
OUTREC:	MOVE 2,PNT
NOUTRC:	SETZ OUTCLK,
MOROUT:	CAML OUTCLK,OUTCL
	JRST BLKS
	ILDB 1,2
	IDPB 1,3
	AOJ OUTCLK,
	JRST MOROUT
BLKS:	CAML OUTCLK,LNOUT
	JRST SPILL
	MOVEI 1,BLANK
	IDPB 1,3
	AOJ OUTCLK,
	JRST BLKS
	SUBTTL OUTPUT PART OF REC CONV

SPILL:	MOVEI 1,15
	IDPB 1,3
	MOVEI 1,12
	IDPB 1,3
	AOJ NORCK,
	MOVE 6,BUFMIN	;NO IN SO FAR
	ADD 6,BUFMAJ	;HOW MANY THIS TIME
	MOVEM 6,BUFMIN	;NO NOW TOTAL
	ADD 6,BUFMAJ	;PROJECTED
	MOVE 4,BUFSIZ
	IMULI 4,5
	CAMG 6,4
	JRST NOUREC
ZERLUP:	SETZ 6,
	MOVEI 1,5
	IDPB 6,3
	SOJG 1,.-1
	HRLZ 1,3
	SETZM @3
	AOJ 3,
	HRR 1,3
	HRRZ 6,OPNT
	ADD 6,BUFSIZ
	BLT 1,-1(6)
	JSA 16,BLKOUT
	SETZM BUFMIN
	MOVE 3,OPNT
	TRO FLAGS,BMTFLG	;MEANS BUFFER EMPTY
NOUREC:	CAMGE NORCK,NORC
	JRST NOUTRC
	JUMPGE 0,RECST
	TRNN FLAGS,BMTFLG
	JRST ZERLUP
THTSAL:	SKIPL RENFLG
	JRST ALLDON
	RENAME 0,ZERO
	JRST RENERR
	RENAME 1,TMPFIL
	JRST RENERR
	CLOSE 0,
	RELEAS 0,
ALLDON:	CLOSE 1,
	RELEAS 1,
	EXIT
	SUBTTL FILE NAME INPUT ROUTINE

GTFILE:	0
	HRRZS FLAGS	;L H FOR GETFILE AND GETWRD
	MOVEM 0,4
	SETZM	2(4)
SEMBLE:	JSA 16,GTWORD
	CAIE 0,":"
	JRST UNCOL
	MOVEM 1,5(4)
	JRST SEMBLE
UNCOL:	CAIE 0,"."
	JRST UNDOT
	MOVEM 1,(4)
	TLO FLAGS,DOTSEN
	JRST SEMBLE
UNDOT:	CAIE 0,"["
	JRST UNLBK
	TLO FLAGS,LBKSEN
	TLNE FLAGS,DOTSEN
	HLLZM	1,1(4)
	TLNN FLAGS,DOTSEN
	MOVEM 1,(4)
	JRST GETOCT
UNLBK:	CAIE 0,12
	JRST SYNTAX
	TLNE FLAGS,DOTSEN
	HLLZM	1,1(4)
	TLNN FLAGS,DOTSEN
	MOVEM 1,(4)
	JRA 16,1(16)		;NORMAL RETURN
SYNTAX:	TTCALL 3,[ASCIZ/
?SYNTAX ERROR/]
	JRA 16,(16)		;ERROR RETURN
GETOCT:	MOVEI 2,6
	SETZ 1,
INOTHR:	TTCALL 4,0
	CAIN 0,"]"
	JRST INOTHR
	CAIN 0,15
	JRST GETBAK
	CAIN 0,","
	JRST PGN
	CAIL 0,"0"
	CAILE 0,"7"
	JRST SYNTAX
	SOJL 2,INOTHR
	SUBI 0,60
	LSH 1,3
	ADD 1,0
	JRST INOTHR
PGN:	HRLZM 1,3(4)
	JRST GETOCT
GETBAK:	TTCALL 4,0
	HRRM 1,3(4)
	JRA 16,1(16)	;NORMAL RETURN
	SUBTTL WORD INPUT SUBROUTINE

GTWORD:	0
	MOVEI 2,6
	MOVE 3,WPNT
	SETZM WORD
GETMO:	TTCALL 4,0
	CAIL 0,"0"
	CAILE 0,"Z"
	JRST DELIM
	CAILE 0,"9"
	CAIL 0,"A"
	JRST LEGCHR
DELIM:	MOVE 1,WORD
	CAIN 0,15
	TTCALL 4,0
	JRA 16,(16)
LEGCHR:	SOJL 2,GETMO
	SUBI 0,40
	IDPB 0,3
	JRST GETMO
	SUBTTL IO ROUTINES

INPTTY:	0
RETINP:	SETZ 1,
INTLP:	TTCALL 4,0
	CAIL "0"
	CAILE "9"
	JRST WRAPIT
	IMULI 1,12
	SUBI 0,60
	ADD 1,0
	JRST INTLP
WRAPIT:	CAIN ","
	JRA 16,(16)
	CAIN 15
	TTCALL 4,0
	CAIN 12
	JRA 16,(16)
	CLRBFI
	TTCALL 3,[ASCIZ/
?ILLEGAL CHARACTER - RETYPE LINE
/]
	JRST RETINP

INPCHR:	0
	SETZ 0,	;ZER HAS ERR CODE 1 HAS CHR
GET:	SOSGE IB+2
	JRST GETBF
	ILDB 1,IB+1
	JUMPE 1,GET
	CAIN 1,15
	JRST GET
	CAIN 1,12
	AOJ 0,	;1 IN ZER MEANS CRLF
	JRA 16,(16)	;ZER MEANS OK
GETBF:	IN 0,
	JRST GET
	STATZ 0,20000
	SOSA 0	;-1 MEANS EOF

	JRST INERTY
	JRA 16,(16)

BLKOUT:	0
	OUTPUT 1,OUTLST
	STATZ 1,740000
	JRST OUTERR
	JRA 16,(16)
OUTLST:	0	;TO BE FILLED IN AT RUN TIME
	0
SUBTTL MISC MESSAGES

MESS1:	 ASCIZ/
HOW MANY CHARACTERS PER EXISTING RECORD? /
MESS2:	 ASCIZ/
WHAT IS THE RATIO OF EXISTING RECORDS TO NEW  E.G. 2,3 ? /
MESS3:	 ASCIZ/
TOTAL LENGTH OF EACH NEW RECORD? /
MESS4:	ASCIZ/
INPUT? /
MESS5:	ASCIZ/
OUTPUT? /
NITERR:	TTCALL 3,[ASCIZ/
?FATAL INIT ERROR/]
	EXIT
CANTFI:	TTCALL 3,[ASCIZ/
?CANT FIND FILE
/]
	JRST RETA
CANTFO:	TTCALL 3,[ASCIZ/
?FATAL ERROR ON ENTER/]
	EXIT
	JRST RETB
INERTY:	TTCALL 3,[ASCIZ/
?FATAL INPUT ERROR/]
	EXIT
OUTERR:	TTCALL 3,[ASCIZ/
?FATAL OUTPUT ERROR/]
	STATZ 1,400000
	TTCALL 3,[ASCIZ/
?OUTPUT DEVICE WRITE LOCK/]
	STATZ 1,2000
	TTCALL 3,[ASCIZ/
?END OF TAPE ON MTA/]
	STATZ 1,40000
	TTCALL 3,[ASCIZ/
?TAPE FULL ON DTA/]
	EXIT
TOOBIG:	TTCALL 3,[ASCIZ/
?OUTPUT RECORD GREATER THAN 4096 CHARACTERS/]
	EXIT
MATHER:	TTCALL 3,[ASCIZ/
?INPUT RECORDS LENGTH, RATIO OR OUTPUT LENGTH ERROR
/]
	JRST SIZTRY
NOCORE:	TTCALL 3,[ASCIZ/
?NOT ENOUGH CORE AVAILABLE FOR CONVERSION/]
	EXIT
NOSTRT:	TTCALL 3,[ASCIZ/
?NO RESTART - TYPE "RUN"/]
	EXIT
RENERR:	CLOSE 0,
	RELEAS 0,
	CLOSE 1,
	RELEAS 1,
	TTCALL 3,[ASCIZ/
?RENAME FAILURE/]
	EXIT

	END START