home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src6.dms / in.adf / BOUNCHSRCS.LZH / decrunch.s < prev    next >
Encoding:
Text File  |  1989-01-22  |  1.4 KB  |  48 lines

  1.  
  2. ; Mini decruncher
  3.  
  4. ; By Fredrik Juto 1989
  5. ; This software is public domain,
  6. ; you may freely distribute, modify or sell it.
  7. ; (See `crunch.s' for crunch routine)
  8.  
  9. ;  FROM  A0
  10. ;   TO   A1
  11. ; LENGTH D0
  12.  
  13. decrunch:
  14.    movem.l  d0-d2/a0-a2,-(sp) ; Push the callers stuff on the stack.
  15.    move.l   a1,a2
  16.    add.l    d0,a2             ; A2 points to source end.
  17.  
  18. de_main:
  19.    moveq    #0,d1             ; Clear d1
  20.    move.b   (a0)+,d1          ; Place next byte in d1 (control byte)
  21.    btst     #7,d1             ; Is it dump & crunch?
  22.    bne.s    de_crunch         ; Crunch.
  23.  
  24. *** Dump ***
  25. de_dump:
  26.    move.b   (a0)+,(a1)+       ; Dumping...
  27.    cmpa.l   a1,a2             ; Is the whole job done?
  28.    beq.s    de_exit           ; Yeah! exit
  29.    dbf      d1,de_dump        ; Decrease d1, if d1 is true, continue dumping..
  30.    bra.s    de_main           ; Jump to main
  31.  
  32. *** Crunch ***
  33. de_crunch:
  34.    bclr     #7,d1             ; Clear the dump/crunch flag in d1 (control byte)
  35.    move.b   (a0)+,d2          ; Read in byte to be repeated
  36. de_crunchloop:
  37.    move.b   d2,(a1)+          ; Repeat byte
  38.    cmpa.l   a1,a2             ; Are we finished?
  39.    beq.s    de_exit           ; Yep, exit.
  40.    dbf      d1,de_crunchloop  ; if (d1--) goto de_crunchloop;
  41.    bra.s    de_main           ; Jump to main.
  42.  
  43. de_exit:
  44.    movem.l  (sp)+,d0-d2/a0-a2 ; Push callers stuff from stack.
  45.    rts                        ; Exit to caller
  46.  
  47.    end                        ; End of assembly
  48.