sym$memory_link_data_conversion  ident
*copy ASMREGS
*copy osa$cybil_interface
         PAGE
................................................................................
.
.        Conversion services.
.
................................................................................
.
.
.        register usage in syaconv.
.
a_tbl    AREG      5                   .pointer to conversion table
a_buf    AREG      6                   .pointer to C170 data buffer
a_vefile AREG      7                   .pointer to nos/ve file
a_line   AREG      8                   .pointer to BAM record
a_save   AREG      9                   .pointer to data save area
amacsr   AREG      0f(16)              .scratch A register
amacscr  AREG      0f(16)              .scratch A register
.
x_ch     XREG      3                   .current character/escape flag
x_li     XREG      5                   .index into current BAM line
x_bi     XREG      6                   .index into C170 buffer
x_fp     XREG      7                   .position within C180 file
x_mask   XREG      8                   .c170 character mask
x_ml     XREG      9                   .C170 character mask limit
x_bl     XREG      0a(16)              .C170 buffer length
x_rl     XREG      0b(16)              .BAM record length
x_us     XREG      0b(16)              .Holds Unit Seperator for T records
x_fl     XREG      0c(16)
.
.        bam record equivalents
.
bam_hdrt equ       0                   .bam record header type
bam_len  equ       bam_hdrt+1          .bam record length
bam_last equ       bam_len+6           .bam previous record fba
bam_id   equ       bam_last+6          .bam record identifier
hdr_size equ       bam_id+1
.
bac_fulr equ       0                   .bac$full_record
bac_star equ       1                   .bac$start_record
bac_conr equ       2                   .bac$continue_record
bac_endr equ       3                   .bac$end_record
bac_part equ       4                   .bac$partition
bac_delr equ       5                   .bac$deleted_record
bac_endd equ       6                   .bac$end_of_data
.
.        endline   - terminate current bam record.
.
         proc
endline  pname
         ente      x_ch,01e(16)
         sbyts,1   x_ch,a_line,x0,bam_id
         entp      x_ch,bac_fulr
         sbyts,1   x_ch,a_line,x0,bam_hdrt
         sbyts,6   x_li,a_line,x0,bam_len   .save record length
         incr      x_li,hdr_size
         addax     a_line,x_li
         sbyts,6   x_fp,a_line,x0,bam_last
         addr      x_fp,x_li
         entp      x_li,0              .reset record size
         pend
.
.        nxtline   - setup to read next bam record.
.
         proc
nxtline  pname
         local     next_rec
next_rec addrq     x_rl,x_rl,hdr_size
         addr      x_fp,x_rl
         addrq     x2,x_fp,hdr_size
         brrgt     x2,x_fl,exit        .if at end of file
         addax     a_line,x_rl
         lbyts,6   x_rl,a_line,x0,bam_len   .fetch record length
         entp      x_li,0              .reset record size
         lbyts,1   x2,a_line,x0,bam_hdrt
         decr      x2,bac_part
         brrge     x2,x0,next_rec
         addrq     x2,x_fp,hdr_size
         addr      x2,x_rl
         brrgt     x2,x_fl,exit        .if at end of file
         pend
.
.        definition of save record.
.
cnv_type equ       0                   .conversion type
seq_ptr  equ       1                   .VE file sequence ptr
seq_len  equ       seq_ptr+6           .VE file length
seq_pos  equ       seq_len+4           .VE file position
line_pos equ       seq_pos+4           .position within current line
last_ch  equ       line_pos+4          .last contents of x_ch
.
syp$memory_link_data_conversion  procedur gated
request  param     val,pointer
buffer   param     val,pointer
length   param     ref,integer
.
         ploada    a_buf,buffer        .fetch pointer to input buffer
         ploadx    x_bl,length         .size of buffer
         ploada    a_save,request
         la        a_vefile,a_save,seq_ptr .fba of VE file
         lbyts,4   x_fl,a_save,x0,seq_len  .fetch VE file length
         lbyts,4   x_fp,a_save,x0,seq_pos  .fetch position within VE file
         lbyts,4   x_li,a_save,x0,line_pos .length of line
         cpyaa     a_line,a_vefile
         addax     a_line,x_fp             .pointer to current record
         lbyts,1   x_ch,a_save,x0,last_ch
         entp      x_bi,0                  .preset buffer index
         brreq     x_fl,x_fp,exit          .exit if file len same as file pos
         lbyts,1   x4,a_save,x0,cnv_type
         entx      x1,convc
         brrge     x4,x1,exit          .if illegal conversion type
         shfx      x4,x4,x0,2
         ente      x_ml,600(8)*10      .preset mask limit
         addpxq    a5,x4,convvec       .form pva of entry routine
         brdir     a5,x0               .start conversion
..       exit      return to calling program saving current state.
.
.        entry     x_ch   = possible flag character.
.                  x_li   = index into the current line.
.                  x_fp   = position within the VE file.
.                  x_bi   = current index into NOS data block.
.
exit     sbyts,1   x_ch,a_save,x0,last_ch   .save shift character
         sbyts,4   x_li,a_save,x0,line_pos  .save line length
         sbyts,4   x_fp,a_save,x0,seq_pos   .save file position
         pstorxp   x_bi,length
         return
         PAGE
..       convvec   branch table for the conversion routines.
.
.        entry     a5 = pva of one of these routines.
.
convvec  bss       0
c64ata   addpxq    a_tbl,x0,t64ata     .do 6/12 display code to ascii
         brreq     x0,x0,dcta
.
cat64a   addpxq    a_tbl,x0,tat64a     .do ascii to 6/12 display code
         brreq     x0,x0,atdc
.
c64ta    addpxq    a_tbl,x0,tb64ta     .do display code to ascii
         brreq     x0,x0,dcta
.
cat64    addpxq    a_tbl,x0,tbat64     .do ascii to 64 character display code
         brreq     x0,x0,atdc
.
c812ta   brreq     x0,x0,c812ta3       .do 8 in 12 ascii to ascii
         brreq     x0,x0,$
