Google
 

Trailing-Edge - PDP-10 Archives - LCG_Integration_Tools_Clearinghouse_T20_v7_30Apr86 - tools/10backup/c36.mar
There are 8 other files named c36.mar in the archive. Click here to see a list.
	.title	C36	DEC-10 36 Bit Conversion Routines
	.ident	'C36 v1.0'
;
; This module is part of 10BACKUP - a program to read DECsystem-10
; BACKUP tapes in INTERCHANGE mode on a VAX.
;
; The source modules that make up the 10BACKUP program are:-
;
;	10BACKUP.BAS	the main line program.
;	BIO.BAS		contains tape and file IO routines.
;	BUR.MAR		is a set of macro utility routines.
;	C36.MAR		contains 36 bit conversion routines.
;	BMS.MSG		contains the error message definitions.
;	10BACKUP.RNH	Runoff input to build the help library.
;
;
;	Each DEC-10 36 bit word is written to tape as five bytes.
; The fifth byte uses only the low 4 bits. To compound problems
; the five bytes are written on the tape in the reverse order to
; how the VAX reads them.
;	For ascii information this means that the bits are set
; up in the following manner:-
;
;	    4	     3	      2	       1	0
; Char:  xxxx555x 44445555 33333444 22222233 11111112
;  Bit:  xxxx210x 32106543 43210654 54321065 65432106
;
;
;
; C36_UNPACK is a routine to unpack DEC-10 blocks into binary
; form ready for further processing. Each 5 byte DEC-10 word
; is converted into a sign extended quadword. This unpacking
; assumes the tape is written in TM10 format as documented on
; page 6-18 of our ancient Hardware Reference Manual (DEC-10-XSRMA-A-D).
; Other drives may produce slightly different formats and
; require a different version of Unpack.
;
; Binary map (before unpacked):-
;
;	    4	     3	      2	       1	0
;	          11       11111111 22222222 33333322
;  Bit:  xxxx3210 10987654 98765432 76543210 54321098
;
; Called via:  CALL C36_UNPACK( WORD_COUNT, WORDS(), QUAD_RESULT() )
;
	.psect	$code,pic,shr,nowrt,long
;
	.entry	c36_unpack,^M<R3,R4,R5,R6,R7>

	movl	4(AP),R5			;Number of DEC-10 words.
	bleq	50$				;If none then finished.
	movl	8(AP),R4			;Address of input buffer.
	movl	12(AP),R3			;Address of output buffer.
	movzbl	#4,R6				;Constant value #4.
	movzbl	#28,R7				;Constant value #28.
;
10$:	extv	R6,R6,(R4),R1			;Get sign extended hi order.
	movb	(R4)+,-(SP)			;Get hi byte.
	movb	(R4)+,-(SP)			; next byte.
	movb	(R4)+,-(SP)			; and next.
	movb	(R4)+,-(SP)			; and next.
	movb	(R4)+,R0			;Get lo order 4 bits.
	insv	(SP)+,R6,R7,R0			;Insert next 28 bits.
	movq	R0,(R3)+			;Store result.
;
	sobgtr	R5,10$				;Do for all words.
;
50$:	ret					;Return to caller.
;
;
;
;
; C36_CHKSUM is a routine to compute the check sum for a
; block of unpacked DEC-10 words. The resultant check sum
; is a sign extended quadword.
;
; Called via:  CALL C36_CHKSUM( WORD_COUNT, WORDS(), CHECK_SUM )
;
	.psect	$code,pic,shr,nowrt,long
;
	.entry	c36_chksum,^M<R3,R4,R5,R6,R7>

	clrq	R0				;Initialize check sum.
	movl	4(AP),R5			;Number of DEC-10 words.
	bleq	50$				;If none then finished.
	movl	8(AP),R4			;Address of input buffer.
	movl	12(AP),R3			;Address of check sum output.
	movzbl	#1,R6				;Constant value - #1.
	movzbl	#4,R7				;Constant value - #4.
;
10$:	addl	(R4)+,R0			;Add in low order.
	adwc	(R4)+,R1			;Add in hi order.
	ashq	R6,R0,R0			;Move to left one pos.
	bbc	R7,R1,20$			;Did we move a set bit out?
	bisb	R6,R0				;Yup, put it back in.
20$:	extv	#0,R7,R1,R1			;Sign extend hi result.
;
	sobgtr	R5,10$				;Do for all words.
;
50$:	movq	R0,(R3)				;Pass back result.
	ret					;Return to caller.
