Google
 

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

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

	GO	FILEID		;IDENTIFY OUTPUT FILE

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

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

	MOVEM	BYTE,C11SUM#	;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 ?

C11LPA:	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,SRTBLK	;BC=6='S PDP-11 START BLOCK
C11LPB:	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
	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

C11DATA: 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,C11DATA	;LOOP FILLING BUFFER

C11DO:	GO	PUTESP		;LINE STARTS WITH "E" & "SPACE"
	GO	C11CNV		;ASCIIZE AND OUTPUT BUFFER

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

	GO	CK11SUM		;VERIFY CHECKSUM
	JRST	C11LP		;GET NEXT BLOCK
CK11SUM: GO	G11BYT		;GET CHECKSUM BYTE
	JRST	ERR4		;EOF ?
	MOVE	T1,C11SUM	;VERIFY CHECKSUM RESULT
	TRNN	T1,377		;SHOULD BE 8 BITS OF 0
	RTN
	JRST	ERR23		;CHECKSUM ERROR ?

G11WD:	GO	G11BYT		;GET RH BYTE
	JRST	ERR4		;EOF ?
	MOVEM	BYTE,BYTESV#	;SAVE
	GO	G11BYT		;GET LH BYTE
	JRST	ERR4		;EOF ?
	MOVE	T1,BYTE
	LSH	T1,8		;POSITION LH BYTE
	IOR	T1,BYTESV	;INCLUDE RH BYTE
	RTN

G11BYT:	AOS	FB		;ADVANCE FILE BYTE
	ANDI	FB,3		;(MOD 4)
	JUMPN	FB,G11BY2	;IF NOT NEW WORD JUST FETCH BYTE
	GO	RINP		;GET NEXT 36 BIT WORD
	RTN			;END OF FILE

G11BY1:	MOVEM	CHR,CHRSAV#
	TLNN	CHR,(6B2)	;TEST FOR JUNK IN EITHER HALF
	TRNE	CHR,6B20
	JRST	ERR24

G11BY2:	LDB	BYTE,PTRTAB(FB)	;GET PROPER 8 BIT BYTE
	ADDM	BYTE,C11SUM	;ACCUMULATE TO CHECKSUM
	JRST	CPOPJ1		;SKIP RETURN

PTRTAB:	POINT	8,CHRSAV,17	;8 BIT BYTE PICKUP POINTERS
	POINT	8,CHRSAV,9
	POINT	8,CHRSAV,35
	POINT	8,CHRSAV,27

SRTBLK:	GO	CK11SUM		;VERIFY CHECKSUM
	MOVE	T1,ADR11
	MOVEM	T1,B11ADR	;SETUP START ADDRESS
	SETZM	B11CNT		;START HAS 0 DATA WORD COUNT

	GO	PUTESP
	GO	C11CNV		;ASCIIZE AND OUTPUT

	JRST	C11DON		;COMPLETED
PUTESP:	MOVEI	CHR,"E"		;LINE STARTS WITH "E" & "SPACE"
	GO	PUT1
	MOVEI	CHR," "
	GO	PUT1
	RTN

C11CNV:	MOVE	CHR,B11CNT
	MOVEM	CHR,C11CKS#	;INIT ASCIIZED CHECKSUM
	GO	PUT11		;OUTPUT ASCIIZED WORD COUNT

	GO	PUTCMA		;WC,ADR SEPARATOR

	MOVE	CHR,B11ADR	;OUTPUT ASCIIZED BLOCK ADDRESS
	ADDM	CHR,C11CKS
	GO	PUT11

	GO	PUTCMA		;COMPLETE WC,ADR,

	SETZM	T2
	MOVE	T1,B11CNT
	ANDI	T1,377		;STRIP HI ADDRESS BITS
C11CLP:	SOJL	T1,C11CDN	;FINISHED ALL DATA WORDS ?

	MOVE	CHR,B11DAT(T2)	;GET 16 BIT WORD
	ADDM	CHR,C11CKS	;ADD TO CHECKSUM
	GO	PUT11
	GO	PUTCMA		;FINISH WITH COMMA
	AOJA	T2,C11CLP	;LOOP & INCREMENT DATA ADDRESS

C11CDN:	MOVN	CHR,C11CKS	;NEGATE CHECKSUM
	ANDI	CHR,177777	;STRIP BACK TO 16 BITS
	SKIPE	FLAG8
	ANDI	CHR,7777	;PDP-8, 12 BIT CHECKSUM
	GO	PUT11
	GO	PUTCRF		;CR/LF
	RTN
PUT11:	MOVEI	CNT,3		;3 ASCII CHAR PER 16 BITS
	HRLZ	CHR1,CHR
	TLNN	CHR1,-1		;THIS WORD ALL  ZEROS ?
	RTN			;YES, DON'T OUTPUT

	GO	PUTS11		;SUPPRESS LEADING ZEROS

PUT11X:	SETZM	CHR
	ROTC	CHR,6		;RIGHT JUSTIFY CHAR IN CHR
	CAIN	CHR,75
	JRST	.+6		;LEAVE 75 ALONE
	CAIN	CHR,76
	JRST	.+4		;LEAVE 76 ALONE
	CAIN	CHR,77
	JRST	.+2		;LEAVE 77 ALONE
	TRO	CHR,100		;SET BIT 7 FOR ASCIIZE
	GO	PUT1		;PUT CHAR IN BUFFER
	SOJG	CNT,PUT11X	;ALL CHARS DONE ?
	RTN			;YES

C11SUM:	0
ADR11:	0
B11ADR:	0
B11CNT:	0
B11DAT:	BLOCK	AWC11
	0
	0
	0
	0
	0
	0
	0
	0
ERR20:	MOVEI	[ASCIZ/
CONSTANT 1 ERROR/]
	JRST	ERRX

ERR21:	MOVEI	[ASCIZ/
CONSTANT 0 ERROR/]
	JRST	ERRX

ERR22:	MOVEI	[ASCIZ/
BYTE COUNT ERROR/]
	JRST	ERRX

ERR23:	MOVEI	[ASCIZ/
FILE CHECKSUM ERROR/]
	JRST	ERRX

ERR24:	MOVEI	[ASCIZ/
WORD NOT DOUBLE 16 BIT FORMAT ERROR/]
	JRST	ERRX