.
cat812   brreq     x0,x0,cat8121       .do ascii to 8 in 12 ascii
         brreq     x0,x0,$
.
c63ta    addpxq    a_tbl,x0,tb63ta     .do 63 ch display code to ascii
         brreq     x0,x0,dcta
.
cat63    addpxq    a_tbl,x0,tbat63     .do ascii to 63 ch display code
         brreq     x0,x0,atdc
.
c63ata   addpxq    a_tbl,x0,t63ata     .do 6/12 63 ch display code to ascii
         brreq     x0,x0,dcta
.
cat63a   addpxq    a_tbl,x0,tat63a     .do ascii to 6/12 display code
         brreq     x0,x0,atdc
.
p56t64   brreq     x0,x0,p56t641       .pack 56 bits to 64 bits
         brreq     x0,x0,$
.
p64t56   addxq     x2,x_fl,-7
         brreq     x0,x0,p64t561       .pack 64 bits into 56 bits
.
p60t64   brreq     x0,x0,p60t640       .pack 60 bits into 64 bits
         brreq     x0,x0,$
.
p64t60   brrne     x_ch,x0,p64t602     .if on 1/2 byte boundary
         brreq     x0,x0,p64t601       .pack 64 bits into 60 bits
.
p32t64   brreq     x_bi,x_bl,exit
         brreq     x0,x0,p32t641       .pack 32 bits of 60 into 64
.
p64t32   addxq     x2,x_fl,-4
         brreq     x0,x0,p64t321       .pack 64 bits into 32 of 60
.
con812   brreq     x0,x0,con8121       .convert ascii to 8 in 12 t type records
         brreq     x0,x0,$
.
p60t60   brreq     x0,x0,p60t600       .pack 60 bits into 64 bits
         brreq     x0,x0,$             .with zero fill
.

convc    equ       ($-convvec)/8
         PAGE
..       dcta      Display Code To Ascii conversion.
.
.        entry     a_line = pointer to current output record.
.                  a_buf = buffer pointer.
.                  x_ch = shift character flag.
.                  x_li = current length of line.
.                  x_fp = offset within file of current output record.
.                  x_bl = buffer size.
.
.
dcta     ente      xf,080(16)          .shift character flag
dcta1    lxi       x1,a_buf,x_bi,0     .fetch next word from buffer
         entp      x_mask,0
         brreq     x_bi,x_bl,exit      .if out of data
         incr      x_bi,1
         brreq     x_ch,xf,dcta5       .if zero character
dcta2    isob      x2,x1,x_mask,405(8) .isolate 6 bit character
         addrq     x_mask,x_mask,600(8)
         shfr      x_ch,x_ch,x0,6
         addr      x2,x_ch             .add shift offset
         lbyts,1   x_ch,a_tbl,x2,0     .fetch translation
         brrge     x_ch,xf,dcta5       .if shift character
dcta3    sbyts,1   x_ch,a_line,x_li,hdr_size   .store ascii translation
         incr      x_li,1
         entp      x_ch,0              .clear shift character flag
dcta4    brrgt     x_ml,x_mask,dcta2   .if more characters in C170 word
         brreq     x0,x0,dcta1         .fetch next word
.
dcta5    subr      x_ch,xf             .form shift table offset
         brrne     x_ch,x0,dcta4       .if not the ZERO character
         cpyxx     x_ch,xf
         brreq     x_mask,x_ml,dcta1   .if last character in word
         cpyxx     x4,x_ml
         subr      x4,x_mask
         shfr      x4,x4,x0,-6
         decr      x4,1                .count of bits remaining in word
         addr      x4,x_mask
         isob      x2,x1,x4,400(8)     .isolate remaining portion of word
         ente      x_ch,c' :'
         brxne     x2,x0,dcta3         .if not end of line
         endline
         brreq     x0,x0,dcta1         .fetch next word
.
t63ata   vfd,8     80(16)
         vfd,208   c'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         vfd,80    c'0123456789'
         vfd,152   c'+-*/()$= ,.#[]:"_!&'
         vfd,8     027(16)
         vfd,24    c'?<>'
         vfd,8     80(16)+(tb6374-t63ata)/64
         vfd,8     c'\'
         vfd,8     80(16)+(data76-t63ata)/64
         vfd,8     c';'
.
tb6374   vfd,128   c':@^@%@@`        '
         vfd,128   c'                '
         vfd,128   c'                '
         vfd,128   c'                '
.
t64ata   vfd,8     80(16)
         vfd,208   c'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         vfd,80    c'0123456789'
         vfd,152   c'+-*/()$= ,.#[]%"_!&'
         vfd,8     027(16)
         vfd,24    c'?<>'
         vfd,8     80(16)+(tb6474-t64ata)/64
         vfd,8     c'\'
         vfd,8     80(16)+(data76-t64ata)/64
         vfd,8     c';'
.
tb6474   vfd,128   c':@^@:@@`        '
         vfd,128   c'                '
         vfd,128   c'                '
         vfd,128   c'                '
.
data76   vfd,8     c'`'
         vfd,208   c'abcdefghijklmnopqrstuvwxyz'
         vfd,32    c'{|}~'
         vfd,8     07f(16)
         vfd,64    00001020304050607(16)
         vfd,64    008090a0b0c0d0e0f(16)
         vfd,64    01011121314151617(16)
         vfd,64    018191a1b1c1d1e1f(16)
.
tb64ta   vfd,8     80(16)
         vfd,208   c'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         vfd,80    c'0123456789'
         vfd,152   c'+-*/()$= ,.#[]%"_!&'
         vfd,8     027(16)
         vfd,56    c'?<>@\^;'
.
tb63ta   vfd,8     80(16)
         vfd,208   c'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         vfd,80    c'0123456789'
         vfd,152   c'+-*/()$= ,.#[]:"_!&'
         vfd,8     027(16)
         vfd,56    c'?<>@\^;'
         PAGE
