home *** CD-ROM | disk | FTP | other *** search
/ BBS 1 / BBS#1.iso / document / compress.arj / LZP.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-03-19  |  1.1 KB  |  87 lines

  1. ; #compile /ml /w+ /t /m8 /zi
  2. ; #link    nolink
  3.  
  4.                         Include    LZ.ASI
  5. ;-------------------------------------------------------------
  6. ;
  7. ;    Project:    YAR compressor
  8. ;    Module:        LZP.ASM
  9. ;    Purpose:
  10. ;            Contains packer's critical code
  11. ;            for LZ.C
  12. ;
  13. ;    (C) 1991-92 Compact Soft
  14. ;    Written by: cs:dk
  15. ;
  16. ;-------------------------------------------------------------
  17.  
  18.  
  19. ; =====    Packing routines
  20. .code
  21.  
  22. bitBuf_s    STRUC
  23.     bits        dw    ?
  24.     bytes        db    BITS dup (?)
  25.     freeBits    db    ?
  26.     freeBytePtr    dw    ?
  27. ENDS
  28.  
  29. treeEl    STRUC
  30.     codeLen    db    ?
  31.     codeVal    db    ?
  32. ENDS
  33.  
  34.  
  35. global    BitBuf : bitBuf_s
  36.  
  37. global    FlushBitBuf : PROC
  38.  
  39.  
  40. global    _PutCode : PROC
  41. ;void    _PutCode (treeEl dptr t);
  42.  
  43. proc    _PutCode, t : DATAPTR
  44.  
  45.     uses    si, di    ; a C convention
  46.  
  47.     mov    si, t
  48.     xor    cx, cx
  49.     mov    cl, [si].codeLen
  50.     mov    al, [si].codeVal
  51.  
  52.     mov    bx, BitBuf.bits
  53.     mov    dl, BitBuf.freeBits
  54.  
  55. @@loop:
  56.     shr    al, 1
  57.     rcr    bx, 1
  58.  
  59.     dec    dl
  60.     jz    @@flush
  61.  
  62. @@again:
  63.     loop    @@loop
  64.  
  65.     mov    BitBuf.bits, bx
  66.     mov    BitBuf.freeBits, dl
  67.  
  68.     ret
  69.  
  70. @@flush:
  71.     mov    BitBuf.bits, bx
  72.     mov    BitBuf.freeBits, dl
  73.  
  74.     push    cx ax bx dx
  75.     call    FlushBitBuf
  76.     pop    dx bx ax cx
  77.  
  78.     mov    bx, BitBuf.bits
  79.     mov    dl, BitBuf.freeBits
  80.     jmp    @@again
  81.  
  82. endp    _PutCode
  83.  
  84.  
  85. end    ; of LZP.ASM
  86.  
  87.