mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-11-29 05:49:20 +00:00
a bit faster, a bit smaller
This commit is contained in:
parent
da4f6f7882
commit
32b98f3085
@ -54,11 +54,12 @@ lzsa1_decompress:
|
|||||||
jne .mid_literals
|
jne .mid_literals
|
||||||
|
|
||||||
lodsw ; grab 16-bit extra length
|
lodsw ; grab 16-bit extra length
|
||||||
jmp short .got_literals
|
.byte 81H ; mask inc ah/lodsb
|
||||||
|
; (*like jmp short .got_literals but faster)
|
||||||
|
|
||||||
.mid_literals:
|
.mid_literals:
|
||||||
lodsb ; grab single extra length byte
|
|
||||||
inc ah ; add 256
|
inc ah ; add 256
|
||||||
|
lodsb ; grab single extra length byte
|
||||||
|
|
||||||
.got_literals:
|
.got_literals:
|
||||||
xchg cx,ax
|
xchg cx,ax
|
||||||
@ -67,16 +68,17 @@ lzsa1_decompress:
|
|||||||
test dl,dl ; check match offset size in token (O bit)
|
test dl,dl ; check match offset size in token (O bit)
|
||||||
js .get_long_offset
|
js .get_long_offset
|
||||||
|
|
||||||
xchg ax,cx ; clear ah - cx is zero from the rep movsb above
|
dec cx
|
||||||
|
xchg cx,ax ; ah to 0xff - cx was zero from the rep movsb above
|
||||||
lodsb
|
lodsb
|
||||||
dec ah
|
.byte 3CH ; mask lodsw
|
||||||
jmp short .get_match_length
|
; (*like jmp short .get_match_length but faster)
|
||||||
|
|
||||||
.get_long_offset:
|
.get_long_offset:
|
||||||
lodsw ; Get 2-byte match offset
|
lodsw ; Get 2-byte match offset
|
||||||
|
|
||||||
.get_match_length:
|
.get_match_length:
|
||||||
xchg ax,dx ; dx: match offset ax: original token
|
xchg dx,ax ; dx: match offset ax: original token
|
||||||
and al,0FH ; isolate match length in token (MMMM)
|
and al,0FH ; isolate match length in token (MMMM)
|
||||||
add al,3 ; add MIN_MATCH_SIZE
|
add al,3 ; add MIN_MATCH_SIZE
|
||||||
|
|
||||||
@ -90,8 +92,13 @@ lzsa1_decompress:
|
|||||||
|
|
||||||
lodsw ; grab 16-bit length
|
lodsw ; grab 16-bit length
|
||||||
test ax,ax ; bail if we hit EOD
|
test ax,ax ; bail if we hit EOD
|
||||||
je short .done_decompressing
|
jne short .got_matchlen
|
||||||
jmp short .got_matchlen
|
|
||||||
|
.done_decompressing:
|
||||||
|
pop ax ; retrieve the original decompression offset
|
||||||
|
xchg ax,di ; compute decompressed size
|
||||||
|
sub ax,di
|
||||||
|
ret ; done
|
||||||
|
|
||||||
.mid_matchlen:
|
.mid_matchlen:
|
||||||
lodsb ; grab single extra length byte
|
lodsb ; grab single extra length byte
|
||||||
@ -109,9 +116,3 @@ lzsa1_decompress:
|
|||||||
xchg si,ax ; restore ds:si
|
xchg si,ax ; restore ds:si
|
||||||
pop ds
|
pop ds
|
||||||
jmp short .decode_token ; go decode another token
|
jmp short .decode_token ; go decode another token
|
||||||
|
|
||||||
.done_decompressing:
|
|
||||||
pop ax ; retrieve the original decompression offset
|
|
||||||
xchg ax,di ; compute decompressed size
|
|
||||||
sub ax,di
|
|
||||||
ret ; done
|
|
||||||
|
@ -72,7 +72,7 @@ lzsa2_decompress:
|
|||||||
jnb .offset_9_bit
|
jnb .offset_9_bit
|
||||||
|
|
||||||
; 5 bit offset
|
; 5 bit offset
|
||||||
xchg ax,cx ; clear ah - cx is zero from the rep movsb above
|
xchg cx,ax ; clear ah - cx is zero from the rep movsb above
|
||||||
mov al,020H ; shift Z (offset bit 4) in place
|
mov al,020H ; shift Z (offset bit 4) in place
|
||||||
and al,dl
|
and al,dl
|
||||||
shl al,1
|
shl al,1
|
||||||
@ -85,7 +85,7 @@ lzsa2_decompress:
|
|||||||
jmp short .get_match_length
|
jmp short .get_match_length
|
||||||
|
|
||||||
.offset_9_bit: ; 9 bit offset
|
.offset_9_bit: ; 9 bit offset
|
||||||
xchg ax,cx ; clear ah - cx is zero from the rep movsb above
|
xchg cx,ax ; clear ah - cx is zero from the rep movsb above
|
||||||
lodsb ; get 8 bit offset from stream in A
|
lodsb ; get 8 bit offset from stream in A
|
||||||
dec ah ; set offset bits 15-8 to 1
|
dec ah ; set offset bits 15-8 to 1
|
||||||
test dl,020H ; test bit Z (offset bit 8)
|
test dl,020H ; test bit Z (offset bit 8)
|
||||||
@ -120,9 +120,9 @@ lzsa2_decompress:
|
|||||||
xchg ah,al
|
xchg ah,al
|
||||||
|
|
||||||
.get_match_length:
|
.get_match_length:
|
||||||
mov bp,ax ; bp: offset
|
xchg bp,ax ; bp: offset
|
||||||
.repeat_match:
|
.repeat_match:
|
||||||
mov ax,dx ; ax: original token
|
xchg ax,dx ; ax: original token
|
||||||
and al,07H ; isolate match length in token (MMM)
|
and al,07H ; isolate match length in token (MMM)
|
||||||
add al,2 ; add MIN_MATCH_SIZE_V2
|
add al,2 ; add MIN_MATCH_SIZE_V2
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ lzsa2_decompress:
|
|||||||
|
|
||||||
.done_decompressing:
|
.done_decompressing:
|
||||||
pop ax ; retrieve the original decompression offset
|
pop ax ; retrieve the original decompression offset
|
||||||
xchg ax,di ; compute decompressed size
|
xchg di,ax ; compute decompressed size
|
||||||
sub ax,di
|
sub ax,di
|
||||||
ret ; done
|
ret ; done
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ lzsa2_decompress:
|
|||||||
|
|
||||||
xchg bx,ax
|
xchg bx,ax
|
||||||
lodsb ; load two nibbles
|
lodsb ; load two nibbles
|
||||||
xchg ax,bx
|
xchg bx,ax
|
||||||
|
|
||||||
.has_nibble:
|
.has_nibble:
|
||||||
mov cl,4 ; swap 4 high and low bits of nibble
|
mov cl,4 ; swap 4 high and low bits of nibble
|
||||||
|
Loading…
Reference in New Issue
Block a user