..       atdc      Ascii To Display Code conversion.
.
.        entry     a_line = pointer to current output record.
.                  a_tbl = pointer to conversion table.
.                  a_buf = buffer pointer.
.                  x_ch = shift character flag.
.                  x_li = current length of line.
.                  x_fp = offset within file of current output record.
.                  x_bl = buffer size.
.
.
atdc     lbyts,6   x_rl,a_line,x0,bam_len
         addrq     x2,x_rl,hdr_size
         addr      x2,x_fp
         brrgt     x2,x_fl,exit
atdc1    entp      x1,0
         ente      x2,07f(16)
         entp      x_mask,0
atdc2    brrne     x_ch,x0,atdc3       .if additional character to copy
         brrge     x_li,x_rl,atdc5     .if at or past the end of line
         lbyts,1   x_ch,a_line,x_li,hdr_size   .fetch next character from line
         andx      x_ch,x2
         incr      x_li,1
         addr      x_ch,x_ch
         lbyts,2   x_ch,a_tbl,x_ch,0   .fetch display code version
atdc3    insb      x1,x_ch,x_mask,405(8)   .insert display code character
         addxq     x_mask,x_mask,600(8)
         shfx      x_ch,x_ch,x0,-6
         brrgt     x_ml,x_mask,atdc2   .if more room in c170 word
         sxi       x1,a_buf,x_bi,0
         incr      x_bi,1
atdc4    brrne     x_bi,x_bl,atdc1     .if more room in buffer
         brreq     x0,x0,exit
atdc5    lbyts,1   x2,a_line,x0,bam_hdrt
         brrne     x2,x0,atdc7         .if not bac$full_record
atdc6    isob      x2,x1,x0,6413(8)    .check last 12 bits
         brrne     x2,x0,atdc3         .if not proper end of line
         sxi       x1,a_buf,x_bi,0
         incr      x_bi,1
         entp      x1,0
         nxtline                       .advance to next BAM record
         entp      x_ch,0
         brreq     x0,x0,atdc4         .process next line
.
atdc7    bss       0                   .process partial record
         decr      x2,bac_endr
         brreq     x2,x0,atdc6         .if bac$end_record
         nxtline                       .advance to next BAM record
         entp      x_ch,0
         ente      x2,07f(16)
         brreq     x0,x0,atdc2         .continue current line
