home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0689.ZIP / CCE_0689 / LHA3_SRC.LZH / SOURCE / HUFST.S < prev    next >
Text File  |  1993-12-20  |  39KB  |  1,894 lines

  1.  
  2.             import error
  3.             import fill_buf
  4.             import _filbuf
  5.             import pathname
  6.             import backup2
  7.             import InitTree
  8.             import ProcInd
  9.             import copy_to_view
  10.             import buffer_3
  11.  
  12.             import flg_Y
  13.             import key_word
  14.             import key
  15.             import bsize
  16.             import origsize
  17.             import buffered
  18.             import cmdupdate
  19.             import buffer_last
  20.             import method
  21.             import compsize
  22.             import compress
  23.             import outfile
  24.  
  25.             export hfreq
  26.             export prnt
  27.             export son
  28.  
  29.             export match_length
  30.             export match_position
  31.             export file3
  32.             export file1
  33.             export blocksize
  34.             export codesize
  35.             export textsize
  36.             export crc
  37.             export crctbl
  38.             export dad
  39.             export lson
  40.             export rson
  41.             export text_buf
  42.             export outrec
  43.             export outrec_decode
  44.             export ship
  45.  
  46.             export shipout
  47.             export shipout_decode
  48.             export Decode
  49.             export Encode
  50.             export InsertONode
  51.             export DeleteONode
  52.             export OpenOut
  53.             export code
  54.             export buf_putc
  55.  
  56. DICBIT        set 13
  57. DICSIZ        set (1<<DICBIT)
  58. BUFSIZ        set    16384
  59.  
  60. N            set 4096
  61. F            set 60
  62. THRESHOLD    set 2
  63. N_CHAR        set 256-THRESHOLD+F
  64. T            set N_CHAR*2-1
  65. FOLD        set 18
  66. R            set T-1
  67. NIL            set    N
  68.  
  69. WTERR        set 14
  70.  
  71.  
  72. outrec_decode:
  73.         ds.l    1    ; 0 Speicherzeiger
  74.         ds.l    1    ; 4 Länge
  75.         ds.l    1    ; 8 Basispointer
  76.         ds.l    1    ; 12 basislänge
  77.  
  78. outrec:    ds.l    1    ; 0 Speicherzeiger
  79.         ds.l    1    ; 4 Länge
  80.         ds.l    1    ; 8 Basispointer
  81.         ds.l    1    ; 12 basislänge
  82.  
  83. ship:   ds.w    1
  84.  
  85.  
  86. ferror_enc:
  87.         lea.l    backup2,A0
  88.         bra.s    ferror
  89. ferror_dec:
  90.         lea.l    pathname,a0
  91. ferror:
  92.         moveq    #WTERR,D0
  93.         moveq.l    #-1,D1
  94.         jmp        error
  95.  
  96.  
  97. buf_putc:
  98.         lea        outrec(pc),a0
  99.         addq.l    #1,codesize-outrec(a0)
  100.  
  101.         move.l    (a0),a1
  102.         move.b    d0,(a1)+
  103.         move.l    a1,(a0)+
  104.         subq.l    #1,(a0)
  105.         bpl.b    _buf_exit
  106.  
  107.         bsr.b    shipout
  108.  
  109. _buf_exit:
  110.         rts
  111.  
  112.  
  113. code:    tst.b    flg_Y
  114.         beq.s    _no_code
  115.  
  116.         subq.l    #1,d0
  117.         bmi.s    _no_code
  118.  
  119.         movem.l    d1-d2/a2,-(sp)
  120.  
  121.         move.l    key,a1
  122.         lea.l    key_word,a2
  123.  
  124. _code:    move.l    #32767,d2
  125.         cmp.l    d0,d2
  126.         ble.b    _do_code
  127.  
  128.         move.l    d0,d2
  129. _do_code:
  130.         sub.l    d2,d0
  131. _code_lp:
  132.         move.b    (a1)+,d1
  133.         beq.b    _re_code
  134.         eor.b    d1,(a0)+
  135.         dbra    d2,_code_lp
  136.  
  137.         subq.l    #1,d0
  138.         bpl.b    _code
  139.  
  140. _exit_code:
  141.         move.l    a1,key
  142.         movem.l    (sp)+,d1-d2/a2
  143. _no_code:
  144.         rts
  145.  
  146. _re_code:
  147.         movea.l    a2,a1
  148.         move.b    (a1)+,d1
  149.         eor.b    d1,(a0)+
  150.         dbra    d2,_code_lp
  151.         subq.l    #1,d0
  152.         bpl.b    _code
  153.         bra.b    _exit_code
  154.  
  155.  
  156. shipout:movem.l d0-d2/a0-a2,-(sp)
  157.  
  158.         lea        outrec(pc),a0
  159.         move.l    (a0),d1
  160.         sub.l    8(a0),d1
  161.         beq        ship1
  162.  
  163.         move.w    ship(pc),d0
  164.         bne        do_ship
  165.  
  166.         cmp.b    #5,method
  167.         bne.b    not_lha5
  168.  
  169.         move.l    d1,d0
  170.  
  171.         tst.b    buffered
  172.         beq.b    _buffer
  173.  
  174.         move.l    (a0),d0
  175.         sub.l    buffer_last,d0
  176.  
  177. _buffer:add.l    d0,compsize
  178.  
  179. not_lha5:
  180.         move.b    compress,d0
  181.         bne.b    code_ship
  182.  
  183.         move.l    compsize,d0
  184.         cmp.b    #5,method
  185.         beq.b    lha5
  186.  
  187.         move.l    codesize(pc),d0
  188.  
  189. lha5:    cmp.l    origsize(pc),d0
  190.         blt.b    code_ship
  191.  
  192.         tst.b    buffered
  193.         beq.b    ship1
  194.  
  195.         move.l    buffer_last,d1
  196.         sub.l    8(a0),d1
  197.         bra.b    do_ship
  198.  
  199. code_ship:
  200.         pea        (a0)
  201.  
  202.         tst.b    buffered
  203.         beq.b    _crypt1
  204.  
  205.         move.l    (a0),d0
  206.         move.l    buffer_last,a0
  207.         sub.l    a0,d0
  208.         bra.b    _crypt
  209.  
  210. _crypt1:move.l    8(a0),a0
  211.         move.l    d1,d0
  212.  
  213. _crypt:    bsr        code
  214.         move.l    (sp)+,a0
  215.  
  216.         tst.b    buffered
  217.         beq.b    do_ship
  218.  
  219.         tst.l    4(a0)
  220.         bpl.s    ex_ship
  221.  
  222. do_ship:move.l    d1,-(sp)
  223.         move.l    8(a0),-(sp)
  224.         move.l    d1,-(sp)
  225.         move.w    outfile,-(sp)    ; (=handle)
  226.         move.w    #$40,-(sp)        ; Fwrite
  227.         trap    #1
  228.         lea        12(sp),sp
  229.         move.l    (sp)+,d1
  230.  
  231.         tst.l    d0
  232.         bmi        ferror_enc
  233.  
  234.         cmp.l    d1,d0
  235.         blt        ferror_enc
  236.  
  237.         clr.b    buffered
  238.  
  239. ship1:    lea        outrec(pc),a0
  240.         move.l    12(a0),4(a0)
  241.         move.l    8(a0),(a0)
  242.  
  243. ex_ship:movem.l (sp)+,d0-d2/a0-a2
  244.         rts
  245.  
  246.  
  247. shipout_decode:
  248.         movem.l d0-d2/a0-a2,-(sp)
  249.  
  250.         lea        outrec_decode(pc),a0
  251.         move.l    (a0),d0
  252.         move.l    8(a0),a0
  253.         sub.l    a0,d0
  254.         beq        ship1_d
  255.  
  256.         jsr        copy_to_view
  257.  
  258.         lea        outrec_decode(pc),a0
  259.         move.l    (a0),d1
  260.         sub.l    8(a0),d1
  261.  
  262.         move.l    file3(pc),d0    ; _cnt
  263.         beq        ship1_d
  264.  
  265.         move.l    d1,-(sp)
  266.         move.l    8(a0),-(sp)
  267.         move.l    d1,-(sp)
  268.         move.l    d0,a0
  269.         move.w    14(a0),-(sp)    ; file3._file (=handle)
  270.         move.w    #$40,-(sp)        ; Fwrite
  271.         trap    #1
  272.         lea        12(sp),sp
  273.         move.l    (sp)+,d1
  274.  
  275.         tst.l    d0
  276.         bmi        ferror_dec
  277.  
  278.         cmp.l    d1,d0
  279.         blt        ferror_dec
  280.  
  281. ship1_d:lea        outrec_decode(pc),a0
  282.         move.l    12(a0),4(a0)
  283.         move.l    8(a0),(a0)
  284.  
  285.         movem.l (sp)+,d0-d2/a0-a2
  286.         rts
  287.  
  288.  
  289.         macro    ferror    file
  290.         move.l    file,a0
  291.         move.w    12(a0),d0
  292.         btst    #14,d0
  293.         endm
  294.  
  295.  
  296.         macro    putc reg
  297.         local    putc1
  298.  
  299.         lea        outrec(pc),a0
  300.         addq.l    #1,codesize-outrec(a0)
  301.  
  302.         move.l    (a0),a1
  303.         move.b    reg,(a1)+
  304.         move.l    a1,(a0)
  305.         subq.l    #1,4(a0)
  306.         bpl.b    putc1
  307.         bsr        shipout
  308. putc1:
  309.         endm
  310.  
  311. OpenOut:move.l    bsize,d0
  312.         subq.l    #1,d0
  313.  
  314.         move.l    a1,(a0)+
  315.         move.l    d0,(a0)+
  316.         move.l    a1,(a0)+
  317.         move.l    d0,(a0)
  318.         rts
  319.  
  320.         macro    getc
  321.         local    getc1
  322.         local    getc2
  323.         local    getc3
  324.         local    getceof
  325.  
  326.         move.l    file3(pc),a0
  327.         subq.l    #1,(a0)
  328.         bpl.b    getc1
  329.  
  330.         movem.l d1-d2/a0-a1,-(sp)
  331.         jsr        _filbuf
  332.         movem.l (sp)+,d1-d2/a0-a1
  333.  
  334.         cmp.w    #$ffff,d0
  335.         beq.b    getceof
  336.         bra.b    getc2
  337.  
  338. getceof:tst.b    d0
  339.         bra.b    getc3
  340.  
  341. getc1:    moveq.l #0,d0
  342.         move.l    4(a0),a1
  343.         move.b    (a1)+,d0
  344.         move.l    a1,4(a0)
  345.  
  346. getc2:    cmp.b    d0,d0
  347. getc3:
  348.         endm
  349.  
  350.         macro    rgetc
  351.         local    getc1
  352.         local    getc2
  353.  
  354.         subq.l    #1,(a0)
  355.         bpl.b    getc1
  356.  
  357.         bsr        fill_buf
  358.         bra.b    getc2
  359.  
  360. getc1:    moveq.l #0,d0
  361.         move.l    4(a0),a1
  362.         move.b    (a1)+,d0
  363.         move.l    a1,4(a0)
  364. getc2:
  365.         endm
  366.  
  367.         macro    getw
  368.         local    Fits
  369.         local    getwEnd
  370.  
  371.         rgetc
  372.         move.w    d0,d7
  373.         lsl.w    #8,d7
  374.         rgetc
  375.         move.b    d0,d7
  376. getwEnd:endm
  377.  
  378.         macro    crcgetc
  379.         local    no_crc
  380.  
  381.         lea        crc,A1
  382.  
  383.         move.w    (A1)+,D1    ; A1 -> crctbl
  384.         move.w    d1,d2
  385.         eor.w    D0,D1
  386.  
  387.         and.w    #$ff,D1
  388.         add.w    D1,D1
  389.  
  390.         lsr.w    #8,D2
  391.         move.w    0(A1,D1.w),D1
  392.         eor.w    D2,D1
  393.         move.w    D1,-(A1)    ; crc
  394.         endm
  395.  
  396.         macro    putcode
  397.         local    PutCode1
  398.         local    PutCode2
  399.         movem.w D3/D4,-(SP)
  400.         move.w    D0,D4
  401.         move.w    D1,D3
  402.         move.b    d7,D2
  403.         lsr.w    D2,D1
  404.         or.w    D1,d6
  405.  
  406.         add.b    D0,d7
  407.         cmpi.b    #8,d7
  408.         bcs.b    PutCode2
  409.  
  410.         move.w    d6,D0
  411.         lsr.w    #8,D0
  412.         putc    d0
  413.  
  414.         subq.b    #8,d7
  415.         cmpi.b    #8,d7
  416.         bcs.b    PutCode1
  417.  
  418.         putc    d6
  419.  
  420.         subq.b    #8,d7
  421.  
  422.         move.w    D3,D0
  423.         move.b    D4,D1
  424.         sub.b    d7,D1
  425.         lsl.w    D1,D0
  426.         move.w    D0,d6
  427.         bra.b    PutCode2
  428.  
  429. PutCode1:
  430.         move.w    d6,D0
  431.         lsl.w    #8,D0
  432.         move.w    D0,d6
  433.  
  434. PutCode2:
  435.         move.w  (sp)+,D3
  436.         move.w    (sp)+,D4
  437.         endm
  438.  
  439. reconst:movem.l D0-A6,-(SP)
  440.         lea        hfreq,A0
  441.         lea        prnt-hfreq(a0),A1
  442.         lea        son-hfreq(a0),A2
  443.         bra.b    rcon_a
  444.  
  445. rcon:    movem.l D0-A6,-(SP)
  446. rcon_a: moveq    #0,D0
  447.         moveq    #0,D1
  448. ; Collect leaf nodes in the first half of the table
  449. ; and relace the hfreq by (hfreq+1)/2
  450. rcon1:    cmpi.w    #2*T,0(A2,D1.w) ; if son[i] >= T
  451.         blt.b    rcon2
  452.         moveq    #1,D2
  453.         add.w    0(A0,D1.w),D2
  454.         lsr.w    #1,D2
  455.         move.w    D2,0(A0,D0.w)    ; hfreq[j] = (hfreq[i]+1)/2
  456.         move.w    0(A2,D1.w),0(A2,D0.w) ; son[j]=son[i]
  457.         addq.w    #2,D0        ; j++
  458. rcon2:        addq.w    #2,D1        ; i++
  459.         cmp.w    #2*T,D1     ; i < T
  460.         blo.b    rcon1
  461.  
  462. ; begin constructing tree by connecting sons
  463. ; for (i=0; j=N_CHAR; j < T; i+=2; j++) {
  464.  
  465.         move.w    #N_CHAR*2,D3
  466.         moveq    #0,D4
  467. rcon3:        moveq    #2,D0
  468.         add.w    D4,D0        ;        k=i+2
  469.         move.w    0(A0,D4.w),D6
  470.         add.w    0(A0,D0.w),D6    ; f=hfreq[i]+hfreq[k]
  471.         move.w    D6,0(A0,D3.w)    ; hfreq[j]=f
  472. ; for (k=j-1; f < hfreq[k]; k--);
  473.         moveq    #-2,D5
  474.         add.w    D3,D5
  475.         bra.b    rcon5
  476. rcon4:        subq.w    #2,D5
  477. rcon5:        cmp.w    0(A0,D5.w),D6
  478.         blo.b    rcon4
  479.  
  480.         addq.w    #2,D5
  481.         move.w    D3,D7
  482.         sub.w    D5,D7        ; l=(j-k) * 2
  483.  
  484.         lea    0(A0,D5.w),A3
  485.         bsr.b    movemem     ;nach oben schieben
  486.         move.w    D6,0(A0,D5.w)    ; hfreq[k]= f
  487.  
  488.         lea    0(A2,D5.w),A3
  489.         bsr.b    movemem
  490.  
  491.         move.w    D4,0(A2,D5.w)    ; son[k] = i
  492.  
  493.         addq.w    #4,D4        ; i+=2
  494.         addq.w    #2,D3        ; j++
  495.         cmp.w    #2*T,D3
  496.         blo.b    rcon3
  497.  
  498. ; connect prnt
  499. ; for (i=0; i<T; i++) {
  500.         moveq    #0,D0
  501. rcon6:        move.w    0(A2,D0.w),D1
  502.         move.w    D0,0(A1,D1.w)
  503.         cmp.w    #2*T,D1
  504.         blt.b    rcon7        ; if ((k=son[j]) >= T) {
  505.         move.w    D0,0(A1,D1.w)    ; prnt[k] = i
  506.         bra.b    rcon8
  507. rcon7:        move.w    D0,0(A1,D1.w)    ; prnt[k] = i
  508.         move.w    D0,2(A1,D1.w)    ; prnt[k+1] = i;
  509. rcon8:        addq.w    #2,D0
  510.         cmp.w    #2*T,D0
  511.         blo.b    rcon6
  512.         movem.l (SP)+,D0-A6
  513.         rts
  514.  
  515. movemem:    adda.w    D7,A3
  516.         lea    2(A3),A4
  517.         move.w    D7,D0
  518.         bra.b    movemem2
  519. movemem1:    move.w    -(A3),-(A4)
  520.         subq.w    #2,D0
  521. movemem2:    bne.b    movemem1
  522.         rts
  523. ; -----------------------------------------------------------------------
  524. ;        update
  525. ; -----------------------------------------------------------------------
  526.  
  527.  
  528. ; void update(int c);
  529. ; register int i,j,k,l;
  530. ; register D3 = c
  531. ; register D1 = k
  532. ; register D2 = l
  533. ; register A1 = son
  534.  
  535. ; register D5 = cardinal c
  536. ; a4 = hfreq[c]
  537.  
  538. ;uses: d0,d1,d2,d5
  539. ;       a0,a1,a2,a3,a4,a6
  540. ; expects:     a2 = hfreq        d2 = 2*T
  541. ;           a4 = son
  542.         macro    update
  543.         local    upd_1
  544.         local    upd_2
  545.         local    upd_2a
  546.         local    upd_2b
  547.         local    upd_3
  548.         local    upd_4
  549.         local    upd_5
  550.         local    upd_6
  551.         local    updx
  552.         local    updx1
  553.         local    updrecon
  554.  
  555.         tst.w    R*2(A2)  ; if hfreq[R] == MAX_FREQ
  556.         bmi        updrecon
  557.  
  558. upd_1:    lea    prnt-hfreq(a2),A0     ; A0 = prnt
  559.  
  560.         move.w    0(a0,d0.w),d0
  561. ; do {
  562.         lea    0(A2,d0.w),A1    ; A1 = hfreq[c]
  563.         addq.w    #1,(A1)     ; hfreq[c]++
  564.  
  565. ; Ab hier: l=d5
  566. ; if the order is disturbed, exchange nodes
  567.         cmpm.w    (A1)+,(a1)+    ; if k>hfreq[l=c+1])
  568.         bcs.b    upd_2b
  569.  
  570. upd_2a:     move.w    0(a0,d0.w),d0
  571.         beq.b    updx
  572. ; do {
  573. upd_2:        lea    0(A2,d0.w),A1    ; A1 = hfreq[c]
  574.         addq.w    #1,(A1)     ; hfreq[c]++
  575.  
  576. ; Ab hier: l=d5
  577. ; if the order is disturbed, exchange nodes
  578.         cmpm.w    (A1)+,(a1)+    ; if k>hfreq[l=c+1])
  579.         bcc.b    upd_2a
  580.  
  581. ; while k > hfreq[++l]
  582. upd_2b:     subq.w    #1,-4(a1)
  583.         move.w    -4(a1),d1
  584. upd_3:        cmp.w    (a1)+,D1
  585.         beq.b    upd_3        ; while (k>hfreq[++l]);
  586.         subq.l    #4,a1
  587.         addq.w    #1,(a1)
  588.  
  589.         sub.l    A2,a1
  590.  
  591.         move.w    0(a4,d0.w),d4    ; i=son[c]
  592.         move.w    a1,(a0,d4.w)    ;prnt[i]=l
  593.  
  594.         cmp.w    d2,d4            ; if i<T
  595.         bge.b    upd_4
  596.         move.w    a1,2(A0,d4.w)    ; prnt[i+1]=l
  597.  
  598. upd_4:        move.w    0(A4,a1.w),D1           ; j=son[l]
  599.         move.w    d4,0(A4,a1.w)        ; son[l]=j
  600.  
  601.         move.w    d0,(A0,d1.w)    ; prnt[j] = c
  602.  
  603.         cmp.w    d2,D1            ; if j<T
  604.         bge.b    upd_5
  605.         move.w    d0,2(A0,d1.w)    ; prnt[j+1]=c
  606.  
  607. upd_5:        move.w    D1,0(a4,d0.w)    ; son[c]=j
  608.         move.w    a1,d0
  609. upd_6:        move.w    0(a0,d0.w),d0
  610.         beq.b    updx1
  611. ; do {
  612.         lea    0(A2,d0.w),A1    ; A1 = hfreq[c]
  613.         addq.w    #1,(A1)     ; hfreq[c]++
  614. ;         move.w    (A1)+,D1      ; k=hfreq[c]
  615.  
  616. ; Ab hier: l=d5
  617. ; if the order is disturbed, exchange nodes
  618.         cmp.w    (A1)+,(a1)+    ; if k>hfreq[l=c+1])
  619.         bcc.b    upd_6
  620.         bra.b    upd_2b
  621. ; while k > hfreq[++l]
  622. updrecon:    bsr    reconst
  623.         bra    upd_1
  624. updx1:
  625. updx:
  626.         endm
  627.  
  628. ; -----------------------------------------------------------------------
  629. ;         EncodeChar
  630. ; -----------------------------------------------------------------------
  631.  
  632. ; void EncodeChar(unsigned c);
  633. ; register unsigned i;
  634. ; register int j,k;
  635. ; D5 = c
  636. ; D3 = i
  637. ; d4 = j
  638. ; d0 = k
  639.         macro    EncodeCh
  640.         local    Enchar1
  641.         local    Enchar2
  642.         local    Enchar3
  643.         local    Enchar4
  644.         local    Enchar5
  645.         local    Enchar6
  646.         move.w    d5,-(SP)
  647.         move.w    #2*R,d2
  648.         move.w    D0,D5        ; c
  649.         moveq    #0,D1        ;i=0
  650.         move.l    d1,a1        ;j=0
  651.         moveq    #0,d4        ;shift=0
  652.         lea        prnt,A0
  653.         add.w    #T,D0        ; T
  654.         add.w    D0,D0
  655.         move.w    0(A0,D0.w),D0    ; k=prnt[c+T]
  656. ; while
  657. ; if (k & 1) i +=0x8000
  658. Enchar1:    addq.w    #1,d4
  659.         btst    #1,D0
  660.         beq.b    Enchar2
  661.         lsr.w    d4,d1
  662.         add.w    d4,a1
  663.         moveq    #0,d4
  664.         add.w    #$8000,d1
  665. Enchar2:    move.w    0(A0,D0.w),D0    ; k=prnt[k]
  666.         cmp.w    d2,D0            ; R
  667.         bne.b    Enchar1
  668.  
  669. ; putcode(j,i)
  670. Enchar5:add.w    d4,a1
  671.         move.w    a1,D0
  672.         lsr.w    d4,d1
  673.         lea        hfreq,a2
  674.         putcode
  675. ; update(c)
  676.         move.w    D5,D0
  677.         add.w    D0,D0
  678.         lea        hfreq,a2
  679.         lea        son-hfreq(A2),a4
  680.         move.w    #2*T,D2
  681.         add.w    d2,d0
  682.         update
  683.         move.w    (SP)+,D5
  684.         endm
  685.  
  686. ; void EncodePosition(unsigned c)
  687. ; register unsigned i;
  688.  
  689.         macro    EncodePo
  690.         move.w    D0,d4
  691.  
  692.         lsr.w    #6,D0
  693.         move.w    D0,D2        ; i = c >> 6
  694.  
  695.         lea        p_code(pc),A0
  696.         moveq    #0,D1
  697.         move.b    0(A0,D2.w),D1
  698.         lsl.w    #8,D1        ; p_code[i] << 8
  699.  
  700. ;         lea     p_len,A1
  701.         moveq    #0,D0
  702.         move.b    p_len-p_code(A0,D2.w),D0    ; p_len[i]
  703.         putcode         ; putcode(p_len[i],p_code[i] <<8)
  704.  
  705.         moveq    #$3F,D1
  706.         and.w    d4,D1
  707.         moveq    #$0A,D0
  708.         lsl.w    D0,D1
  709.         moveq    #6,D0
  710.         putcode
  711.         endm
  712.  
  713. ; void DeleteNode(int p);        D5 = P
  714. ; register int q;
  715.  
  716. ; register D5 = p    ; D4 = cardinal p
  717. ; register D1 = q    ; D2 = cardinal q
  718. ; register D3 = temp
  719.  
  720. ; register A0 = dad
  721. ; register A2 = rson
  722. ; register A3 = lson
  723. ; register A4 = *rson[p]
  724. ; register A5 = *lson[p]
  725.  
  726.  
  727. ; WARNING: THE FOLLOWING REGISTERS MUST BE DEFINED:
  728. ;
  729. ; A2 = lson
  730. ; A3 = rson
  731. ; a4 = dad
  732. ; A5 = text_buf
  733.  
  734.         macro    DeleteNo
  735.         local    DNode_1
  736.         local    DNode_2
  737.         local    DNode_3
  738.         local    DNode_4
  739.         local    DNode_5
  740.         local    DNode_6
  741.         local    DNode_7
  742.         local    DNode_8
  743.         local    DNode_9
  744.         local    DNodex1
  745.         local    DNodex2
  746.         move.w    #2*NIL,D7
  747.         cmp.w    0(a4,d5.w),d7    ; if dad[p] == NIL
  748.         beq.b    DNode_9         ;     return
  749.         cmp.w    0(A3,d5.w),d7    ; if rson[p] == NIL
  750.         beq.b    DNodex1
  751.         move.w    0(a2,d5.w),d2
  752.         cmp.w    d2,d7            ; if lson[p] == NIL
  753.         beq.b    DNodex2
  754. DNode_2:
  755.         move.w    0(a3,d2.w),d1
  756.         cmp.w    d1,d7
  757.         beq.b    DNode_5
  758. ; do { q=rson[q] } while (rson[q] != NIL}
  759. DNode_3:
  760.         move.w d2,d1
  761.         move.w    0(A3,D2.w),D2
  762.         cmp.w    D7,D2
  763.         bne.b    DNode_3
  764.         move.w    d1,d2
  765. DNode_4:
  766. ; d2 = q    |  d5 = p     |  d1/d0 = temp |
  767. ; a2 = lson |  a3 = rson |    a4      = dad    |
  768.  
  769.         move.w    0(a2,d2.w),d0        ; lson[q]
  770.         move.w    0(a4,d2.w),d1        ; dad[q]
  771.         move.w    d0,0(a3,d1.w)        ; rson[dad[q]]=lson[q]
  772.         move.w    d1,0(a4,d0.w)        ; dad[lson[q]]=dad[q]
  773.         move.w    0(a2,d5.w),d1        ; lson[p]
  774.         move.w    d1,0(a2,d2.w)        ; lson[q]=lson[p]
  775.         move.w    d2,0(a4,d1.w)        ; dad[lson[p]]=q
  776.  
  777. DNode_5:
  778.         move.w    (a3,d5.w),d0
  779.         move.w    d0,0(A3,D2.w)        ; rson[q] = rson[p]
  780.         move.w    D2,0(A4,d0.w)        ; dad[rson[p]] = q
  781. DNode_6:
  782.         move.w    0(a4,d5.w),d0        ; dad[p]
  783.         move.w    d0,0(A4,D2.w)         ; dad[q]=dad[p]
  784.  
  785.         cmp.w    0(A3,d0.w),D5
  786.         bne.b    DNode_7             ; if rson[dad[p]]=p
  787. ; else ..
  788.         move.w    D2,0(A3,d0.w)        ; rson[dad[p]]=q
  789.         bra.b    DNode_8
  790. DNodex1:
  791.         move.w    0(a2,d5.w),d2        ; q=lson[p]
  792.         bra.b    DNode_6
  793. DNodex2:
  794.         move.w    0(a3,d5.w),d2        ; q=rson[p]
  795.         bra.b    DNode_6
  796. DNode_7:move.w    D2,0(A2,d0.w)        ; lson[dad[p]]=q
  797. DNode_8:move.w    D7,0(a4,d5.w)
  798. DNode_9:
  799.         endm
  800.  
  801. ; -----------------------------------------------------------------------
  802. ;        InsertNode
  803. ; -----------------------------------------------------------------------
  804.  
  805. ; void InsertNode(int r);
  806. ; rester int i,p,cmp;
  807. ; unsigned char *key;
  808. ; unigned c;
  809.  
  810. ; register D1 = cmp
  811. ; register D2 = p
  812. ; register A1 = *key
  813. ; register a2 = rson
  814. ; register A3 = lson
  815.  
  816. ; WARNING: THE FOLLOWING REGISTERS MUST BE DEFINED:
  817. ;
  818. ; A2 = lson
  819. ; A3 = rson
  820. ; A4 = dad
  821.  
  822.  
  823.         macro    InsertNo
  824.         local    INode_1
  825.         local    INode_1a
  826.         local    INode_2
  827.         local    INode_3
  828.         local    INode_3a
  829.         local    INode_4
  830.         local    INode_6
  831.         local    INode_6e1
  832.         local    INode_6odd
  833.         local    INode_7
  834.         local    INode_8
  835.         local    INode_9
  836.         local    INode_10
  837.         local    INode_11
  838.         local    INode_12
  839.         local    INode_14
  840.         local    Encode_L1
  841.         movem.l a6/d3,-(sp)
  842.  
  843.         move.w    d6,d1
  844.         lea    0(A5,D1.w),A1    ; key=&text_buf[r]
  845.  
  846.         move.w    (A1)+,D2    ; key[0]
  847.         add.w    #N+1,D2     ; p= N+1+key[0]
  848.         add.w    D2,D2        ; cardinal
  849.         move.w    #2*NIL,d3
  850.         move.w    d3,0(A2,D1.w)    ; rson[r] = NIL
  851.         move.w    d3,0(A3,D1.w)    ; lson[r] = NIL
  852.  
  853. ; for ...
  854. ;        move.l    dad(pc),A4
  855. INode_1a:    move.w    d2,a6
  856.         move.w    0(A3,D2.w),d2    ; rson[p]
  857.         cmp.w    d3,d2        ; if rson[p] != NIL
  858.         bne.b    INode_6     ; p=rson[p] else
  859.  
  860. INode_2:    move.w    a6,d2
  861.         move.w    D1,0(a3,d2.w)    ; rson[p] = r
  862.         move.w    D2,0(A4,D1.w)    ; dad[r] = p
  863.         bra    INode_14
  864.  
  865. INode_4:    move.w    a6,d2
  866.         move.w    D1,0(a2,d2.w)    ; lson[p] = r
  867.         move.w    D2,0(A4,D1.w)    ; dad[r] = p
  868.         bra    INode_14
  869. INode_3a:    bge.b    INode_1a
  870. INode_3:    move.w    d2,a6
  871.         move.w    0(A2,D2.w),d2    ; d2=lson[p]
  872.         cmp.w    d3,d2        ; if lson[p] != NIL
  873.         beq.b    INode_4
  874.  
  875. ; for (i=1; i<F; i++)
  876. INode_6:    move.l    a1,A0        ; key[1] (Siehe oben (a0)+)
  877.         lea    2(A5,D2.w),A6    ; text_buf[p+1]
  878.         cmpm.w    (a0)+,(a6)+    ; this saves MUTCH time
  879.         bne.b    INode_3a    ; and also (why?) some bytes
  880.         cmpm.l    (a0)+,(a6)+
  881.         bne.b    INode_3a
  882.  
  883.         rept    20
  884.         cmpm.l    (a0)+,(a6)+
  885.         bne.b    INode_8
  886.         endm
  887.         moveq    #7,D0
  888. INode_7:    cmpm.l    (A0)+,(A6)+
  889.         dbne    D0,INode_7
  890.  
  891. INode_8:    beq.b    INode_10
  892.         bhi.b    INode_3
  893.         move.w    d2,a6
  894.         move.w    0(A3,D2.w),d2    ; rson[p]
  895.         cmp.w    d3,d2        ; if rson[p] != NIL
  896.         bne.b    INode_6     ; p=rson[p] else
  897.  
  898.         move.w    a6,d2
  899.         move.w    D1,0(a3,d2.w)    ; rson[p] = r
  900.         move.w    D2,0(A4,D1.w)    ; dad[r] = p
  901.         bra    INode_14
  902. Encode_L1:    move.w    D1,0(A3,d0.w)
  903.         move.w    d3,0(a4,d2.w)    ; dad[p] = NIL
  904.         bra.b    INode_14
  905. ;  break
  906. INode_10:    ; d2 = p     a2 = lson     a4 = dad
  907.         ; d1 = r     a3 = rson
  908.         move.w    0(a2,d2.w),d0        ; d0 = lson[p]
  909.         move.w    d1,0(a4,d0.w)        ;    dad[lson[p]]=r
  910.         move.w    d0,0(a2,d1.w)        ;    lson[r]=lson[p]
  911.         move.w    0(a3,d2.w),d0        ; d0=rson[p]
  912.         move.w    d1,0(a4,d0.w)        ;    dad[rson[p]]=r
  913.         move.w    d0,0(a3,d1.w)        ;    rson[r]=rson[p]
  914.         move.w    0(a4,d2.w),d0        ; dad[r]=dad[p]
  915.         move.w    d0,(a4,d1.w)
  916.         cmp.w    0(A3,d0.w),D2
  917.         beq.b    Encode_L1
  918.         move.w    D1,0(A2,D0.w)        ; lson[dad[p]] = r
  919. INode_12:    move.w    d3,0(a4,d2.w)        ; dad[p] = NIL
  920. INode_14:
  921.         movem.l (sp)+,a6/d3
  922.         endm
  923.  
  924.         macro    MatchInsertNo
  925.         local    INode_1
  926.         local    INode_1a
  927.         local    INode_2
  928.         local    INode_3
  929.         local    INode_3a
  930.         local    INode_4
  931.         local    INode_6
  932.         local    INode_7
  933.         local    INode_8
  934.         local    INode_9
  935.         local    INode_9a
  936.         local    INode_10
  937.         local    INode_12
  938.         local    INode_14
  939.         local    Encode_L1
  940.         pea        (a6)
  941.         movem.w D3-D5,-(SP)
  942.         moveq    #1,D1        ; cmp=1
  943.         move.w    #2*NIL,d5
  944. ;         add.w     D6,D6
  945.         lea    0(A5,D6.w),A1    ; key=&text_buf[r]
  946.  
  947.         move.w    (A1)+,D2    ; key[0]
  948.         add.w    #N+1,D2     ; p= N+1+key[0]
  949.         add.w    D2,D2        ; cardinal
  950.  
  951.         move.w    D5,0(A2,D6.w)    ; rson[r] = NIL
  952.         move.w    D5,0(A3,D6.w)    ; lson[r] = NIL
  953.  
  954. ; match_position=d7
  955. ; match_length=d0
  956.         moveq    #0,d0        ; match_length=0
  957. ;         clr.w     match_length-lson(a2)      ; match_length=0
  958. ; for ...
  959. ;        move.l  dad(pc),A4
  960. INode_1:    tst.b    D1        ; if (cmp > 0) {
  961.         blt.b    INode_3
  962. INode_1a:    move.w    d2,a6
  963.         move.w    0(A3,D2.w),d2    ; rson[p]
  964.         cmp.w    d5,d2        ; if rson[p] != NIL
  965.         bne.b    INode_6     ; p=rson[p] else
  966.  
  967. INode_2:    move.w    a6,d2
  968.         move.w    D6,0(a3,d2.w)    ; rson[p] = r
  969.         move.w    D2,0(A4,D6.w)    ; dad[r] = p
  970.         bra    INode_14
  971.  
  972. INode_4:    move.w    a6,d2
  973.         move.w    D6,0(a2,d2.w)    ; lson[p] = r
  974.         move.w    D2,0(A4,D6.w)    ; dad[r] = p
  975.         bra    INode_14
  976. INode_3a:    bge.b    INode_1a
  977. INode_3:    move.w    d2,a6
  978.         move.w    0(A2,D2.w),d2    ; d7=lson[p]
  979.         cmp.w    d5,d2        ; if lson[p] != NIL
  980.         beq.b    INode_4
  981.  
  982. ; for (i=1; i<F; i++)
  983. INode_6:    move.l    a1,A0        ; key[1] (Siehe oben (a0)+)
  984.         lea    2(A5,D2.w),A6    ; text_buf[p+1]
  985.         cmpm.l    (a0)+,(a6)+    ; this saves MUTCH time
  986.         bne.b    INode_3a    ; and also (why?) some bytes
  987.         cmpm.w    (a0)+,(a6)+
  988.         bne.b    INode_3a
  989.         moveq    #F-5,D3
  990. INode_7:    cmpm.w    (A0)+,(A6)+
  991.         dbne    D3,INode_7
  992.  
  993. INode_8:    beq    INode_9a
  994.         shi    d1        ; cmp=key[i]-text_buf[p+1]
  995.         not    d3
  996.         add.w    #F,d3
  997.  
  998.         cmp.w    d0,D3        ; if i>match_length
  999.         ble.b    INode_1
  1000. INode_9:    move.w    D6,D7
  1001.         sub.w    D2,D7        ; r-p
  1002.         and.w    #2*$0FFF,D7      ; (r-p) & (N-1)
  1003.         subq.w    #2,D7        ; ((r-p) & (N-1)) -1 = match_pos
  1004.  
  1005.         move.w    D3,d0        ; match_length=i
  1006.         tst.b    D1        ; if (cmp > 0) {
  1007.         blt    INode_3
  1008.         move.w    d2,a6
  1009.         move.w    0(A3,D2.w),d2    ; rson[p]
  1010.         cmp.w    d5,d2        ; if rson[p] != NIL
  1011.         bne.b    INode_6     ; p=rson[p] else
  1012.  
  1013.         move.w    a6,d2
  1014.         move.w    D6,0(a3,d2.w)    ; rson[p] = r
  1015.         move.w    D2,0(A4,D6.w)    ; dad[r] = p
  1016.         bra    INode_14
  1017. INode_9a:    not    d3
  1018.         add.w    #F,d3
  1019.         move.w    D6,D7
  1020.         sub.w    D2,D7        ; r-p
  1021.         and.w    #2*$0FFF,D7      ; (r-p) & (N-1)
  1022.         subq.w    #2,D7        ; ((r-p) & (N-1)) -1 = match_pos
  1023.  
  1024.         move.w    D3,d0        ; match_length=i
  1025. ;  break
  1026. INode_10:
  1027.         move.w    0(a2,d2.w),d4        ; d4 = lson[p]
  1028.         move.w    d6,0(a4,d4.w)        ;    dad[lson[p]]=r
  1029.         move.w    d4,0(a2,d6.w)        ;    lson[r]=lson[p]
  1030.         move.w    0(a3,d2.w),d4        ; d4=rson[p]
  1031.         move.w    d6,0(a4,d4.w)        ;    dad[rson[p]]=r
  1032.         move.w    d4,0(a3,d6.w)        ;    rson[r]=rson[p]
  1033.         move.w    0(a4,d2.w),d4
  1034.         move.w    d4,0(a4,d6.w)        ; dad[r]=dad[p]
  1035.  
  1036.         cmp.w    0(A3,D4.w),D2
  1037.         beq.b    Encode_L1
  1038.  
  1039.         move.w    D6,0(A2,D4.w)    ; lson[dad[p]] = r
  1040.  
  1041. INode_12:
  1042.         move.w    d5,0(a4,d2.w)    ; dad[p] = NIL
  1043.         bra.b    INode_14
  1044. Encode_L1:
  1045.         move.w    D6,0(A3,D4.w)
  1046.         move.w    d5,0(a4,d2.w)    ; dad[p] = NIL
  1047. INode_14:
  1048.         move.w    d0,match_length
  1049.         move.w    d7,match_position
  1050.         move.w  (sp)+,d3
  1051.         move.w    (sp)+,d4
  1052.         move.w    (sp)+,d5
  1053.         move.l    (sp)+,a6
  1054.         endm
  1055.  
  1056. ; -----------------------------------------------------------------------
  1057. ;        StartHuff
  1058. ; -----------------------------------------------------------------------
  1059.  
  1060.  
  1061. StartHuf:
  1062.         movem.l D3-D4/A2-A3,-(SP)
  1063.         lea        hfreq,A0
  1064.         movea.l A0,A1        ; freqp=hfreq
  1065.         lea        son,A2        ; sonp=son
  1066.         lea        2*T+prnt,A3    ; prnpt=&prntp[T]
  1067. ; for(i=0; i<N_CHAR; i++) {
  1068.         move.w    #2*T,D1     ; iT=T
  1069.         moveq    #0,D4
  1070.         moveq    #0,D0           ; i=0
  1071.         bra.b    SHuff2
  1072. SHuff1: move.w    #1,(A1)+    ; *hfreq++=1
  1073.         move.w    D1,(A2)+    ; *sonp++=iT++
  1074.         addq.w    #2,D1
  1075.         move.w    D4,(A3)+    ; *prntp++=i;
  1076.         addq.w    #1,D0
  1077.         addq.w    #2,D4
  1078. SHuff2: cmp.w    #$013A,D0
  1079.         blt.b    SHuff1
  1080. ; }
  1081.         moveq    #0,D0           ; i=0
  1082.         move.w    #N_CHAR*2,D4
  1083.         move.w    #N_CHAR,D1    ; j=N_CHAR
  1084.         movea.l A0,A1        ;freqp=hfreq
  1085.         lea        2*N_CHAR+son,A2 ; sonp=&son[N_CHAR]
  1086.         lea        prnt,A3     ; prntp=prnt
  1087. ; while (j<=R) {
  1088.         bra.b    SHuff4
  1089. SHuff3: move.w    (A1)+,D2
  1090.         add.w    (A1)+,D2
  1091.         move.w    D1,D3
  1092.         add.w    D3,D3
  1093.         move.w    D2,0(A0,D3.w)    ; hfreq[j] = *freqp++ + *freqp++
  1094.         move.w    D0,(A2)+    ; *sonp++=i
  1095.         move.w    D4,(A3)+    ; *prntp++=j
  1096.         move.w    D4,(A3)+    ; *prntp++=j
  1097.         addq.w    #4,D0        ; i+=2
  1098.         addq.w    #1,D1        ; j+=1
  1099.         addq.w    #2,D4
  1100. SHuff4: cmp.w    #R,D1
  1101.         ble.b    SHuff3
  1102. ; }
  1103.         move.w    #$FFFF,$04E6(A0) ;hfreq[T]=0xffff
  1104.         clr.w    2*R+prnt    ; prnt[R]=0
  1105.         movem.l (SP)+,D3-D4/A2-A3
  1106.         rts
  1107.  
  1108. ; -----------------------------------------------------------------------
  1109. ;        Encode
  1110. ; -----------------------------------------------------------------------
  1111.  
  1112. ; void Encode(void);
  1113. ; register int i,r,s,c;
  1114. ; register int len,last_match_length
  1115. ; long printcount,printsize;
  1116.  
  1117. ; register D4 = c
  1118. ; register D5 = s
  1119. ; register D6 = r
  1120. ; register A2 = *textsize
  1121. ; 4(sp) = printcount;
  1122. Encode: movem.l D3-D7/A2-A6,-(SP)
  1123.         lea        -$0A(SP),SP
  1124.  
  1125.         move.l    lson(pc),A2
  1126.         move.l    rson(pc),A3
  1127.         move.l    dad(pc),A4
  1128.  
  1129.         move.l    textsize(pc),D0
  1130.         beq        enc_23        ; if (textsize==0) return
  1131.  
  1132.         lea        text_buf,A5
  1133.         moveq    #0,D1
  1134.         move.b    D1,putlen    ; putlen=0
  1135.         moveq    #0,D2
  1136.         move.b    D1,D2
  1137.         move.w    D2,putbuf    ; putbuf=0
  1138. ; printcount=textsize < blocksize ? textsize : blocksize
  1139.         move.l    D0,(SP)
  1140.         cmp.l    blocksize(pc),D0
  1141.         bge.b    enc_1
  1142.         bra.b    enc_2
  1143. enc_1:    move.l    blocksize(pc),D0
  1144. enc_2:    move.l    D0,4(SP)
  1145.         clr.l    textsize               ; textsize=0
  1146.  
  1147.         bsr        StartHuf
  1148.         jsr        InitTree
  1149.         moveq    #0,D5        ; s=0
  1150.         move.w    #N-F,D6     ; r=N-F
  1151.  
  1152. ; for(i=s; i<r;i++)
  1153.         move.w    D5,D7
  1154.         movem.l D0/A5,-(SP)
  1155.         add.w    d7,d7
  1156.         lea        0(A5,D7.w),A5
  1157.         lsr.w    #1,d7
  1158.         move.w    D6,D0
  1159.         sub.w    D7,D0
  1160.         sub.w    #1,D0
  1161. enc_4:    move.w    #$20,(A5)+    ; textbuf[i]=' '
  1162.         dbra    D0,enc_4
  1163.         movem.l (SP)+,D0/A5
  1164.  
  1165. ; for(len=0;len<F && (c=crc_getc(file3)) != EOF; len++)
  1166.         moveq    #0,D3
  1167.         pea        (a5)
  1168.         add.w    d6,d6
  1169.         lea        0(A5,D6.w),A5
  1170.         lsr.w    #1,d6
  1171.         bra.b    enc_6
  1172. enc_5:    addq.l    #1,a5
  1173.         move.b    D4,(A5)+    ; text_buf[r+len]=c
  1174.         addq.w    #1,D3        ; len++
  1175. enc_6:    cmp.w    #F,D3
  1176.         bge.b    enc_7
  1177.         getc
  1178.         bne.b    enc_7        ; Ist EOF
  1179.         crcgetc         ; c=crc_getc(file3)
  1180.         move.w    D0,D4
  1181.         bra.b    enc_5
  1182. ; end for
  1183. enc_7:    movea.l (SP)+,A5
  1184.         move.w    D3,D0
  1185.         ext.l    D0
  1186.         move.l    D0,textsize           ; textsize=len
  1187.  
  1188. ; for(i=1; i<=F; i++)
  1189.         moveq    #F-1,D7
  1190.         move.w    D6,-(SP)
  1191.         subq.w    #1,D6
  1192. enc_8:    add.w    d6,d6
  1193.         InsertNo    ; InsertNode(r-i)          ***
  1194.         lsr.w    d6
  1195.         subq.w    #1,D6
  1196. enc_9:    dbra    D7,enc_8
  1197.         move.w    (SP)+,D6
  1198.         add.w    d6,d6
  1199.         MatchInsertNo          ; InsertNode(r)           ***
  1200.         add.w    d5,d5
  1201. enc_10: lea        match_length(pc),A6
  1202.  
  1203.         cmp.w    (A6),D3
  1204.         bge.b    enc_11        ; if (match_length > len)
  1205.         move.w    D3,(A6)     ;    match_length=len
  1206. enc_11: move.b    putlen(pc),d7
  1207.         move.w    d6,d1
  1208.         move.w    d6,-(sp)
  1209.         move.w    putbuf(pc),d6
  1210.         cmpi.w    #2,(A6)
  1211.         bgt        enc_12        ; if match_length <=THRESHOLD
  1212.         move.w    #1,(A6)     ;    match_length=1
  1213.         moveq    #0,D0
  1214.         move.w    (A5,D1.w),D0
  1215.         EncodeCh    ; EncodeChar(text_buf[r])
  1216.         bra        enc_13
  1217. enc_12: move.w    (A6),D0
  1218.         add.w    #$FD,D0
  1219.         EncodeCh    ; EncodeChar(255-THRESHOLD+match_length)
  1220.         move.w    match_position(pc),D0
  1221.         lsr.w    #1,d0
  1222.         EncodePo    ; EncodePosition(match_position)
  1223. enc_13: move.b    d7,putlen
  1224.         move.w    d6,putbuf
  1225.         move.w    (sp)+,d6
  1226.         move.l    lson(pc),a2
  1227.         move.l    dad(pc),a4
  1228. ; for(i=0;i<last_match_length && (c=crc_getc(file3))!= EOF;i++)
  1229.         move.w    (a6),D0
  1230.  
  1231.         moveq.l #0,d4
  1232.         move.w    D0,D4
  1233.         add.l    D4,textsize
  1234.         lea        2*N(A5),A6
  1235.         dbra    d4,enc_14
  1236. enc_14a:subq.w    #1,d3
  1237.         bra        enc_15
  1238. enc_14b:InsertNo
  1239. enc_14: DeleteNo        ; DeleteNode(s)
  1240.         move.w    #2*$fff,d7
  1241.         getc
  1242.         bne        enc_14a     ; Ist EOF
  1243.         crcgetc         ; c=crc_getc(file3)
  1244.         move.w    d0,0(A5,D5.w)    ; text_buf[s]=c;
  1245.         cmp.w    #2*(F-1),D5
  1246.         bge.b    enc_15        ; if (s<F-1)
  1247.         move.w    d0,0(A6,D5.w)    ; text_buf[s+N]=c;
  1248. enc_15:
  1249.         addq.w    #2,D5
  1250.         and.w    d7,D5
  1251.         addq.w    #2,D6
  1252.         and.w    d7,D6
  1253. enc_16: dbra    d4,enc_14b
  1254.         MatchInsertNo
  1255. ; end for
  1256. ; if ((textsize +=i) >= printcount && i>0)
  1257. enc_17: tst.w    d3
  1258.         beq.b    enc_22
  1259.  
  1260.         move.l    textsize(pc),D1
  1261.         cmp.l    4(SP),D1
  1262.         blt        enc_10
  1263.  
  1264.         jsr        ProcInd
  1265. enc_18:    move.l    blocksize(pc),d0
  1266.         add.l    d0,4(SP)    ; printcount+=blocksize
  1267.         move.l    4(SP),D0
  1268.         cmp.l    (SP),D0
  1269.         ble        enc_10        ; if (printcount>printsize)
  1270.         move.l    (SP),4(SP)    ;    printcount=printsize
  1271.         bra        enc_10        ; while(len>0)
  1272.  
  1273. enc_22: move.b    putlen,d0
  1274.         beq.b    enc_23
  1275.  
  1276.         move.w    putbuf,d0
  1277.         lsr.w    #8,d0
  1278.         putc    d0
  1279.  
  1280. enc_23:    bsr        shipout
  1281.         lea        $0A(SP),SP
  1282.         movem.l (SP)+,D3-D7/A2-A6
  1283.         rts
  1284.  
  1285. ;**************************************************************************
  1286. ;**        Stuff for use with Decode                 **
  1287. ;**************************************************************************
  1288.  
  1289. ; -----------------------------------------------------------------------
  1290. ;        DecodeChar
  1291. ;  this is mixed with GetBit !
  1292. ; -----------------------------------------------------------------------
  1293.  
  1294.         macro    DecodeCh
  1295.         local    GBit
  1296.         local    GBit1
  1297.         local    GBit2
  1298.         local    GBit4
  1299.         local    GBit5
  1300.         local    DeC3
  1301.         local    DeC4
  1302.         local    DeC2
  1303.         move.w    2*R(A4),D1    ; C = son[R]
  1304.         move.l    #2*T,d2
  1305.         cmp.w    d2,D1        ;  while c < T
  1306.         bcc.b    DeC3
  1307.  
  1308. GBit:    dbra    d6,GBit4    ; keine Bits mehr da ?
  1309.         movea.l file1(pc),A0
  1310.         getw
  1311.         moveq    #15,d6
  1312.  
  1313. GBit4:    add.w    d7,d7        ; getbuf << 1 & if (getbuf>0)
  1314.         bge.b    GBit5
  1315.         addq.w    #2,d1        ; c+=getbit()
  1316. GBit5:                    ; getlen--
  1317.         move.w    0(A4,D1.w),D1    ; c=son[c]
  1318.  
  1319. DeC2:    cmp.w    d2,D1        ;  while c < T
  1320.         bcs.b    GBit
  1321. DeC3:    move.w    d1,d0
  1322.         sub.w    d2,D1        ; C -= T
  1323.         swap    d1
  1324.  
  1325.         update
  1326.         swap    d1
  1327.         move.w    d1,d0
  1328.         lsr.w    D0         ; Ausgleich für Arrays
  1329.         endm
  1330.  
  1331.  
  1332. ; -----------------------------------------------------------------------
  1333. ;        DecodePosition
  1334. ; -----------------------------------------------------------------------
  1335.  
  1336.         macro    DecodePo
  1337.         local    Dpos1
  1338.         local    Dpos2
  1339.         local    Dpos3
  1340.         local    D1Pos1
  1341.         local    D1Pos2
  1342.         local    Dnpos
  1343.         local    GetBit1
  1344.         local    GetBit2
  1345.         local    GetBit4
  1346.         local    GetBit5
  1347.         local    GetByte1
  1348.         local    GetByte2
  1349.         local    GetByte3
  1350.         local    GetByte4
  1351.         local    x
  1352.         moveq    #8,d4
  1353. ; while getlen<=8 {
  1354.         cmp.b    d4,d6
  1355.         bgt.b    GetByte4
  1356. GetByte1:
  1357. ;    i=rgetc(file1)
  1358.         movea.l file1(pc),A0
  1359.         rgetc
  1360. ;    getbuf |= i << 8 - getlen
  1361.         move.w    d4,D1;        d4=8
  1362.         sub.b    d6,D1
  1363.         lsl.w    D1,D0
  1364.         or.w    D0,d7
  1365. ;    getlen+=8
  1366.         add.b    d4,d6
  1367. GetByte4:
  1368. ; i=getbuf;
  1369.         and.l    #$ffff,d7
  1370.         lsl.l    #8,d7
  1371.         swap    d7
  1372.         sub.w    d4,d6
  1373.         lea        d_code(pc),A0
  1374.         moveq    #0,D4
  1375.         move.b    0(A0,D7.w),D4
  1376.         add.l    #d_len-d_code,a0
  1377.         moveq    #0,D2
  1378.         move.b    0(A0,D7.w),d2
  1379.         lsl.w    #6,D4
  1380.         swap    d7
  1381.         subq.w    #2,d2
  1382. Dpos1:    move.w    d6,d6        ; <8 bits availale?
  1383.         bgt.b    GetBit5      ; getlen = 0?
  1384.         movea.l file1(pc),A0
  1385.         getw
  1386.         moveq    #16,d6
  1387. GetBit5:move.w    d2,d0
  1388.         cmp.w    d6,d0
  1389.         blt.b    GetBit6
  1390.         move.w    d6,d0
  1391. GetBit6:lsl.l    d0,d7
  1392.         sub.w    d0,d6
  1393.         sub.w    d0,d2
  1394. Dpos2:    bne.b    Dpos1         ; nächstes bit
  1395.         swap    d7
  1396.         moveq    #$3f,d0
  1397.         and.w    d7,d0
  1398.         swap    d7
  1399. Dpos3:    or.w    D4,D0
  1400.         endm
  1401.  
  1402. ; -----------------------------------------------------------------------
  1403. ;        Decode
  1404. ; -----------------------------------------------------------------------
  1405.  
  1406. Decode: movem.l D3-D7/A2-A6,-(SP)
  1407.         subq.w    #6,SP
  1408.         lea.l    outrec_decode(pc),a0
  1409.         move.l    buffer_3,a1
  1410.         bsr        OpenOut
  1411. ; if textsize == 0
  1412. ;     return
  1413.         move.l    textsize,D0
  1414.         beq        Dcode19
  1415. ; getlen = 0
  1416.         moveq    #0,D1
  1417.         move.b    D1,d6
  1418. ; getbuf = 0
  1419.         moveq    #0,D2
  1420.         move.b    D1,D2
  1421.         move.w    D2,d7
  1422. ; printcount=textsize<blocksize ? textsize | blocksize
  1423.         cmp.l    blocksize(pc),D0
  1424.         ble.b    Dcode1
  1425.         move.l    blocksize(pc),D0
  1426. Dcode1:    move.l    D0,(SP)
  1427. ; StartHuff()
  1428.         bsr        StartHuf
  1429. ; for (i=0; i<N-F;i++)
  1430.         moveq    #0,D4
  1431.         lea    text_buf,A5
  1432.         bra.b    Dcode5
  1433. Dcode4:
  1434. ;     text_buf[i] = ' '
  1435.         move.b    #$20,0(A5,D4.w)
  1436.         addq.w    #1,D4
  1437. Dcode5:
  1438.         cmp.w    #$0FC4,D4
  1439.         blt.b    Dcode4
  1440. ; r = N-F;
  1441.         move.w    #$0FC4,D5
  1442. ; for (count = 0; count < textsize;) {
  1443.         lea        crc,A6
  1444.         move.w    (A6)+,A3    ; A6 -> crctbl
  1445.         lea        son-crctbl(a6),a4
  1446.         lea        hfreq-crctbl(a6),a2
  1447.         clr.l    delen-son(a4)
  1448.         bra        Dcode16
  1449. Dcode6:
  1450. ;  c=DecodeCh()
  1451.         DecodeCh
  1452. ;  if (c<256) {
  1453.         cmp.w    #$0100,D0
  1454.         bge.b    Dcode8
  1455. ;       text_buf[r++]=c;
  1456.         move.b    D0,0(A5,D5.w)
  1457.         addq.w    #1,D5
  1458. ;         putc(c)
  1459.         lea        outrec_decode(pc),a0
  1460.         move.l    (a0),a1
  1461.         move.b    d0,(a1)+
  1462.         move.l    a1,(a0)
  1463.         subq.l    #1,4(a0)
  1464.         bpl.b    Dcode7
  1465.         bsr        shipout_decode
  1466. Dcode7:
  1467. ;      setcrc(c)
  1468.         move.w    A3,D1
  1469.         eor.w    D0,D1
  1470.         and.w    #$FF,D1
  1471.         add.w    D1,D1
  1472.         move.w    A3,D2
  1473.         lsr.w    #8,D2
  1474.         move.w    0(A6,D1.w),D0
  1475.         eor.w    D2,D0
  1476.         move.w    D0,A3
  1477.  
  1478. ;       r & = (N-1)
  1479.         and.w    #$fff,D5
  1480. ;        count ++;
  1481.         addq.l    #1,delen-son(A4)
  1482. ; } else {
  1483.         bra    Dcode12
  1484. Dcode8:
  1485. ;      i= (r-DecodePosition()-1) & (N-1)
  1486.         move.w    d0,d3
  1487.         DecodePo
  1488.         move.w    D5,D4
  1489.         sub.w    D0,D4
  1490.         subq.w    #1,D4
  1491.         move.w    #$fff,d2
  1492.         and.w    d2,D4
  1493.  
  1494.         exg.l    d3,d4
  1495. ;      j = c - 255+THRESHOLD
  1496.         add.w    #$FF03-1,D4
  1497. ;      for (k=0; k<j; k++) {
  1498.  
  1499.         exg.l    a3,d6
  1500.         addq.l    #1,delen-son(A4)
  1501.         ext.l    d4
  1502.         add.l    d4,delen-son(a4)
  1503.         lea        outrec_decode(pc),a0
  1504.         move.l    (a0)+,a1    ; len
  1505.  
  1506. Dcode9:
  1507. ;     c=text_buf[(i+k) & (N-1)]
  1508.         and.w    d2,D3
  1509.         move.b    0(A5,D3.w),D0
  1510. ;     text_buf[r++] = c;
  1511.         move.b    D0,0(A5,D5.w)
  1512.         addq.w    #1,D5
  1513. ;     r &=(N-1)
  1514.         and.w    d2,D5
  1515. ;           putc(c)
  1516.         move.b    d0,(a1)+
  1517.         subq.l    #1,(a0)
  1518.         bpl.b    Dcode10
  1519. ; Hier shipout_decode
  1520.         move.l    a1,outrec_decode
  1521.         bsr        shipout_decode
  1522.         lea        outrec_decode(pc),a0
  1523.         move.l    (a0)+,a1    ; Memory
  1524. Dcode10:
  1525. ;     setcrc(c)
  1526.  
  1527.         move.w    d6,D1
  1528.         eor.b    D0,D6
  1529.         and.w    #$FF,D6
  1530.         add.w    D6,D6
  1531.         lsr.w    #8,D1
  1532.         move.w    0(A6,D6.w),D6
  1533.         eor.w    D1,D6
  1534. ;     count++;
  1535. ;    }
  1536.         addq.w    #1,D3
  1537.  
  1538. Dcode11:
  1539.         dbra    d4,Dcode9
  1540.         move.l    a1,outrec_decode
  1541.         exg.l    a3,d6
  1542. Dcode12:
  1543. ;    if (count >= printcount) {
  1544.         move.l    delen-son(a4),d0
  1545.         cmp.l    (SP),d0
  1546.         bcs.b    Dcode16a
  1547.  
  1548.         jsr        ProcInd
  1549. Dcode13:
  1550. ;     printcount +=blocksize;
  1551.         move.l    blocksize(pc),D0
  1552.         add.l    D0,(SP)
  1553. ;     if (printcount > textsize)
  1554.         move.l    (SP),D1
  1555.         cmp.l    textsize(pc),D1
  1556.         ble.b    Dcode14
  1557. ;    printcount = textsize);
  1558.         move.l    textsize(pc),(SP)
  1559. Dcode14:
  1560. ;    if (file3 != NULL && ferror(file3))
  1561.         move.l    file3(pc),D0
  1562.         beq.b    Dcode16
  1563.         ferror    D0
  1564.  
  1565. Dcode15:bne.b    Dcode17
  1566. Dcode16:move.l    delen-son(a4),d0
  1567. Dcode16a:
  1568.         cmp.l    textsize(pc),D0
  1569.         bcs    Dcode6
  1570. Dcode17:
  1571.         jsr        ProcInd
  1572. Dcode18:
  1573. ;     if (file3 != NULL && ferror(file3) {
  1574.         move.l    file3(pc),D0
  1575.         beq.b    Dcode19
  1576.         ferror    D0
  1577.         beq.b    Dcode19
  1578. ;        error(WTERR,file3)
  1579.         lea.l    pathname,A0
  1580.         moveq.l    #WTERR,D0
  1581.         moveq.l    #-1,D1
  1582.         jmp        error
  1583.  
  1584. Dcode19:move.w    a3,-(a6)    ; crc
  1585.         addq.w    #6,SP
  1586.         bsr        shipout_decode
  1587.         movem.l (SP)+,D3-D7/A2-A6
  1588.         rts
  1589.  
  1590. DeleteONode:    movem.l D0-A6,-(SP)
  1591.                 move.l     lson(pc),A2
  1592.                 move.l     rson(pc),A3
  1593.                 move.w    D0,D5
  1594.                 move.w    #2*NIL,D7
  1595.                 move.l    dad(pc),A0
  1596.                 add.w    D5,D5
  1597. ; if dad[p] == NIL
  1598.                 cmp.w    0(A0,D5.w),D7
  1599.                 beq.b    DNode_9
  1600. ; if rson[p] == NIL
  1601.                 cmp.w    0(A3,D5.w),D7
  1602.                 beq.b    DNodex1
  1603.  
  1604. ; if lson[p] == NIL
  1605. DNode_1:        cmp.w    0(A2,D5.w),D7
  1606.                 beq.b    DNodex2
  1607.  
  1608. DNode_2:        lea     0(A2,D5.w),A4    ; lson[p]
  1609.                 lea     0(A3,D5.w),A5    ; rson[p]
  1610.                 move.w    (A4),D1
  1611.  
  1612.                 move.w    D1,D2
  1613.                 cmp.w    0(A3,D2.w),D7
  1614.                 beq.b    DNode_5
  1615. ; do { q=rson[q] } while (rson[q] != NIL}
  1616.  
  1617. DNode_3:        move.w    0(A3,D2.w),D2
  1618.                 cmp.w    D7,D2
  1619.                 beq.b    DNode_4
  1620.                 move.w    D2,D1
  1621.                 bra.b    DNode_3
  1622.  
  1623. DNode_4:        move.w    D1,D2
  1624.                 move.w    0(A0,D2.w),D3
  1625.                 lea     0(A2,D2.w),A1    ; rson[q]
  1626.                 move.w    (A1),0(A3,D3.w) ; lson[dad[q]] = rson[q]
  1627.                 move.w    (A1),D3
  1628.                 move.w    0(A0,D2.w),0(A0,D3.w) ; dad[rson[q]]=dad[q[
  1629.                 move.w    (A4),D3
  1630.                 move.w    D3,(A1)         ; rson[q]=rson[p]
  1631.                 move.w    D1,0(A0,D3.w)
  1632. DNode_5:        move.w    (A5),D3
  1633.                 move.w    D3,0(A3,D2.w)    ; rson[q] = rson[p]
  1634.                 move.w    D1,0(A0,D3.w)    ; dad[rson[p]] = q
  1635. DNode_6:        move.w    0(A0,D5.w),0(A0,D1.w) ; dad[q]=dad[p]
  1636.  
  1637.                 lea     0(A0,D5.w),A5    ; A5=*dad[p]
  1638.                 move.w    (A5),D3         ; D3 = cardinal dad[p]
  1639.                 cmp.w    0(A3,D3.w),D5
  1640.                 bne.b    DNode_7         ; if rson[dad[p]]=p
  1641. ; else ..
  1642.                 move.w    D1,0(A3,D3.w)    ; rson[dad[p]]=q
  1643.                 move.w    D7,(A5)
  1644.                 movem.l (SP)+,D0-A6
  1645.                 rts
  1646. ; if ..
  1647. DNode_7:        move.w    D1,0(A2,D3.w)    ; lson[dad[p]]=q
  1648. ; endif ..
  1649. DNode_8:        move.w    D7,(A5)         ; dad[p]=NIL
  1650. DNode_9:        movem.l (SP)+,D0-A6
  1651.                 rts
  1652. DNodex2:        move.w    0(A3,D5.w),D1
  1653.                 bra.b    DNode_6
  1654. DNodex1:        move.w    0(A2,D5.w),D1
  1655.                 bra.b    DNode_6
  1656.  
  1657. ; void InsertNode(int r);
  1658. ; rester int i,p,cmp;
  1659. ; unsigned char *key;
  1660. ; unigned c;
  1661.  
  1662. ; register D1 = cmp
  1663. ; register D2 = p
  1664. ; register A1 = *key
  1665. ; register A2 = rson
  1666. ; register A3 = lson
  1667.  
  1668. ; D0 = cardinal p
  1669.  
  1670. ; Benötigt: A0 = text_buf
  1671. ;            A2 = lson
  1672. ;            A3 = rson
  1673. ;            A4 = dad
  1674.  
  1675. InsertONode:    movem.l D0-A6,-(SP)
  1676.                 move.l    lson(pc),A2
  1677.                 move.l     rson(pc),A3
  1678.                 lea     text_buf,a5
  1679.  
  1680.                 move.w    D0,D6
  1681.                 moveq    #1,D1            ; cmp=1
  1682.  
  1683.                 lea     0(A5,D6.w),A1    ; key=&text_buf[r]
  1684.                 add.w    D6,D6
  1685.  
  1686.                 moveq    #0,D2
  1687.                 move.b    (A1),D2         ; key[0]
  1688.                 add.w    #4097,D2        ; p= N+1+key[0]
  1689.                 add.w    D2,D2            ; cardinal
  1690.  
  1691.                 move.w    #2*NIL,D7        ; NIL
  1692.                 move.w    D7,0(A2,D6.w)    ; rson[r] = NIL
  1693.                 move.w    D7,0(A3,D6.w)    ; lson[r] = NIL
  1694.  
  1695.                 clr.w    match_length    ; match_length=0
  1696. ; for ...
  1697.                 move.l    dad(pc),A4
  1698. I_Node1:        tst.w    D1                ; if (cmp > 0) {
  1699.                 blt.b    I_Node4
  1700.                 lea     0(A3,D2.w),A6    ; rson[p]
  1701.                 cmp.w    (A6),D7         ; if rson[p] != NIL
  1702.                 bne.b    I_Node5         ; p=rson[p] else
  1703.  
  1704. I_Node2:        move.w    D6,(A6)         ; rson[p] = r
  1705.                 move.w    D2,0(A4,D6.w)    ; dad[r] = p
  1706.                 bra     I_Node11
  1707.  
  1708. I_Node3:        move.w    D6,(A6)         ; lson[p] = r
  1709.                 move.w    D2,0(A4,D6.w)    ; dad[r] = p
  1710.                 bra     I_Node11
  1711.  
  1712. I_Node4:        lea     0(A2,D2.w),A6    ; d7=lson[p]
  1713.                 cmp.w    (A6),D7         ; if lson[p] != NIL
  1714.                 beq.b    I_Node3
  1715.  
  1716. ; for (i=1; i<F; i++)
  1717. I_Node5:        move.w    (A6),D2
  1718.                 moveq    #0,D1
  1719.                 moveq    #FOLD-2,D5
  1720.                 lea     1(A1),A0        ; key[1]
  1721.                 lsr.w    #1,D2
  1722.                 lea     1(A5,D2.w),A6    ; text_buf[p+1]
  1723.                 add.w    D2,D2
  1724. I_Node6:        cmpm.b    (A0)+,(A6)+
  1725.                 dbne    D5,I_Node6
  1726.  
  1727. I_Node7:        moveq    #FOLD-1,D3
  1728.                 sub.w    D5,D3
  1729.                 moveq    #0,D5
  1730.                 move.b    -1(A0),D1
  1731.                 move.b    -1(A6),D5
  1732.                 sub.w    D5,D1            ; d1=key[i]-text_buf[p+i]
  1733.  
  1734.                 lea     match_length,A6
  1735.                 cmp.w    (A6),D3         ; if i>match_length
  1736.                 ble.b    I_Node1
  1737.  
  1738.                 move.w    D2,D4
  1739.                 lsr.w    #1,D4
  1740.                 move.w    D4,match_position
  1741.  
  1742.                 move.w    D3,(A6)         ; match_length=i
  1743.                 cmp.w    #FOLD,D3        ; if i>=F
  1744.                 blt.b    I_Node1         ; break
  1745.  
  1746. I_Node8:        move.w    0(A4,D2.w),0(A4,D6.w) ; dad[r] = dad[p]
  1747.                 move.w    0(A2,D2.w),0(A2,D6.w) ; lson[r] = lson[p]
  1748.                 move.w    0(A3,D2.w),0(A3,D6.w) ; rson[r] = rson[p[
  1749.  
  1750.                 move.w    0(A2,D2.w),D4
  1751.                 move.w    D6,0(A4,D4.w)    ; dad[lson[p]]=r
  1752.  
  1753.                 move.w    0(A3,D2.w),D4
  1754.                 move.w    D6,0(A4,D4.w)    ; dad[rson[p]]=r
  1755.  
  1756.                 lea     0(A4,D2.w),A6
  1757.                 move.w    (A6),D4         ; a6 = *dat[p]
  1758.                 cmp.w    0(A3,D4.w),D2
  1759.                 beq.b    I_Node12
  1760.  
  1761. I_Node9:        move.w    (A6),D3
  1762.                 move.w    D6,0(A2,D3.w)    ; lson[dad[p]] = r
  1763.  
  1764. I_Node10:        move.w    D7,(A6)         ; dad[p] = NIL
  1765. I_Node11:        movem.l (SP)+,D0-A6
  1766.                 rts
  1767.  
  1768. I_Node12:        move.w    D6,0(A3,D4.w)
  1769.                 move.w    D7,(A6)         ; dad[p] = NIL
  1770.                 movem.l (SP)+,D0-A6
  1771.                 rts
  1772.  
  1773. putbuf:     ds.w    1
  1774. putlen:     ds.b    1
  1775.  
  1776.             even
  1777.  
  1778. file3:        ds.l    1
  1779. file1:        ds.l    1
  1780. blocksize:    ds.l    1
  1781. lson:        ds.l    1
  1782. rson:        ds.l    1
  1783. dad:        ds.l    1
  1784. textsize:    ds.l    1
  1785. match_position:
  1786.             ds.w    1
  1787. match_length:
  1788.             ds.w    1
  1789. codesize:    ds.l    1
  1790.  
  1791. p_len:
  1792.     dc.b    $03, $04, $04, $04, $05, $05, $05, $05
  1793.     dc.b    $05, $05, $05, $05, $06, $06, $06, $06
  1794.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1795.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1796.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1797.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1798.     dc.b    $08, $08, $08, $08, $08, $08, $08, $08
  1799.     dc.b    $08, $08, $08, $08, $08, $08, $08, $08
  1800.  
  1801. p_code:
  1802.     dc.b    $00, $20, $30, $40, $50, $58, $60, $68
  1803.     dc.b    $70, $78, $80, $88, $90, $94, $98, $9C
  1804.     dc.b    $A0, $A4, $A8, $AC, $B0, $B4, $B8, $BC
  1805.     dc.b    $C0, $C2, $C4, $C6, $C8, $CA, $CC, $CE
  1806.     dc.b    $D0, $D2, $D4, $D6, $D8, $DA, $DC, $DE
  1807.     dc.b    $E0, $E2, $E4, $E6, $E8, $EA, $EC, $EE
  1808.     dc.b    $F0, $F1, $F2, $F3, $F4, $F5, $F6, $F7
  1809.     dc.b    $F8, $F9, $FA, $FB, $FC, $FD, $FE, $FF
  1810.  
  1811. d_code:
  1812.     dc.b    $00, $00, $00, $00, $00, $00, $00, $00
  1813.     dc.b    $00, $00, $00, $00, $00, $00, $00, $00
  1814.     dc.b    $00, $00, $00, $00, $00, $00, $00, $00
  1815.     dc.b    $00, $00, $00, $00, $00, $00, $00, $00
  1816.     dc.b    $01, $01, $01, $01, $01, $01, $01, $01
  1817.     dc.b    $01, $01, $01, $01, $01, $01, $01, $01
  1818.     dc.b    $02, $02, $02, $02, $02, $02, $02, $02
  1819.     dc.b    $02, $02, $02, $02, $02, $02, $02, $02
  1820.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1821.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1822.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1823.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1824.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1825.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1826.     dc.b    $08, $08, $08, $08, $08, $08, $08, $08
  1827.     dc.b    $09, $09, $09, $09, $09, $09, $09, $09
  1828.     dc.b    $0A, $0A, $0A, $0A, $0A, $0A, $0A, $0A
  1829.     dc.b    $0B, $0B, $0B, $0B, $0B, $0B, $0B, $0B
  1830.     dc.b    $0C, $0C, $0C, $0C, $0D, $0D, $0D, $0D
  1831.     dc.b    $0E, $0E, $0E, $0E, $0F, $0F, $0F, $0F
  1832.     dc.b    $10, $10, $10, $10, $11, $11, $11, $11
  1833.     dc.b    $12, $12, $12, $12, $13, $13, $13, $13
  1834.     dc.b    $14, $14, $14, $14, $15, $15, $15, $15
  1835.     dc.b    $16, $16, $16, $16, $17, $17, $17, $17
  1836.     dc.b    $18, $18, $19, $19, $1A, $1A, $1B, $1B
  1837.     dc.b    $1C, $1C, $1D, $1D, $1E, $1E, $1F, $1F
  1838.     dc.b    $20, $20, $21, $21, $22, $22, $23, $23
  1839.     dc.b    $24, $24, $25, $25, $26, $26, $27, $27
  1840.     dc.b    $28, $28, $29, $29, $2A, $2A, $2B, $2B
  1841.     dc.b    $2C, $2C, $2D, $2D, $2E, $2E, $2F, $2F
  1842.     dc.b    $30, $31, $32, $33, $34, $35, $36, $37
  1843.     dc.b    $38, $39, $3A, $3B, $3C, $3D, $3E, $3F
  1844.  
  1845. d_len:
  1846.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1847.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1848.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1849.     dc.b    $03, $03, $03, $03, $03, $03, $03, $03
  1850.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1851.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1852.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1853.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1854.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1855.     dc.b    $04, $04, $04, $04, $04, $04, $04, $04
  1856.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1857.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1858.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1859.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1860.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1861.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1862.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1863.     dc.b    $05, $05, $05, $05, $05, $05, $05, $05
  1864.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1865.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1866.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1867.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1868.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1869.     dc.b    $06, $06, $06, $06, $06, $06, $06, $06
  1870.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1871.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1872.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1873.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1874.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1875.     dc.b    $07, $07, $07, $07, $07, $07, $07, $07
  1876.     dc.b    $08, $08, $08, $08, $08, $08, $08, $08
  1877.     dc.b    $08, $08, $08, $08, $08, $08, $08, $08
  1878.  
  1879.             bss
  1880.  
  1881. crc:        ds.w    1    ; Reihenfolge !
  1882. crctbl:     ds.w    256
  1883. delen:        ds.l    1
  1884. hfreq:        ds.w    T+1
  1885. prnt:        ds.w    T+N_CHAR
  1886. son:        ds.w    T
  1887.  
  1888.             align    16
  1889.  
  1890. text_buf:    ds.b    BUFSIZ
  1891.  
  1892.             even
  1893.             end
  1894.