small depacker routines
category: general [glöplog]
Currently coding an Atari ST 480 bytes bootsector for Outline 2009, i'm using a lz77 packer with a small depacker:
If i'm correct, the depacker is only 32 bytes long, but the lz77 packer doesn't work that well for 68k code (518 bytes to 329 when all loops are unrolled). Anyone has informations/ideas for packing demos <1k?
Pervect/Topix has made CodePressor, but it's designed specifically for the ARM processor (original idea by Tony Haines). Also my friend eXoTiCorn/ICeBird has a very small Huffman depacker, but you need 256b of statistical datas IIRC.
Code:
Min EQU 3
lea PackedData(pc),a0
lea Where2Depack(pc),a1
;a0=@PackedData
;a1=@Where2Depack
Depacker
moveq.l #0,d0
move.b (a0)+,d0 ;d0=ControlByte
beq.s DpkEnd
bmi.s DpkMatch
DpkNoMatch
move.l a0,a2 ;a2=@CopyFrom=@PackedData
add.l d0,a0 ;a0+=NbNoMatch
subq.l #1,d0
bra.s DpkCopyOne
DpkMatch
moveq.l #0,d1
move.b (a0)+,d1 ;d1=Offset-1
addq.l #1,d1 ;d1=Offset
move.l a1,a2 ;a2=@Where2Depack
sub.l d1,a2 ;a2=@CopyFrom=@Where2Depack-Offset
sub.b #129-Min,d0 ;d0=NbMatch=Control-128+Min-1
DpkCopyOne
move.b (a2)+,(a1)+
dbra d0,DpkCopyOne
bra.s Depacker
DpkEnd
; bra Where2Depack
clr.w -(sp)
trap #1
PackedData ;ABCDABDABCD
dc.b $06,$41,$42,$43,$44,$41,$42,$80,$02,$02,$43,$44,$00
Where2Depack
If i'm correct, the depacker is only 32 bytes long, but the lz77 packer doesn't work that well for 68k code (518 bytes to 329 when all loops are unrolled). Anyone has informations/ideas for packing demos <1k?
Pervect/Topix has made CodePressor, but it's designed specifically for the ARM processor (original idea by Tony Haines). Also my friend eXoTiCorn/ICeBird has a very small Huffman depacker, but you need 256b of statistical datas IIRC.
Have you checked out UCL (http://www.oberhumer.com/opensource/ucl/) ?
There are decoder routines in 68k assembly in the downloadable archive afaik, but I'm not sure how small you can get the decoder routine.
There are decoder routines in 68k assembly in the downloadable archive afaik, but I'm not sure how small you can get the decoder routine.
the ucl compressor is complete rubbish. you either want the real nrv or implement a packer yourself.
but in general, your best bet is designing decompressor+packed data format+compressor all at the same time.
but in general, your best bet is designing decompressor+packed data format+compressor all at the same time.
Thank you for the answers.
@mic: Seen on UCL's webpage
It's far too much for a <480 bytes bootsector. Unless they are far below 200 bytes, of course... ;)
@ryg: When coding for CodeCraft compos (<1k) on the ARM, it was nonetheless very pleasant to have ready to go packers designed for the processor. It's a bit strange to think in terms of lz77 compression... At the moment i'm replacing the fast 4*movem.l with different parameters by 4*3*move.l with similar parameters to improve compression! It's going against all i've done before...
@mic: Seen on UCL's webpage
Quote:
The decompressors can be squeezed into less than 200 bytes of code.
It's far too much for a <480 bytes bootsector. Unless they are far below 200 bytes, of course... ;)
@ryg: When coding for CodeCraft compos (<1k) on the ARM, it was nonetheless very pleasant to have ready to go packers designed for the processor. It's a bit strange to think in terms of lz77 compression... At the moment i'm replacing the fast 4*movem.l with different parameters by 4*3*move.l with similar parameters to improve compression! It's going against all i've done before...