.
tat64a   vfd,16    4076(8)             .nul
         vfd,16    4176(8)             .soh
         vfd,16    4276(8)             .stx
         vfd,16    4376(8)             .etx
         vfd,16    4476(8)             .eot
         vfd,16    4576(8)             .enq
         vfd,16    4676(8)             .ack
         vfd,16    4776(8)             .bel
         vfd,16    5076(8)             .bs
         vfd,16    5176(8)             .ht
         vfd,16    5276(8)             .lf
         vfd,16    5376(8)             .vt
         vfd,16    5476(8)             .ff
         vfd,16    5576(8)             .cr
         vfd,16    5676(8)             .s0
         vfd,16    5776(8)             .s1
         vfd,16    6076(8)             .dle
         vfd,16    6176(8)             .dc1
         vfd,16    6276(8)             .dc2
         vfd,16    6376(8)             .dc3
         vfd,16    6476(8)             .dc4
         vfd,16    6576(8)             .nak
         vfd,16    6676(8)             .syn
         vfd,16    6776(8)             .etb
         vfd,16    7076(8)             .can
         vfd,16    7176(8)             .em
         vfd,16    7276(8)             .sub
         vfd,16    7376(8)             .esc
         vfd,16    7476(8)             .fs
         vfd,16    7576(8)             .gs
         vfd,16    7676(8)             .rs
         vfd,16    7776(8)             .us
         vfd,16    0055(8)             .space
         vfd,16    0066(8)             .!
         vfd,16    0064(8)             ."
         vfd,16    0060(8)             .#
         vfd,16    0053(8)             .$
         vfd,16    0063(8)             .%
         vfd,16    0067(8)             .&
         vfd,16    0070(8)             .'
         vfd,16    0051(8)             .(
         vfd,16    0052(8)             .)
         vfd,16    0047(8)             .*
         vfd,16    0045(8)             .+
         vfd,16    0056(8)             ., comma
         vfd,16    0046(8)             .-
         vfd,16    0057(8)             ..
         vfd,16    0050(8)             ./
         vfd,16    0033(8)             .0
         vfd,16    0034(8)             .1
         vfd,16    0035(8)             .2
         vfd,16    0036(8)             .3
         vfd,16    0037(8)             .4
         vfd,16    0040(8)             .5
         vfd,16    0041(8)             .6
         vfd,16    0042(8)             .7
         vfd,16    0043(8)             .8
         vfd,16    0044(8)             .9
         vfd,16    0474(8)             .:
         vfd,16    0077(8)             .;
         vfd,16    0072(8)             .<
         vfd,16    0054(8)             .=
         vfd,16    0073(8)             .>
         vfd,16    0071(8)             .?
         vfd,16    0174(8)             .@
         vfd,16    0001(8)             .A
         vfd,16    0002(8)             .B
         vfd,16    0003(8)             .C
         vfd,16    0004(8)             .D
         vfd,16    0005(8)             .E
         vfd,16    0006(8)             .F
         vfd,16    0007(8)             .G
         vfd,16    0010(8)             .H
         vfd,16    0011(8)             .I
         vfd,16    0012(8)             .J
         vfd,16    0013(8)             .K
         vfd,16    0014(8)             .L
         vfd,16    0015(8)             .M
         vfd,16    0016(8)             .N
         vfd,16    0017(8)             .O
         vfd,16    0020(8)             .P
         vfd,16    0021(8)             .Q
         vfd,16    0022(8)             .R
         vfd,16    0023(8)             .S
         vfd,16    0024(8)             .T
         vfd,16    0025(8)             .U
         vfd,16    0026(8)             .V
         vfd,16    0027(8)             .W
         vfd,16    0030(8)             .X
         vfd,16    0031(8)             .Y
         vfd,16    0032(8)             .Z
         vfd,16    0061(8)             .[
         vfd,16    0075(8)             .\
         vfd,16    0062(8)             .]
         vfd,16    0274(8)             .^
         vfd,16    0065(8)             ._ underscore
         vfd,16    0774(8)             .` grave
         vfd,16    0176(8)             .a
         vfd,16    0276(8)             .b
         vfd,16    0376(8)             .c
         vfd,16    0476(8)             .d
         vfd,16    0576(8)             .e
         vfd,16    0676(8)             .f
         vfd,16    0776(8)             .g
         vfd,16    1076(8)             .h
         vfd,16    1176(8)             .i
         vfd,16    1276(8)             .j
         vfd,16    1376(8)             .k
         vfd,16    1476(8)             .l
         vfd,16    1576(8)             .m
         vfd,16    1676(8)             .n
         vfd,16    1776(8)             .o
         vfd,16    2076(8)             .p
         vfd,16    2176(8)             .q
         vfd,16    2276(8)             .r
         vfd,16    2376(8)             .s
         vfd,16    2476(8)             .t
         vfd,16    2576(8)             .u
         vfd,16    2676(8)             .v
         vfd,16    2776(8)             .w
         vfd,16    3076(8)             .x
         vfd,16    3176(8)             .y
         vfd,16    3276(8)             .z
         vfd,16    3376(8)             .{
         vfd,16    3476(8)             .|
         vfd,16    3576(8)             .}
         vfd,16    3676(8)             .~
         vfd,16    3776(8)             .del
.
.        ascii to 64 character display code conversion table.
.
tbat64   vfd,16    0055(8)             .nul
         vfd,16    0055(8)             .soh
         vfd,16    0055(8)             .stx
         vfd,16    0055(8)             .etx
         vfd,16    0055(8)             .eot
         vfd,16    0055(8)             .enq
         vfd,16    0055(8)             .ack
         vfd,16    0055(8)             .bel
         vfd,16    0055(8)             .bs
         vfd,16    0055(8)             .ht
         vfd,16    0055(8)             .lf
         vfd,16    0055(8)             .vt
         vfd,16    0055(8)             .ff
         vfd,16    0055(8)             .cr
         vfd,16    0055(8)             .s0
         vfd,16    0055(8)             .s1
         vfd,16    0055(8)             .dle
         vfd,16    0055(8)             .dc1
         vfd,16    0055(8)             .dc2
         vfd,16    0055(8)             .dc3
         vfd,16    0055(8)             .dc4
         vfd,16    0055(8)             .nak
         vfd,16    0055(8)             .syn
         vfd,16    0055(8)             .etb
         vfd,16    0055(8)             .can
         vfd,16    0055(8)             .em
         vfd,16    0055(8)             .sub
         vfd,16    0055(8)             .esc
         vfd,16    0055(8)             .fs
         vfd,16    0055(8)             .gs
         vfd,16    0055(8)             .rs
         vfd,16    0055(8)             .us
         vfd,16    0055(8)             .space
         vfd,16    0066(8)             .!
         vfd,16    0064(8)             ."
         vfd,16    0060(8)             .#
         vfd,16    0053(8)             .$
         vfd,16    0063(8)             .%
         vfd,16    0067(8)             .&
         vfd,16    0070(8)             .'
         vfd,16    0051(8)             .(
         vfd,16    0052(8)             .)
         vfd,16    0047(8)             .*
         vfd,16    0045(8)             .+
         vfd,16    0056(8)             ., comma
         vfd,16    0046(8)             .-
         vfd,16    0057(8)             ..
         vfd,16    0050(8)             ./
         vfd,16    0033(8)             .0
         vfd,16    0034(8)             .1
         vfd,16    0035(8)             .2
         vfd,16    0036(8)             .3
         vfd,16    0037(8)             .4
         vfd,16    0040(8)             .5
         vfd,16    0041(8)             .6
         vfd,16    0042(8)             .7
         vfd,16    0043(8)             .8
         vfd,16    0044(8)             .9
         vfd,16    0000(8)             .:
         vfd,16    0077(8)             .;
         vfd,16    0072(8)             .<
         vfd,16    0054(8)             .=
         vfd,16    0073(8)             .>
         vfd,16    0071(8)             .?
         vfd,16    0074(8)             .@
         vfd,16    0001(8)             .A
         vfd,16    0002(8)             .B
         vfd,16    0003(8)             .C
         vfd,16    0004(8)             .D
         vfd,16    0005(8)             .E
         vfd,16    0006(8)             .F
         vfd,16    0007(8)             .G
         vfd,16    0010(8)             .H
         vfd,16    0011(8)             .I
         vfd,16    0012(8)             .J
         vfd,16    0013(8)             .K
         vfd,16    0014(8)             .L
         vfd,16    0015(8)             .M
         vfd,16    0016(8)             .N
         vfd,16    0017(8)             .O
         vfd,16    0020(8)             .P
         vfd,16    0021(8)             .Q
         vfd,16    0022(8)             .R
         vfd,16    0023(8)             .S
         vfd,16    0024(8)             .T
         vfd,16    0025(8)             .U
         vfd,16    0026(8)             .V
         vfd,16    0027(8)             .W
         vfd,16    0030(8)             .X
         vfd,16    0031(8)             .Y
         vfd,16    0032(8)             .Z
         vfd,16    0061(8)             .[
         vfd,16    0075(8)             .\
         vfd,16    0062(8)             .]
         vfd,16    0076(8)             .^
         vfd,16    0065(8)             ._ underscore
         vfd,16    0055(8)             .` grave
         vfd,16    0001(8)             .a
         vfd,16    0002(8)             .b
         vfd,16    0003(8)             .c
         vfd,16    0004(8)             .d
         vfd,16    0005(8)             .e
         vfd,16    0006(8)             .f
         vfd,16    0007(8)             .g
         vfd,16    0010(8)             .h
         vfd,16    0011(8)             .i
         vfd,16    0012(8)             .j
         vfd,16    0013(8)             .k
         vfd,16    0014(8)             .l
         vfd,16    0015(8)             .m
         vfd,16    0016(8)             .n
         vfd,16    0017(8)             .o
         vfd,16    0020(8)             .p
         vfd,16    0021(8)             .q
         vfd,16    0022(8)             .r
         vfd,16    0023(8)             .s
         vfd,16    0024(8)             .t
         vfd,16    0025(8)             .u
         vfd,16    0026(8)             .v
         vfd,16    0027(8)             .w
         vfd,16    0030(8)             .x
         vfd,16    0031(8)             .y
         vfd,16    0032(8)             .z
         vfd,16    0055(8)             .{
         vfd,16    0055(8)             .|
         vfd,16    0055(8)             .}
         vfd,16    0055(8)             .~
         vfd,16    0055(8)             .del
