Advertisement
vladikcomper

Comper Decompressor

Nov 7th, 2013
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement