Google
 

Trailing-Edge - PDP-10 Archives - klad_sources - klad.sources/cnvrt8.mac
There are no other files named cnvrt8.mac in the archive.
SUBTTL	PDP-8 FILE CONVERSION
S

CNVRT8:	MOVE	FILNAM		;INITIALIZE FILE NAMES
	MOVEM	INNAME
	MOVEM	OUTNAM
	MOVE	[SIXBIT/BIN/]
	SKIPE	FILEXT
	MOVE	FILEXT
	MOVEM	INNAME+1
	MOVE	[SIXBIT/A8/]
	MOVEM	OUTNAM+1
	MOVEI	13		;INPUT 36 BIT BYTES
	MOVEM	INBLK
	GO	ININIT		;INITIALIZE INPUT/OUTPUT

	GO	FILEID		;IDENTIFY FILE

C81:	SETZB	G8DC,C8BIN#

	GO	G8CHR		;GET 8 CHAR
	JUMPE	CHR,.-1		;IGNORE 0'S
	CAIE	CHR,200		;IS IT LEADER ?
	JRST	ERR80		;NO

	GO	G8WRD		;GET ALL LEADER CHARS
	CAIN	BYTE,20000
	JRST	.-2

	TRZN	BYTE,10000	;FIRST WORD, BETTER BE ADDRESS
	JRST	ERR81		;WASN'T, ERROR

	SETZM	CHECK8#		;CLEAR PDP-8 CHECKSUM
	SETZB	CNT,B11CNT
	MOVEM	BYTE,B8ADR#	;SAVE PDP-8 ADDRESS
	MOVEM	BYTE,B11ADR	;SETUP BLOCK START ADDRESS
	ADDM	G8DC,CHECK8
C82:	GO	G8WRD		;GET NEXT WORD
C821:	CAIN	BYTE,20000	;TRAILER ?
	JRST	C8DON1		;YES, RIM COMPLETION
	TRZE	BYTE,10000
	JRST	C8ADR		;NEW ADDRESS

	MOVEM	BYTE,BYTESV	;SAVE THIS DATA WORD
	MOVEM	G8DC,G8DCSV#	;SAVE ASSOC CHECK ENTRY

	GO	G8WRD		;GET NEXT INPUT WORD
	TRNN	BYTE,30000	;IS THIS DATA ENTRY ?
	SETOM	C8BIN		;YES, PDP-8 FILE IN BIN FORMAT
	TRNN	BYTE,20000	;IS THIS TRAILER ?
	JRST	C822		;NO, LAST ENTRY WAS DATA
	SKIPE	C8BIN		;LAST ENTRY CHECKSUM IF BIN FORMAT
	JRST	C8DONE

C822:	MOVE	G8DCSV
	ADDM	CHECK8		;UPDATE PDP-8 CHECKSUM

	MOVE	BYTESV
	MOVEM	B11DAT(CNT)	;STORE DATA WORD

	AOS	B11CNT		;INCREMENT WORD COUNT
	AOS	CNT		;INCREMENT STORAGE POINTER
	AOS	B8ADR		;INCREMENT PDP-8 ADDRESS

	CAIGE	CNT,40		;FILLED THIS BLOCK ?
	JRST	C821		;NOT YET

C83:	SKIPN	B11CNT		;ANY DATA IN STORAGE
	JRST	C84		;NO

	GO	PUT8SP		;LINE STARTS WITH "8" & "SPACE"

	GO	C11CNV		;ASCIIZE AND OUTPUT

C84:	MOVE	B8ADR		;INIT NEXT BLOCK START ADDRESS
	MOVEM	B11ADR
	SETZB	CNT,B11CNT	;CLEAR COUNTS
	JRST	C821		;BACK FOR NEXT PDP-8 WORD
C8ADR:	ADDM	G8DC,CHECK8
	CAIN	BYTE,B8ADR	;CONSECUTIVE ADDRESSES ?
	JRST	C82		;YES, IGNORE IT THEN

	MOVEM	BYTE,B8ADR	;NO, SETUP NEW ADDRESS
	GO	G8WRD		;GET NEXT DATA WORD
	JRST	C83		;OUTPUT CURRENT BLOCK & SETUP NEXT

C8DONE:	MOVE	G8DC,CHECK8	;GET COMPUTED CHECKSUM
	ANDI	G8DC,7777	;MAKE IT 12 BITS
	MOVE	BYTESV		;GET CHECKSUM FROM FILE
	ANDI	7777		;MAKE 12 BITS
	CAME	G8DC		;DO CHECKSUMS AGREE ?
	JRST	ERR23		;NO, ERROR

C8DON1:	SKIPN	B11CNT		;ANY WORDS IN STORAGE ?
	JRST	C8END		;NO

	GO	PUT8SP		;YES, OUTPUT LAST BLOCK
	GO	C11CNV

C8END:	SETZM	B11CNT		;START HAS 0 WORD COUNT
	SETZM	B11ADR		;NO START ADDRESS
	GO	PUT8SP
	GO	C11CNV		;OUTPUT TRANSFER BLOCK

	JRST	C11DON		;COMPLETED

PUT8SP:	MOVEI	CHR,"8"		;LINE STARTS WITH "8" & "SPACE"
	GO	PUT1
	MOVEI	CHR," "
	GO	PUT1
	RTN
;*GET A PAIR OF PDP-8 CHARS TO FORM ADDRESS OR DATA WORD
S

G8WRD:	SETZ	G8DC,		;CLEAR CHECK
	GO	G8CHR		;GET A CHAR
	LSH	CHR,6		;MAKE HI-BYTE OF 12 BITS
	MOVEM	CHR,BYTE
	TRNE	CHR,20000	;IS CHANNEL 8 ZERO ?
	JRST	G8CH8		;NO

	GO	G8CHR		;GET SECOND CHAR
	TRNE	CHR,300		;ARE CHANNELS 7 & 8 ZERO ?
	JRST	ERR82		;NO, BAD CHAR
	ORM	CHR,BYTE	;MERGE THE TWO CHARS
	RTN			;RETURN WITH 12 BIT WORD

G8CH8:	TRNE	CHR,7700	;ARE CHANNELS 1 TO 6 ZERO ?
	JRST	ERR82		;NO, ERROR
	TRNN	CHR,10000	;YES, CHANNEL 7 ZERO ?
	RTN			;YES, LEADER OR TRAILER
	JRST	G8WRD		;FIELD SET 0, IGNORE IT

;*GET A PDP-8 CHAR
S

G8CHR:	GO	RINP		;GET INPUT CHAR
	JRST	ERR4		;EOF, ERROR
	ADDM	CHR,G8DC	;ADD TO CHECKSUM
	RTN

ERR80:	MOVEI	[ASCIZ/
FIRST NON-ZERO CHAR NOT LEADER CODE/]
	JRST	ERRX

ERR81:	MOVEI	[ASCIZ/
FIRST WORD NOT ADDRESS/]
	JRST	ERRX

ERR82:	MOVEI	[ASCIZ/
UNEXPECTED FILE CHAR/]
	JRST	ERRX