;
;
;
;
; C36_HFWD is a routine to extract the two half words from an unpacked
; DEC-10 binary word.
;
; Called via:  CALL C36_HFWD( WORD, LEFT_RESULT, RIGHT_RESULT )
;
	.psect	$code,pic,shr,nowrt,long
;
	.entry	c36_hfwd,^M<>

	movq	@4(AP),R0			;Get DEC-10 word.
;
	extzv	#18,#18,R0,@8(AP)		;Return left half.
	bicl3	#^XFFFC0000,R0,@12(AP)		;Return right half.
;
	ret					;Return to caller.
;
;
;
; C36_ASCII is a routine to extract the ascii characters from a
; block of unpacked DEC-10 words.
;
; Ascii character map (before unpacked):-
;
;	    4	     3	      2	       1	0
; Char:  xxxx555x 44445555 33333444 22222233 11111112
;  Bit:  xxxx210x 32106543 43210654 54321065 65432106
;
; Ascii character map (unpacked):-
;
;	    4	     3	      2	       1	0
; Char:  xxxx1111 11122222 22333333 34444444 5555555x
;  Bit:  xxxx6543 21065432 10654321 06543210 6543210x
;
;
; Called via:  CALL C36_ASCII( WORD_COUNT, WORDS(), ASCII_RESULT() )
;
	.psect	$code,pic,shr,nowrt,long
;
	.entry	c36_ascii,^M<R3,R4,R5,R6,R7>

	movl	4(AP),R5			;Number of DEC-10 words.
	bleq	50$				;If none then already finished.
	movl	8(AP),R4			;Address of input buffer.
	movl	12(AP),R3			;Address of output buffer.
	movzbl	#^X80,R6			;Constant value - #^X80.
	movzbl	#7,R7				;Constant value - #7.
;
10$:	movq	(R4)+,R0			;Get characters.
	extzv	#29,R7,R0,R1			;Get first char.
	movb	R1,(R3)+			;Store first char.
;
	rotl	#10,R0,R0			;Position second char.
	bicb3	R6,R0,(R3)+			;Store second char.
;
	rotl	R7,R0,R0			;Position third char.
	bicb3	R6,R0,(R3)+			;Store third char.
;
	rotl	R7,R0,R0			;Position fourth char.
	bicb3	R6,R0,(R3)+			;Store fourth char.
;
	rotl	R7,R0,R0			;Position fifth char.
	bicb3	R6,R0,(R3)+			;Store fifth char.
;
	sobgtr	R5,10$				;Do until no more words.
;
50$:	ret					;Return to caller.
;
;
;
; C36_SIXBIT is a routine to extract the sixbit characters from a
; block of unpacked DEC-10 words.
;
; Sixbit character map (before unpacked):-
;
;	    4	     3	      2	       1	0
; Char:  xxxx6666 55555566 33444444 22223333 11111122
;  Bit:  xxxx3210 54321054 10543210 32105432 54321054
;
; Sixbit character map (unpacked):-
;
;	    4	     3	      2	       1	0
; Char:  xxxx1111 11222222 33333344 44445555 55666666
;  Bit:  xxxx5432 10543210 54321054 32105432 10543210
;
;
; Called via:  CALL C36_SIXBIT( WORD_COUNT, WORDS(), SIXBIT_RESULT() )
;
	.psect	$code,pic,shr,nowrt,long
;
	.entry	c36_sixbit,^M<R3,R4,R5,R6,R7>

	movl	4(AP),R5			;Number of DEC-10 words.
	bleq	50$				;If none then already finished.
	movl	8(AP),R4			;Address of input buffer.
	movl	12(AP),R3			;Address of output buffer.
	movzbl	#6,R6				;Constant value - #6.
	movzbl	#32,R7				;Constant value - #32.
;
10$:	movq	(R4)+,R0			;Get characters.
	extzv	#30,R6,R0,R1			;Get first sixbit.
	addb3	R7,R1,(R3)+			;Store char.
;
	extzv	#24,R6,R0,R1			;Get second sixbit.
	addb3	R7,R1,(R3)+			;Store char.
;
	extzv	#18,R6,R0,R1			;Get third Sixbit.
	addb3	R7,R1,(R3)+			;Store char.
;
	extzv	#12,R6,R0,R1			;Get fourth Sixbit.
	addb3	R7,R1,(R3)+			;Store char.
;
	extzv	R6,R6,R0,R1			;Get fifth Sixbit.
	addb3	R7,R1,(R3)+			;Store char.
;
	bicb	#^XC0,R0			;Get sixth Sixbit.
	addb3	R7,R0,(R3)+			;Store char.
;
	sobgtr	R5,10$				;Do until no more words.
;
50$:	ret					;Return to caller.
;
;
;
;
	.end