.
tat63a   vfd,16    4076(8)             .nul
         vfd,16    4176(8)             .soh
         vfd,16    4276(8)             .stx
         vfd,16    4376(8)             .etx
         vfd,16    4476(8)             .eot
         vfd,16    4576(8)             .enq
         vfd,16    4676(8)             .ack
         vfd,16    4776(8)             .bel
         vfd,16    5076(8)             .bs
         vfd,16    5176(8)             .ht
         vfd,16    5276(8)             .lf
         vfd,16    5376(8)             .vt
         vfd,16    5476(8)             .ff
         vfd,16    5576(8)             .cr
         vfd,16    5676(8)             .s0
         vfd,16    5776(8)             .s1
         vfd,16    6076(8)             .dle
         vfd,16    6176(8)             .dc1
         vfd,16    6276(8)             .dc2
         vfd,16    6376(8)             .dc3
         vfd,16    6476(8)             .dc4
         vfd,16    6576(8)             .nak
         vfd,16    6676(8)             .syn
         vfd,16    6776(8)             .etb
         vfd,16    7076(8)             .can
         vfd,16    7176(8)             .em
         vfd,16    7276(8)             .sub
         vfd,16    7376(8)             .esc
         vfd,16    7476(8)             .fs
         vfd,16    7576(8)             .gs
         vfd,16    7676(8)             .rs
         vfd,16    7776(8)             .us
         vfd,16    0055(8)             .space
         vfd,16    0066(8)             .!
         vfd,16    0064(8)             ."
         vfd,16    0060(8)             .#
         vfd,16    0053(8)             .$
         vfd,16    0474(8)             .%
         vfd,16    0067(8)             .&
         vfd,16    0070(8)             .'
         vfd,16    0051(8)             .(
         vfd,16    0052(8)             .)
         vfd,16    0047(8)             .*
         vfd,16    0045(8)             .+
         vfd,16    0056(8)             ., comma
         vfd,16    0046(8)             .-
         vfd,16    0057(8)             ..
         vfd,16    0050(8)             ./
         vfd,16    0033(8)             .0
         vfd,16    0034(8)             .1
         vfd,16    0035(8)             .2
         vfd,16    0036(8)             .3
         vfd,16    0037(8)             .4
         vfd,16    0040(8)             .5
         vfd,16    0041(8)             .6
         vfd,16    0042(8)             .7
         vfd,16    0043(8)             .8
         vfd,16    0044(8)             .9
         vfd,16    0063(8)             .:
         vfd,16    0077(8)             .;
         vfd,16    0072(8)             .<
         vfd,16    0054(8)             .=
         vfd,16    0073(8)             .>
         vfd,16    0071(8)             .?
         vfd,16    0174(8)             .@
         vfd,16    0001(8)             .A
         vfd,16    0002(8)             .B
         vfd,16    0003(8)             .C
         vfd,16    0004(8)             .D
         vfd,16    0005(8)             .E
         vfd,16    0006(8)             .F
         vfd,16    0007(8)             .G
         vfd,16    0010(8)             .H
         vfd,16    0011(8)             .I
         vfd,16    0012(8)             .J
         vfd,16    0013(8)             .K
         vfd,16    0014(8)             .L
         vfd,16    0015(8)             .M
         vfd,16    0016(8)             .N
         vfd,16    0017(8)             .O
         vfd,16    0020(8)             .P
         vfd,16    0021(8)             .Q
         vfd,16    0022(8)             .R
         vfd,16    0023(8)             .S
         vfd,16    0024(8)             .T
         vfd,16    0025(8)             .U
         vfd,16    0026(8)             .V
         vfd,16    0027(8)             .W
         vfd,16    0030(8)             .X
         vfd,16    0031(8)             .Y
         vfd,16    0032(8)             .Z
         vfd,16    0061(8)             .[
         vfd,16    0075(8)             .\
         vfd,16    0062(8)             .]
         vfd,16    0274(8)             .^
         vfd,16    0065(8)             ._ underscore
         vfd,16    0774(8)             .` grave
         vfd,16    0176(8)             .a
         vfd,16    0276(8)             .b
         vfd,16    0376(8)             .c
         vfd,16    0476(8)             .d
         vfd,16    0576(8)             .e
         vfd,16    0676(8)             .f
         vfd,16    0776(8)             .g
         vfd,16    1076(8)             .h
         vfd,16    1176(8)             .i
         vfd,16    1276(8)             .j
         vfd,16    1376(8)             .k
         vfd,16    1476(8)             .l
         vfd,16    1576(8)             .m
         vfd,16    1676(8)             .n
         vfd,16    1776(8)             .o
         vfd,16    2076(8)             .p
         vfd,16    2176(8)             .q
         vfd,16    2276(8)             .r
         vfd,16    2376(8)             .s
         vfd,16    2476(8)             .t
         vfd,16    2576(8)             .u
         vfd,16    2676(8)             .v
         vfd,16    2776(8)             .w
         vfd,16    3076(8)             .x
         vfd,16    3176(8)             .y
         vfd,16    3276(8)             .z
         vfd,16    3376(8)             .{
         vfd,16    3476(8)             .|
         vfd,16    3576(8)             .}
         vfd,16    3676(8)             .~
         vfd,16    3776(8)             .del
.
.        ascii to 64 character display code conversion table.
.
tbat63   vfd,16    0055(8)             .nul
         vfd,16    0055(8)             .soh
         vfd,16    0055(8)             .stx
         vfd,16    0055(8)             .etx
         vfd,16    0055(8)             .eot
         vfd,16    0055(8)             .enq
         vfd,16    0055(8)             .ack
         vfd,16    0055(8)             .bel
         vfd,16    0055(8)             .bs
         vfd,16    0055(8)             .ht
         vfd,16    0055(8)             .lf
         vfd,16    0055(8)             .vt
         vfd,16    0055(8)             .ff
         vfd,16    0055(8)             .cr
         vfd,16    0055(8)             .s0
         vfd,16    0055(8)             .s1
         vfd,16    0055(8)             .dle
         vfd,16    0055(8)             .dc1
         vfd,16    0055(8)             .dc2
         vfd,16    0055(8)             .dc3
         vfd,16    0055(8)             .dc4
         vfd,16    0055(8)             .nak
         vfd,16    0055(8)             .syn
         vfd,16    0055(8)             .etb
         vfd,16    0055(8)             .can
         vfd,16    0055(8)             .em
         vfd,16    0055(8)             .sub
         vfd,16    0055(8)             .esc
         vfd,16    0055(8)             .fs
         vfd,16    0055(8)             .gs
         vfd,16    0055(8)             .rs
         vfd,16    0055(8)             .us
         vfd,16    0055(8)             .space
         vfd,16    0066(8)             .!
         vfd,16    0064(8)             ."
         vfd,16    0060(8)             .#
         vfd,16    0053(8)             .$
         vfd,16    0055(8)             .% no translation
         vfd,16    0067(8)             .&
         vfd,16    0070(8)             .'
         vfd,16    0051(8)             .(
         vfd,16    0052(8)             .)
         vfd,16    0047(8)             .*
         vfd,16    0045(8)             .+
         vfd,16    0056(8)             ., comma
         vfd,16    0046(8)             .-
         vfd,16    0057(8)             ..
         vfd,16    0050(8)             ./
         vfd,16    0033(8)             .0
         vfd,16    0034(8)             .1
         vfd,16    0035(8)             .2
         vfd,16    0036(8)             .3
         vfd,16    0037(8)             .4
         vfd,16    0040(8)             .5
         vfd,16    0041(8)             .6
         vfd,16    0042(8)             .7
         vfd,16    0043(8)             .8
         vfd,16    0044(8)             .9
         vfd,16    0063(8)             .:
         vfd,16    0077(8)             .;
         vfd,16    0072(8)             .<
         vfd,16    0054(8)             .=
         vfd,16    0073(8)             .>
         vfd,16    0071(8)             .?
         vfd,16    0074(8)             .@
         vfd,16    0001(8)             .A
         vfd,16    0002(8)             .B
         vfd,16    0003(8)             .C
         vfd,16    0004(8)             .D
         vfd,16    0005(8)             .E
         vfd,16    0006(8)             .F
         vfd,16    0007(8)             .G
         vfd,16    0010(8)             .H
         vfd,16    0011(8)             .I
         vfd,16    0012(8)             .J
         vfd,16    0013(8)             .K
         vfd,16    0014(8)             .L
         vfd,16    0015(8)             .M
         vfd,16    0016(8)             .N
         vfd,16    0017(8)             .O
         vfd,16    0020(8)             .P
         vfd,16    0021(8)             .Q
         vfd,16    0022(8)             .R
         vfd,16    0023(8)             .S
         vfd,16    0024(8)             .T
         vfd,16    0025(8)             .U
         vfd,16    0026(8)             .V
         vfd,16    0027(8)             .W
         vfd,16    0030(8)             .X
         vfd,16    0031(8)             .Y
         vfd,16    0032(8)             .Z
         vfd,16    0061(8)             .[
         vfd,16    0075(8)             .\
         vfd,16    0062(8)             .]
         vfd,16    0076(8)             .^
         vfd,16    0065(8)             ._ underscore
         vfd,16    0055(8)             .` grave
         vfd,16    0001(8)             .a
         vfd,16    0002(8)             .b
         vfd,16    0003(8)             .c
         vfd,16    0004(8)             .d
         vfd,16    0005(8)             .e
         vfd,16    0006(8)             .f
         vfd,16    0007(8)             .g
         vfd,16    0010(8)             .h
         vfd,16    0011(8)             .i
         vfd,16    0012(8)             .j
         vfd,16    0013(8)             .k
         vfd,16    0014(8)             .l
         vfd,16    0015(8)             .m
         vfd,16    0016(8)             .n
         vfd,16    0017(8)             .o
         vfd,16    0020(8)             .p
         vfd,16    0021(8)             .q
         vfd,16    0022(8)             .r
         vfd,16    0023(8)             .s
         vfd,16    0024(8)             .t
         vfd,16    0025(8)             .u
         vfd,16    0026(8)             .v
         vfd,16    0027(8)             .w
         vfd,16    0030(8)             .x
         vfd,16    0031(8)             .y
         vfd,16    0032(8)             .z
         vfd,16    0055(8)             .{
         vfd,16    0055(8)             .|
         vfd,16    0055(8)             .}
         vfd,16    0055(8)             .~
         vfd,16    0055(8)             .del
         PAGE
