Want more features on Pastebin? Sign Up, it's FREE!

Comper Decompressor

By: vladikcomper on Nov 7th, 2013  |  syntax: Motorola 68000 HiSoft Dev  |  size: 1.20 KB  |  views: 233  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ; ===============================================================
  2. ; ---------------------------------------------------------------
  3. ; COMPER Decompressor
  4. ; ---------------------------------------------------------------
  5. ; INPUT:
  6. ;       a0      - Source Offset
  7. ;       a1      - Destination Offset
  8. ; ---------------------------------------------------------------
  9.  
  10. CompDec
  11.  
  12. @newblock
  13.         move.w  (a0)+,d0                ; fetch description field
  14.         moveq   #15,d3                  ; set bits counter to 16
  15.  
  16. @mainloop
  17.         add.w   d0,d0                   ; roll description field
  18.         bcs.s   @flag                   ; if a flag issued, branch
  19.         move.w  (a0)+,(a1)+             ; otherwise, do uncompressed data
  20.         dbf     d3,@mainloop            ; if bits counter remains, parse the next word
  21.         bra.s   @newblock               ; start a new block
  22.  
  23. ; ---------------------------------------------------------------
  24. @flag   moveq   #-1,d1                  ; init displacement
  25.         move.b  (a0)+,d1                ; load displacement
  26.         add.w   d1,d1
  27.         moveq   #0,d2                   ; init copy count
  28.         move.b  (a0)+,d2                ; load copy length
  29.         beq.s   @end                    ; if zero, branch
  30.         lea     (a1,d1),a2              ; load start copy address
  31.  
  32. @loop   move.w  (a2)+,(a1)+             ; copy given sequence
  33.         dbf     d2,@loop                ; repeat
  34.         dbf     d3,@mainloop            ; if bits counter remains, parse the next word
  35.         bra.s   @newblock               ; start a new block
  36.  
  37. @end    rts
clone this paste RAW Paste Data