mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-09-10 07:54:31 +00:00
slightly faster
This commit is contained in:
parent
3c50727421
commit
6f46c60259
@ -28,8 +28,6 @@
|
|||||||
; 3. This notice may not be removed or altered from any source distribution.
|
; 3. This notice may not be removed or altered from any source distribution.
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
OFFSHI = $43 ; zero-page location for temp offset
|
|
||||||
|
|
||||||
DECOMPRESS_LZSA1
|
DECOMPRESS_LZSA1
|
||||||
LDY #$00
|
LDY #$00
|
||||||
|
|
||||||
@ -51,13 +49,13 @@ DECODE_TOKEN
|
|||||||
|
|
||||||
JSR GETSRC ; get single extended byte of variable literals count
|
JSR GETSRC ; get single extended byte of variable literals count
|
||||||
INY ; add 256 to literals count
|
INY ; add 256 to literals count
|
||||||
JMP PREPARE_COPY_LITERALS
|
BCS PREPARE_COPY_LITERALS ; (*like JMP PREPARE_COPY_LITERALS but shorter)
|
||||||
|
|
||||||
LARGE_VARLEN_LITERALS ; handle 16 bits literals count
|
LARGE_VARLEN_LITERALS ; handle 16 bits literals count
|
||||||
; literals count = directly these 16 bits
|
; literals count = directly these 16 bits
|
||||||
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
||||||
TAY ; put high 8 bits in Y
|
TAY ; put high 8 bits in Y
|
||||||
JMP PREPARE_COPY_LITERALS_HIGH
|
BCS PREPARE_COPY_LITERALS_HIGH ; (*like JMP PREPARE_COPY_LITERALS_HIGH but shorter)
|
||||||
|
|
||||||
EMBEDDED_LITERALS
|
EMBEDDED_LITERALS
|
||||||
LSR A ; shift literals count into place
|
LSR A ; shift literals count into place
|
||||||
@ -103,8 +101,7 @@ PREPARE_COPY_MATCH_Y
|
|||||||
COPY_MATCH_LOOP
|
COPY_MATCH_LOOP
|
||||||
LDA $AAAA ; get one byte of backreference
|
LDA $AAAA ; get one byte of backreference
|
||||||
INC COPY_MATCH_LOOP+1
|
INC COPY_MATCH_LOOP+1
|
||||||
BNE GETMATCH_DONE
|
BEQ GETMATCH_INC_HI
|
||||||
INC COPY_MATCH_LOOP+2
|
|
||||||
GETMATCH_DONE
|
GETMATCH_DONE
|
||||||
JSR PUTDST ; copy to destination
|
JSR PUTDST ; copy to destination
|
||||||
DEX
|
DEX
|
||||||
@ -113,6 +110,10 @@ GETMATCH_DONE
|
|||||||
BNE COPY_MATCH_LOOP
|
BNE COPY_MATCH_LOOP
|
||||||
BEQ DECODE_TOKEN ; (*like JMP DECODE_TOKEN but shorter)
|
BEQ DECODE_TOKEN ; (*like JMP DECODE_TOKEN but shorter)
|
||||||
|
|
||||||
|
GETMATCH_INC_HI
|
||||||
|
INC COPY_MATCH_LOOP+2
|
||||||
|
BNE GETMATCH_DONE ; (*like JMP GETMATCH_DONE but shorter)
|
||||||
|
|
||||||
GET_LONG_OFFSET ; handle 16 bit offset:
|
GET_LONG_OFFSET ; handle 16 bit offset:
|
||||||
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
||||||
|
|
||||||
@ -122,7 +123,8 @@ GET_LONG_OFFSET ; handle 16 bit offset:
|
|||||||
CLC ; add dest + match offset
|
CLC ; add dest + match offset
|
||||||
ADC PUTDST+1 ; low 8 bits
|
ADC PUTDST+1 ; low 8 bits
|
||||||
STA COPY_MATCH_LOOP+1 ; store back reference address
|
STA COPY_MATCH_LOOP+1 ; store back reference address
|
||||||
LDA OFFSHI ; high 8 bits
|
OFFSHI = *+1
|
||||||
|
LDA #$AA ; high 8 bits
|
||||||
|
|
||||||
GOT_OFFSET
|
GOT_OFFSET
|
||||||
ADC PUTDST+2
|
ADC PUTDST+2
|
||||||
@ -146,8 +148,10 @@ GOT_OFFSET
|
|||||||
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
||||||
TAY ; put high 8 bits in Y
|
TAY ; put high 8 bits in Y
|
||||||
; large match length with zero high byte?
|
; large match length with zero high byte?
|
||||||
BEQ DECOMPRESSION_DONE ; if so, this is the EOD code, bail
|
BNE PREPARE_COPY_MATCH_Y ; if not, continue
|
||||||
BNE PREPARE_COPY_MATCH_Y ; (*like JMP PREPARE_COPY_MATCH_Y but shorter)
|
; (*like JMP PREPARE_COPY_MATCH_Y but shorter)
|
||||||
|
DECOMPRESSION_DONE
|
||||||
|
RTS
|
||||||
|
|
||||||
GETPUT
|
GETPUT
|
||||||
JSR GETSRC
|
JSR GETSRC
|
||||||
@ -156,10 +160,11 @@ LZSA_DST_LO = *+1
|
|||||||
LZSA_DST_HI = *+2
|
LZSA_DST_HI = *+2
|
||||||
STA $AAAA
|
STA $AAAA
|
||||||
INC PUTDST+1
|
INC PUTDST+1
|
||||||
BNE PUTDST_DONE
|
BEQ PUTDST_INC_HI
|
||||||
INC PUTDST+2
|
|
||||||
PUTDST_DONE
|
PUTDST_DONE
|
||||||
DECOMPRESSION_DONE
|
RTS
|
||||||
|
PUTDST_INC_HI
|
||||||
|
INC PUTDST+2
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
GETLARGESRC
|
GETLARGESRC
|
||||||
@ -172,7 +177,9 @@ LZSA_SRC_LO = *+1
|
|||||||
LZSA_SRC_HI = *+2
|
LZSA_SRC_HI = *+2
|
||||||
LDA $AAAA
|
LDA $AAAA
|
||||||
INC GETSRC+1
|
INC GETSRC+1
|
||||||
BNE GETSRC_DONE
|
BEQ GETSRC_INC_HI
|
||||||
INC GETSRC+2
|
|
||||||
GETSRC_DONE
|
GETSRC_DONE
|
||||||
RTS
|
RTS
|
||||||
|
GETSRC_INC_HI
|
||||||
|
INC GETSRC+2
|
||||||
|
RTS
|
||||||
|
@ -65,7 +65,7 @@ DECODE_TOKEN
|
|||||||
; literals count = directly these 16 bits
|
; literals count = directly these 16 bits
|
||||||
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
JSR GETLARGESRC ; grab low 8 bits in X, high 8 bits in A
|
||||||
TAY ; put high 8 bits in Y
|
TAY ; put high 8 bits in Y
|
||||||
JMP PREPARE_COPY_LITERALS_HIGH
|
BCS PREPARE_COPY_LITERALS_HIGH ; (*like JMP PREPARE_COPY_LITERALS_HIGH but shorter)
|
||||||
|
|
||||||
EMBEDDED_LITERALS
|
EMBEDDED_LITERALS
|
||||||
LSR A ; shift literals count into place
|
LSR A ; shift literals count into place
|
||||||
@ -144,7 +144,8 @@ REP_MATCH
|
|||||||
|
|
||||||
PLA ; retrieve token from stack again
|
PLA ; retrieve token from stack again
|
||||||
AND #$07 ; isolate match len (MMM)
|
AND #$07 ; isolate match len (MMM)
|
||||||
CLC
|
;;CLC ; carry cleared by high ADC above
|
||||||
|
; (assuming no overflow can occur)
|
||||||
ADC #$02 ; add MIN_MATCH_SIZE_V2
|
ADC #$02 ; add MIN_MATCH_SIZE_V2
|
||||||
CMP #$09 ; MIN_MATCH_SIZE_V2 + MATCH_RUN_LEN_V2?
|
CMP #$09 ; MIN_MATCH_SIZE_V2 + MATCH_RUN_LEN_V2?
|
||||||
BNE PREPARE_COPY_MATCH ; if less, length is directly embedded in token
|
BNE PREPARE_COPY_MATCH ; if less, length is directly embedded in token
|
||||||
@ -175,8 +176,7 @@ PREPARE_COPY_MATCH_Y
|
|||||||
COPY_MATCH_LOOP
|
COPY_MATCH_LOOP
|
||||||
LDA $AAAA ; get one byte of backreference
|
LDA $AAAA ; get one byte of backreference
|
||||||
INC COPY_MATCH_LOOP+1
|
INC COPY_MATCH_LOOP+1
|
||||||
BNE GETMATCH_DONE
|
BEQ GETMATCH_INC_HI
|
||||||
INC COPY_MATCH_LOOP+2
|
|
||||||
GETMATCH_DONE
|
GETMATCH_DONE
|
||||||
JSR PUTDST ; copy to destination
|
JSR PUTDST ; copy to destination
|
||||||
DEX
|
DEX
|
||||||
@ -184,6 +184,9 @@ GETMATCH_DONE
|
|||||||
DEY
|
DEY
|
||||||
BNE COPY_MATCH_LOOP
|
BNE COPY_MATCH_LOOP
|
||||||
JMP DECODE_TOKEN
|
JMP DECODE_TOKEN
|
||||||
|
GETMATCH_INC_HI
|
||||||
|
INC COPY_MATCH_LOOP+2
|
||||||
|
BNE GETMATCH_DONE ; (*like JMP GETMATCH_DONE but shorter)
|
||||||
|
|
||||||
GETCOMBINEDBITS
|
GETCOMBINEDBITS
|
||||||
STA FIXUP
|
STA FIXUP
|
||||||
@ -223,11 +226,13 @@ LZSA_DST_LO = *+1
|
|||||||
LZSA_DST_HI = *+2
|
LZSA_DST_HI = *+2
|
||||||
STA $AAAA
|
STA $AAAA
|
||||||
INC PUTDST+1
|
INC PUTDST+1
|
||||||
BNE PUTDST_DONE
|
BEQ PUTDST_INC_HI
|
||||||
INC PUTDST+2
|
|
||||||
PUTDST_DONE
|
PUTDST_DONE
|
||||||
DECOMPRESSION_DONE
|
DECOMPRESSION_DONE
|
||||||
RTS
|
RTS
|
||||||
|
PUTDST_INC_HI
|
||||||
|
INC PUTDST+2
|
||||||
|
RTS
|
||||||
|
|
||||||
GETLARGESRC
|
GETLARGESRC
|
||||||
JSR GETSRC ; grab low 8 bits
|
JSR GETSRC ; grab low 8 bits
|
||||||
@ -239,7 +244,9 @@ LZSA_SRC_LO = *+1
|
|||||||
LZSA_SRC_HI = *+2
|
LZSA_SRC_HI = *+2
|
||||||
LDA $AAAA
|
LDA $AAAA
|
||||||
INC GETSRC+1
|
INC GETSRC+1
|
||||||
BNE GETSRC_DONE
|
BEQ GETSRC_INC_HI
|
||||||
INC GETSRC+2
|
|
||||||
GETSRC_DONE
|
GETSRC_DONE
|
||||||
RTS
|
RTS
|
||||||
|
GETSRC_INC_HI
|
||||||
|
INC GETSRC+2
|
||||||
|
RTS
|
||||||
|
Loading…
Reference in New Issue
Block a user