..       c812ta    C170 8 in 12 to ascii.
.
.        entry     a_line = pointer to current output record.
.                  a_buf = buffer pointer.
.                  x_li = current length of line.
.                  x_fp = offset within file of current output record.
.                  x_bl = buffer size.
.
.
c812ta1  isob      x_ch,x1,x_mask,0413(8)
         brreq     x_ch,x0,c812ta4     .if possible end of ine
c812ta2  sbyts,1   x_ch,a_line,x_li,hdr_size  .save character in line
         addrq     x_mask,x_mask,1400(8)
         incr      x_li,1
         brrne     x_mask,x_ml,c812ta1 .if more characters in word
c812ta3  lxi       x1,a_buf,x_bi,0     .read next C170 word from buffer
         entp      x_mask,0
         incr      x_bi,1
         brrge     x_bl,x_bi,c812ta1   .if word in buffer
         brreq     x0,x0,exit          .exit to get next buffer
.
c812ta4  cpyxx     x4,x_ml
         subr      x4,x_mask
         shfr      x4,x4,x0,-6
         decr      x4,1                .count of bits remaining in word
         addr      x4,x_mask
         isob      x4,x1,x4,400(8)
         brxne     x4,x0,c812ta2       .if not valid end of line
         endline
         brreq     x0,x0,c812ta3       .start next line
         PAGE
