Trailing-Edge
-
PDP-10 Archives
-
integ_tools_tops20_v7_30-apr-86_dumper
-
tools/10backup_v2_2/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 v2.2'
;
; This module is part of 10BACKUP - a program to read DECsystem-10
; BACKUP tapes in INTERCHANGE mode on a VAX.
;
; This module contains various routines to unpack the 36 bit blocks
; written on the DECsystem-10.
;
; The source modules that make up the 10BACKUP program are:-
;
; 10BACKUP.BAS the main line program.
; BIO.MAR 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 bytes 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. This is a bit hard
; for me to determine without knowing anything about other machines so if
; you do strike problems please let me know (otherwise I will never know
; there is a problem and will never fix it!!).
;
; 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,R8,R9,R10,R11>
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.
cvtbl #-8,R6 ;Constant #-8.
cvtbl #-28,R7 ;Constant #-28.
movaq -(SP),R8 ;Make local storage.
movab 3(R8),R9 ;Local data pointer.
movab 5(R8),R10 ;Local data pointer.
movab 7(R8),R11 ;Local data pointer.
;
10$: movb (R4)+,(R11) ;Position first byte.
rotl R6,(R4),(R9) ;Position second & fourth bytes.
movb (R9),(R10) ;Position third byte.
ashl #4,(R4)+,(R8) ;Position last four bits.
ashq R7,(R8),(R3)+ ;Store with sign extension.
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>
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.
;
10$: addl (R4)+,R0 ;Add in low order.
adwc (R4)+,R1 ;Add in hi order.
ashq #1,R0,R0 ;Move to left one pos.
bbc #4,R1,20$ ;Did we move a set bit out?
bisb #1,R0 ;Yup, put it back in.
;
20$: sobgtr R5,10$ ;Do for all words.
;
50$: movl R0,(R3)+ ;Pass back lo result.
extv #0,#4,R1,(R3) ;Sign extend hi 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>
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.
;
10$: ashq #3,(R4)+,R0 ;Get the five characters.
bicb3 R6,R1,(R3)+ ;Store first char.
;
rotl #7,R0,R0 ;Position second char.
bicb3 R6,R0,(R3)+ ;Store second char.
;
rotl #7,R0,R0 ;Position third char.
bicb3 R6,R0,(R3)+ ;Store third char.
;
rotl #7,R0,R0 ;Position fourth char.
bicb3 R6,R0,(R3)+ ;Store fourth char.
;
rotl #7,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>
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.
;
10$: movq (R4)+,R0 ;Get characters.
extzv #30,#6,R0,R1 ;Get first sixbit.
addb3 #32,R1,(R3)+ ;Store char.
;
extzv #24,#6,R0,R1 ;Get second sixbit.
addb3 #32,R1,(R3)+ ;Store char.
;
extzv #18,#6,R0,R1 ;Get third Sixbit.
addb3 #32,R1,(R3)+ ;Store char.
;
extzv #12,#6,R0,R1 ;Get fourth Sixbit.
addb3 #32,R1,(R3)+ ;Store char.
;
extzv #6,#6,R0,R1 ;Get fifth Sixbit.
addb3 #32,R1,(R3)+ ;Store char.
;
bicb #^XC0,R0 ;Get sixth Sixbit.
addb3 #32,R0,(R3)+ ;Store char.
;
sobgtr R5,10$ ;Do until no more words.
;
50$: ret ;Return to caller.
;
;
;
;
.end