Fix the RLL-packing code; include it by default (not called yet, though)
authorhpa <hpa>
Fri, 17 Dec 2004 07:52:54 +0000 (07:52 +0000)
committerhpa <hpa>
Fri, 17 Dec 2004 07:52:54 +0000 (07:52 +0000)
parseconfig.inc
rllpack.inc

index 3b6d111..f738daf 100644 (file)
@@ -1,7 +1,7 @@
 ;; $Id$
 ;; -----------------------------------------------------------------------
 ;;   
-;;   Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
@@ -325,3 +325,5 @@ commit_vk:
 cvk_ret:       ret
 cvk_overflow:  mov word [VKernelCtr],max_vk    ; No more than max_vk, please
                ret
+
+%include "rllpack.inc"
index 3092881..9d2aab3 100644 (file)
 ; 0            = end of data
 ;
 
+               section .text
+
 ;
 ; rllpack:
 ;      Pack CX bytes from DS:SI into ES:DI
-;      Returns updated SI, DI and DX = number of bytes output
+;      Returns updated SI, DI and CX = number of bytes output
 ;
 rllpack:
                push ax
                push bx
+               push cx
                push bp
-               mov dx,di
+               push di
 .startseq:
-               xor ax,ax
+               xor ax,ax               ; Zero byte
+               xor bx,bx               ; Run length zero
                mov bp,di               ; Pointer to header byte
                stosb                   ; Store header byte (might be zero)
-               xor bx,bx               ; No bytes emitted yet
+               jcxz .done_null
 .stdbyte:
-               jcxz .done
                lodsb
                stosb
                dec cx
@@ -52,13 +55,17 @@ rllpack:
 .plainbyte:
                inc bx
                inc byte [es:bp]
-               js .startseq
-               jmp .stdbyte
+               jcxz .done
+               jns .stdbyte
+               jmp .startseq
 .same:
                cmp bl,2
                jb .plainbyte
                ; 3 bytes or more in a row, time to convert sequence
                sub byte [es:bp],bl
+               jnz .normal
+               dec di                  ; We killed a whole stretch, remove start byte
+.normal:
                inc bx  
                sub di,bx
                mov bp,di
@@ -82,14 +89,14 @@ rllpack:
                dec si
                jmp .startseq
 .done:
-               and bx,bx
-               jz .nullok
                xor al,al
                stosb
-.nullok:
+.done_null:
+               pop dx
                sub dx,di
                neg dx
                pop bp
+               pop cx
                pop bx
                pop ax
                ret