..       cat812    convert ascii to 8 in 12 ascii.
.
.        entry     a_line = pointer to current output record.
.                  a_buf = buffer pointer.
.                  x_li = current length of line.
.                  x_fp = offset within file of current output record.
.                  x_bl = buffer size.
.
cat8121  ente      xf,4000(8)
         lbyts,6   x_rl,a_line,x0,bam_len
         addrq     x2,x_rl,hdr_size
         addr      x2,x_fp
         brrgt     x2,x_fl,exit
cat8122  entp      x1,0
         entp      x_mask,0
cat8123  brreq     x_li,x_rl,cat8125
         lbyts,1   x_ch,a_line,x_li,hdr_size
         incr      x_li,1
         insb      x1,x_ch,x_mask,0413(8)
         addxq     x_mask,x_mask,1400(8)
         brrne     x_mask,x_ml,cat8123 .if more room in C170 word
         sxi       x1,a_buf,x_bi,0     .store converted characters
         incr      x_bi,1
cat8124  brrne     x_bi,x_bl,cat8122   .if more room in c170 buffer
         brreq     x0,x0,exit
.
cat8125  sxi       x1,a_buf,x_bi,0     .store converted characters
         lbyts,1   x2,a_line,x0,bam_hdrt
         brrne     x2,x0,cat8127       .if not bac$full_record
cat8126  incr      x_bi,1              .process complete record
         nxtline
         brreq     x0,x0,cat8124       .process next VE line
cat8127  bss       0                   .process partial record
         decr      x2,bac_endr
         brreq     x2,x0,cat8126       .if bac$end_record
         nxtline                       .advance to next BAM record
         brreq     x0,x0,cat8122       .continue with current line
         PAGE
..       con812    Convert ascii to 8 in 12 ascii t type records US trailer
.
.        Entry     a_buf = buffer pointer
.                  a_ve_file = location of ve file
.                  x_fl = file_limit
.                  x_fp = file_position
.                  x_bl = buffer_limit
.                  x_bi = buffer_index = 0
.
con8121  entp      x1,0
         entp      x_mask,0
         ente      x_us,1f(16)             .unit seperator for t type records
con8122  brrge     x_fp,x_fl,exit          .if file_position > file_limit
         lbyts,1   x_ch,a_vefile,x_fp,0    .get next character in file
         incr      x_fp,1                  .incrment to next character in file
         brreq     x_ch,x_us,con8123       .if end of line
         insb      x1,x_ch,x_mask,0413(8)
         addxq     x_mask,x_mask,1400(8)
         brrne     x_mask,x_ml,con8122     .if room in 170 word
con8123  sxi       x1,a_buf,x_bi,0         .store converted 170 word
         incr      x_bi,1                  .increment to next buffer word
         brrne     x_bi,x_bl,con8121       .if still room in buffer
         brreq     x0,x0,exit              .if buffer is full
         PAGE

..       p56t64    pack 56 bits of nos data to 64 bit ve data.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p56t641  lxi       x1,a_buf,x_bi,0     .fetch next nos word
         isob      x2,x1,x0,403(8)     .unused byte count
         incr      x_bi,1
         brrgt     x_bi,x_bl,exit      .if end of c170 buffer
         sbyts,7   x1,a_vefile,x_fp,0    .save in VE buffer
         incr      x_fp,7
         brreq     x0,x2,p56t641       .if more data to copy
         subr      x_fp,x2             .subtract unused bytes
         brrge     x_fp,x0,exit        .if offset positive
         entp      x_fp,0              .force to zero, probably means not b56 file
         brreq     x0,x0,exit          .end of transfer
         PAGE
..       p64t56    pack 64 bits into 56 bit words of C170 data.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p64t561  brrge     x_fp,x2,p64t562     .if last portion of VE data
         lbyts,7   x1,a_vefile,x_fp,0
         incr      x_fp,7
         sxi       x1,a_buf,x_bi,0
         incr      x_bi,1
         brrne     x_bi,x_bl,p64t561   .if more room in c170 buffer
         brreq     x0,x0,exit          .return with full buffer
.
p64t562  addxq     x3,x_fp,7           .calculate unused byte count
         subr      x3,x_fl
         mulrq     x2,x3,8
         cpyxx     x0,x_fl
         subr      x0,x_fp             .valid byte count
         decr      x0,1
         lbyt,x0   x1,a_vefile,x_fp,0
         shfx      x1,x1,x2,0          .position valid data to upper part
         shfx      x3,x3,x0,56         .position unused byte count
         iorx      x1,x3
         sxi       x1,a_buf,x_bi,0     .save last c170 word
         incr      x_bi,1
         brreq     x0,x0,exit          .return with final transfer
         PAGE
..       p32t64    pack 32 bits of 60 into 64 bit ve data.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  a_bi = 0.
.                  a_fp = offset into VE file of data being converted.
.                  a_bl = buffer size.
.
.
p32t641  lxi       x1,a_buf,x_bi,0     .fetch next nos word
         sbyts,4   x1,a_vefile,x_fp,0  .save in ve buffer
         incr      x_fp,4
         incr      x_bi,1
         brrgt     x_bl,x_bi,p32t641   .if more words to copy
         brreq     x0,x0,exit          .end of transfer
         PAGE
