mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-12-23 07:29:30 +00:00
smaller
This commit is contained in:
parent
467cd1970f
commit
e85cb8a5bb
@ -65,27 +65,21 @@ lzsa2_decompress:
|
|||||||
xchg cx,ax
|
xchg cx,ax
|
||||||
rep movsb ; copy cx literals from ds:si to es:di
|
rep movsb ; copy cx literals from ds:si to es:di
|
||||||
|
|
||||||
test dl,dl ; check match offset mode in token (X bit)
|
test dl,0C0h ; check match offset mode in token (X bit)
|
||||||
js .rep_match_or_large_offset
|
js .rep_match_or_large_offset
|
||||||
|
|
||||||
cmp dl,040H ; check if this is a 5 or 9-bit offset (Y bit)
|
;;cmp dl,040H ; check if this is a 5 or 9-bit offset (Y bit)
|
||||||
jnb .offset_9_bit
|
; discovered via the test with bit 6 set
|
||||||
|
xchg cx,ax ; clear ah - cx is zero from the rep movsb above
|
||||||
|
jne .offset_9_bit
|
||||||
|
|
||||||
; 5 bit offset
|
; 5 bit offset
|
||||||
xchg cx,ax ; clear ah - cx is zero from the rep movsb above
|
cmp dl,020H ; test bit 5
|
||||||
mov al,020H ; shift Z (offset bit 4) in place
|
call .get_nibble_x
|
||||||
and al,dl
|
|
||||||
shl al,1
|
|
||||||
shl al,1
|
|
||||||
call .get_nibble ; get nibble for offset bits 0-3
|
|
||||||
or al,cl ; merge nibble
|
|
||||||
rol al,1
|
|
||||||
xor al,0E1H ; set offset bits 7-5 to 1
|
|
||||||
dec ah ; set offset bits 15-8 to 1
|
dec ah ; set offset bits 15-8 to 1
|
||||||
jmp short .get_match_length
|
jmp short .get_match_length
|
||||||
|
|
||||||
.offset_9_bit: ; 9 bit offset
|
.offset_9_bit: ; 9 bit offset
|
||||||
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)
|
||||||
@ -99,15 +93,11 @@ lzsa2_decompress:
|
|||||||
|
|
||||||
; 13 bit offset
|
; 13 bit offset
|
||||||
|
|
||||||
mov ah,020H ; shift Z (offset bit 12) in place
|
cmp dl,0A0H ; test bit 5 (knowing that bit 7 is also set)
|
||||||
and ah,dl
|
xchg ah,al
|
||||||
shl ah,1
|
call .get_nibble_x
|
||||||
shl ah,1
|
sub al,2 ; substract 512
|
||||||
call .get_nibble ; get nibble for offset bits 8-11
|
xchg ah,al
|
||||||
or ah,cl ; merge nibble
|
|
||||||
rol ah,1
|
|
||||||
xor ah,0E1H ; set offset bits 15-13 to 1
|
|
||||||
sub ah,2 ; substract 512
|
|
||||||
lodsb ; load match offset bits 0-7
|
lodsb ; load match offset bits 0-7
|
||||||
jmp short .get_match_length
|
jmp short .get_match_length
|
||||||
|
|
||||||
@ -160,6 +150,15 @@ lzsa2_decompress:
|
|||||||
sub ax,di
|
sub ax,di
|
||||||
ret ; done
|
ret ; done
|
||||||
|
|
||||||
|
.get_nibble_x:
|
||||||
|
cmc ; carry set if bit 4 was set
|
||||||
|
rcr al,1
|
||||||
|
call .get_nibble ; get nibble for offset bits 0-3
|
||||||
|
or al,cl ; merge nibble
|
||||||
|
rol al,1
|
||||||
|
xor al,0E1H ; set offset bits 7-5 to 1
|
||||||
|
ret
|
||||||
|
|
||||||
.get_nibble:
|
.get_nibble:
|
||||||
neg bh ; nibble ready?
|
neg bh ; nibble ready?
|
||||||
jns .has_nibble
|
jns .has_nibble
|
||||||
|
Loading…
Reference in New Issue
Block a user