2 ; -----------------------------------------------------------------------
4 ; Copyright 2004 H. Peter Anvin - All Rights Reserved
6 ; This program is free software; you can redistribute it and/or modify
7 ; it under the terms of the GNU General Public License as published by
8 ; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ; Boston MA 02111-1307, USA; either version 2 of the License, or
10 ; (at your option) any later version; incorporated herein by reference.
12 ; -----------------------------------------------------------------------
17 ; Very simple RLL compressor/decompressor, used to pack binary structures
20 ; Format of leading byte
21 ; 1-128 = x verbatim bytes follow
22 ; 129-255 = (x-126) times subsequent byte
30 ; Pack CX bytes from DS:SI into ES:DI
31 ; Returns updated SI, DI and CX = number of bytes output
41 xor bx,bx ; Run length zero
42 mov bp,di ; Pointer to header byte
43 stosb ; Store header byte (might be zero)
63 ; 3 bytes or more in a row, time to convert sequence
66 dec di ; We killed a whole stretch, remove start byte
104 ; Unpack bytes from DS:SI into ES:DI
105 ; On return SI, DI are updated and CX contains number of bytes output