diff --git a/asm/8088/decompress_small_v1.S b/asm/8088/decompress_small_v1.S index e691dde..e41e220 100755 --- a/asm/8088/decompress_small_v1.S +++ b/asm/8088/decompress_small_v1.S @@ -54,11 +54,12 @@ lzsa1_decompress: jne .mid_literals 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: - lodsb ; grab single extra length byte inc ah ; add 256 + lodsb ; grab single extra length byte .got_literals: xchg cx,ax @@ -67,16 +68,17 @@ lzsa1_decompress: test dl,dl ; check match offset size in token (O bit) 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 - dec ah - jmp short .get_match_length + .byte 3CH ; mask lodsw + ; (*like jmp short .get_match_length but faster) .get_long_offset: lodsw ; Get 2-byte match offset .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) add al,3 ; add MIN_MATCH_SIZE @@ -90,8 +92,13 @@ lzsa1_decompress: lodsw ; grab 16-bit length test ax,ax ; bail if we hit EOD - je short .done_decompressing - jmp short .got_matchlen + jne 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: lodsb ; grab single extra length byte @@ -109,9 +116,3 @@ lzsa1_decompress: xchg si,ax ; restore ds:si pop ds 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 diff --git a/asm/8088/decompress_small_v2.S b/asm/8088/decompress_small_v2.S index dcfc005..312274a 100755 --- a/asm/8088/decompress_small_v2.S +++ b/asm/8088/decompress_small_v2.S @@ -72,7 +72,7 @@ lzsa2_decompress: jnb .offset_9_bit ; 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 and al,dl shl al,1 @@ -85,7 +85,7 @@ lzsa2_decompress: jmp short .get_match_length .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 dec ah ; set offset bits 15-8 to 1 test dl,020H ; test bit Z (offset bit 8) @@ -120,9 +120,9 @@ lzsa2_decompress: xchg ah,al .get_match_length: - mov bp,ax ; bp: offset + xchg bp,ax ; bp: offset .repeat_match: - mov ax,dx ; ax: original token + xchg ax,dx ; ax: original token and al,07H ; isolate match length in token (MMM) add al,2 ; add MIN_MATCH_SIZE_V2 @@ -156,7 +156,7 @@ lzsa2_decompress: .done_decompressing: pop ax ; retrieve the original decompression offset - xchg ax,di ; compute decompressed size + xchg di,ax ; compute decompressed size sub ax,di ret ; done @@ -166,7 +166,7 @@ lzsa2_decompress: xchg bx,ax lodsb ; load two nibbles - xchg ax,bx + xchg bx,ax .has_nibble: mov cl,4 ; swap 4 high and low bits of nibble