..       p64t32    copy 64 bits into 32 of each 60.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p64t321  brrge     x_fp,x2,p64t322     .if near end of VE data
         lbyts,4   x1,a_vefile,x_fp,0  .copy 32 bits
         sxi       x1,a_buf,x_bi,0
         incr      x_fp,4
         incr      x_bi,1
         brrne     x_bi,x_bl,p64t321
         brreq     x0,x0,exit          .if buffer filled
.
p64t322  cpyxx     x0,x_fl             .compute excess byte count
         subr      x0,x_fp
         entp      x2,4
         subr      x2,x0
         mulrq     x2,x2,8             .compute shift count to left adjust
         decr      x0,1
         lbyt,x0   x1,a_vefile,x_fp,0
         shfx      x1,x1,x2,0          .left adjust in 32 bits
         sxi       x1,a_buf,x_bi,0     .store final word in 170 file
         incr      x_bi,1
         brreq     x0,x0,exit          .end of transfer
         PAGE
..       p60t64    pack 60 bits of nos data to 64 bit ve data.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p60t640  brreq     x_bi,x_bl,exit      .if no data in buffer
         brreq     x_ch,x0,p60t641     .if not on 1/2 byte boundary
         decr      x_fp,8
         lbyts,8   x1,a_vefile,x_fp,0
         shfx      x1,x1,x0,-4
         brreq     x0,x0,p60t642
.
p60t641  lxi       x1,a_buf,x_bi,0     .fetch 7 1/2 bytes
         incr      x_bi,1
         brreq     x_bi,x_bl,p60t643   .if end of nos data
p60t642  lxi       x2,a_buf,x_bi,0     .fetch 7 1/2 bytes
         insb      x2,x1,x0,0003(8)    .insert 1/2 byte
         shfx      x1,x1,x0,-4         .7 bytes
         sbyts,7   x1,a_vefile,x_fp,0  .store 15 bytes
         sbyts,8   x2,a_vefile,x_fp,7
         incr      x_bi,1
         incr      x_fp,15
         brrne     x_bi,x_bl,p60t641   .if more nos data
         entp      x_ch,0
         brreq     x0,x0,exit          .if end of nos buffer
.
p60t643  shfx      x1,x1,x0,4
         sbyts,8   x1,a_vefile,x_fp,0  .store 7 1/2 bytes
         incr      x_fp,8
         entp      x_ch,1              .set 1/2 byte flag
         brreq     x0,x0,exit
.
p60t644  brreq     x_bi,x_bl,exit      .if no data in buffer
         decr      x_fp,8
         lbyts,8   x1,a_vefile,x_fp,0  .fetch 7 1/2 byte
         shfx      x1,x1,x0,-4
         brreq     x0,x0,p60t642       .form 15 bytes of ve data
         PAGE
..       p60t60    place 60 bits of nos data to 64 bit ve data.
.                  with zero fill
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p60t600  bss       0
         brreq     x_bi,x_bl,exit      .if no data in buffer
         isom      x2,x0,0003          .mask off upper 1/2 of byte 8
.
p60t601  lxi       x1,a_buf,x_bi,0     .fetch 7 1/2 bytes
.
         inhx      x1,x2               .insert 170 word
         sbyts,8   x1,a_vefile,x_fp,0
         incr      x_bi,1
         incr      x_fp,8
         brrne     x_bi,x_bl,p60t601   .if more nos data
         entp      x_ch,0
         brreq     x0,x0,exit          .if end of nos buffer
.
         PAGE
..       p64t60    pack 64 bits into 60 bits.
.
.        entry     a_vefile = pva of first byte in VE file.
.                  a_buf = buffer pointer.
.                  x_bi = 0.
.                  x_fp = offset into VE file of data being converted.
.                  x_bl = buffer size.
.
.
p64t601  bss       0
         addrq     x2,x_fp,8
         brrgt     x2,x_fl,p64t603   .if near end of file
         lbyts,8   x1,a_vefile,x_fp,0
         isob      x_ch,x1,x0,7403(8)
         addrq     x_ch,x_ch,10(16)
         shfx      x1,x1,x0,-4         .form 60 bit value
         sxi       x1,a_buf,x_bi,0
         incr      x_fp,8
         incr      x_bi,1
         brreq     x_bi,x_bl,exit      .if end of 170 buffer
p64t602  bss       0
         addrq     x2,x_fp,7
         brrgt     x2,x_fl,p64t603   .if near end of file
         lbyts,7   x1,a_vefile,x_fp,0
         insb      x1,x_ch,x0,0403(8)
         entp      x_ch,0
         sxi       x1,a_buf,x_bi,0
         incr      x_bi,1
         incr      x_fp,7
         brrne     x_bi,x_bl,p64t601   .if more buffer space available
         brreq     x0,x0,exit          .if end of 170 buffer
.
p64t603  cpyxx     x0,x_fl
         subr      x0,x_fp             .remaining byte count
         cpyxx     x2,x0
         brrne     x2,x0,p64t6031      .if not done (1 or more bytes left)
         brreq     x_ch,x0,exit        .if done
         entp      x0,1                .4 bits left
p64t6031 bss       0
         entp      x2,8
         subr      x2,x0               .unused byte count
         decr      x0,1
         lbyt,x0   x1,a_vefile,x_fp,0
         mulxq     x2,x2,8             .unused bit count
         shfx      x1,x1,x2,-4         .left adjust to 60 bits
         cpyxx     x_fp,x_fl
         brreq     x_ch,x0,p64t604     .if not on 1/2 byte boundary
         shfx      x1,x1,x0,-4
         insb      x1,x_ch,x0,0403(8)
p64t604  entp      x_ch,0
         sxi       x1,a_buf,x_bi,0
         incr      x_bi,1
         brreq     x0,x0,exit          .file conversion complete
         end
