Google
 

Trailing-Edge - PDP-10 Archives - klad_sources - klad.sources/cnvkmc.mac
There are no other files named cnvkmc.mac in the archive.
SUBTTL	KMC11 MICROCODE BINARY TO ASCII SECTION
S

CNVKMC:	MOVE	FILNAM		;INITIALIZE FILE NAMES
	MOVEM	INNAME
	MOVEM	OUTNAM
	MOVE	[SIXBIT/BIN/]
	SKIPE	FILEXT
	MOVE	FILEXT
	MOVEM	INNAME+1
	MOVE	[SIXBIT/KMC/]
	MOVEM	OUTNAM+1
	MOVEI	13		;INPUT IMAGE BINARY, 36 BIT BYTES
	MOVEM	INBLK
	GO	ININIT

	GO	FILEID		;IDENTIFY OUTPUT FILE

	SETOM	FB
KMCLP:	GO	G11BYT		;GET 8 BIT BYTE
	JRST	ERR4		;ILLEGAL EOF ?
	JUMPE	BYTE,KMCLP	;DISCARD NULLS
	CAIN	BYTE,377
	JRST	KMCLP		;DISCARD DELETES

	CAIE	BYTE,1		;VERIFY CONSTANT 1
	JRST	ERR20		;JUNK ?

	MOVEM	BYTE,KMCSUM#	;INIT CHECKSUM

	GO	G11BYT
	JRST	ERR4		;EOF ?
	SKIPE	BYTE		;VERIFY CONSTANT 0
	JRST	ERR21		;JUNK ?

	GO	G11WD		;GET BYTE COUNT
	JUMPE	T1,ERR22	;ZERO BYTE COUNT ?

KMCLPA:	MOVEI	BC,-6(T1)	;GET DATA BYTE COUNT
	JUMPL	BC,ERR22	;LESS THAN 6 ?

	GO	G11WD		;GET ADDRESS
	MOVEM	T1,ADR11#	;SAVE AS BLOCK START ADDRESS
	JUMPE	BC,SRTKMC	;BC=6='S KMC11 START BLOCK

	CAIL	T1,100000	;ADDRESS 100000 OR MORE ?
	JRST	KMCLPC		;YES, KMC D-RAM DATA
				;NO, KMC C-RAM DATA
KMCLPB:	MOVEI	P1,AWC11*2	;SETUP ASCIIZED WORD COUNT
	CAIGE	BC,AWC11*2	;DOES FILE HAVE THAT MANY ?
	MOVE	P1,BC		;NO - USE WHATS IN FILE
	MOVE	P2,P1		;SET COUNT FOR FETCH

	MOVE	T1,ADR11
	LSH	T1,-1		;DIVIDE BY 2
	MOVEM	T1,B11ADR	;SETUP ASCIIZED START ADDRESS
	AOS	P1		;ROUND UP BYTE COUNT
	LSH	P1,-1		;DIVIDE BY 2
	MOVEM	P1,B11CNT	;SETUP ASCIIZED WORD COUNT

	MOVE	BA,[POINT 8,B11DAT,35] ;SETUP ASCIIZED WORD FORMER

	MOVE	T1,[B11DAT,,B11DAT+1]
	SETZM	B11DAT		;CLEAR STORAGE AREA
	BLT	T1,B11DAT+AWC11

	GO	G11BYT		;GET DATA BYTE
	JRST	ERR4		;EOF ?
	DPB	BYTE,BA		;STUFF INTO BUFFER
	TLCE	BA,(POINT 0,0,27) ;SWITCH BYTES
	AOS	BA		;ADVANCE WORD EVERY TWO
	SOJG	P2,.-5		;LOOP FILLING BUFFER

	GO	KMCCNV		;ASCIIZE AND OUTPUT BUFFER

	MOVEI	T1,AWC11	;ADVANCE BLOCK START ADDRESS
	ADDM	T1,ADR11
	SUBI	BC,AWC11*2	;DECREMENT 11 BYTE COUNT TO GO
	JUMPG	BC,KMCLPB	;LOOP TILL ALL OF THIS BLOCK DONE

	GO	CK11SUM		;VERIFY CHECKSUM
	JRST	KMCLP		;GET NEXT BLOCK
KMCLPC:	MOVEI	P1,AWC11	;SETUP ASCIIZED WORD COUNT
	CAIGE	BC,AWC11	;DOES FILE HAVE THAT MANY ?
	MOVE	P1,BC		;NO - USE WHATS IN FILE
	MOVE	P2,P1		;SET COUNT FOR FETCH

	MOVE	T1,ADR11
	SUBI	T1,100000	;SUBTRACT 100000
	MOVEM	T1,B11ADR	;SETUP ASCIIZED START ADDRESS
	MOVEM	P1,B11CNT	;SETUP ASCIIZED WORD COUNT

	MOVE	BA,[POINT 8,B11DAT,35] ;SETUP ASCIIZED WORD FORMER

	MOVE	T1,[B11DAT,,B11DAT+1]
	SETZM	B11DAT		;CLEAR STORAGE AREA
	BLT	T1,B11DAT+AWC11

	GO	G11BYT		;GET DATA BYTE
	JRST	ERR4		;EOF ?
	DPB	BYTE,BA		;STUFF INTO BUFFER
	AOS	BA		;ADVANCE WORD
	SOJG	P2,.-4		;LOOP FILLING BUFFER

	GO	KMCDNV		;ASCIIZE AND OUTPUT BUFFER

	MOVEI	T1,AWC11	;ADVANCE BLOCK START ADDRESS
	ADDM	T1,ADR11
	SUBI	BC,AWC11	;DECREMENT 11 BYTE COUNT TO GO
	JUMPG	BC,KMCLPC	;LOOP TILL ALL OF THIS BLOCK DONE

	GO	CK11SUM		;VERIFY CHECKSUM
	JRST	KMCLP		;GET NEXT BLOCK
SRTKMC:	GO	CK11SUM		;VERIFY CHECKSUM
	MOVE	T1,ADR11
	MOVEM	T1,B11ADR	;SETUP START ADDRESS
	SETZM	B11CNT		;START HAS 0 DATA WORD COUNT

	GO	KMCCNV		;ASCIIZE AND OUTPUT

	JRST	C11DON		;COMPLETED

KMCCNV:	GO	PUTCSP
	GO	C11CNV
	RTN

KMCDNV:	GO	PUTDSP
	GO	C11CNV
	RTN