z80_unpacker: comment with possible LUT variant of updating probs value

missing 512 byte table generator, which doesn't look trivial to do
(especially in terms of code size).
Not tested, but looks as decent speed up.
This commit is contained in:
Peter Helcmanovsky (Ped)
2022-09-19 14:31:00 +02:00
parent a8fd3dc573
commit 9913dcf4bb

View File

@@ -316,6 +316,21 @@ decode_number:
jr c,.fix_bit_pos ; until stop bit is reached (all bits did land to correct position) jr c,.fix_bit_pos ; until stop bit is reached (all bits did land to correct position)
ret ; return with CF=0 (important for unpack routine) ret ; return with CF=0 (important for unpack routine)
DISPLAY "upkr.unpack total size: ",/D,$-unpack
; reserve space for probs array without emitting any machine code (using only EQU)
IFDEF UPKR_PROBS_ORIGIN ; if specific address is defined by user, move probs array there
probs: EQU ((UPKR_PROBS_ORIGIN) + 255) & -$100 ; probs array aligned to 256
ELSE
probs: EQU ($ + 255) & -$100 ; probs array aligned to 256
ENDIF
.real_c: EQU 1 + 255 + 1 + 2*NUMBER_BITS ; real size of probs array
.c: EQU (.real_c + 1) & -2 ; padding to even size (required by init code)
.e: EQU probs + .c
DISPLAY "upkr.unpack probs array placed at: ",/A,probs,",\tsize: ",/A,probs.c
/* /*
archived: negligibly faster but +6B longer decode_number variant using HL' and BC' to archived: negligibly faster but +6B longer decode_number variant using HL' and BC' to
do `number|=(1<<bit_pos);` type of logic in single loop. do `number|=(1<<bit_pos);` type of logic in single loop.
@@ -347,20 +362,20 @@ decode_number:
; pop de ; pop de
; ret ; ret
DISPLAY "upkr.unpack total size: ",/D,$-unpack /*
archived: possible LUT variant of updating probs value, requires 512-aligned 512B table (not tested)
; reserve space for probs array without emitting any machine code (using only EQU) */
; code is replacing decode_bit from "; *** adjust probs[context_index]", followed by `ld (bc),a : add a,d ...`
IFDEF UPKR_PROBS_ORIGIN ; if specific address is defined by user, move probs array there ; ld c,a
probs: EQU ((UPKR_PROBS_ORIGIN) + 255) & -$100 ; probs array aligned to 256 ; ld a,high(probs_update_table)/2 ; must be 512 aligned
ELSE ; rla
probs: EQU ($ + 255) & -$100 ; probs array aligned to 256 ; ld b,a
ENDIF ; ld a,(bc)
.real_c: EQU 1 + 255 + 1 + 2*NUMBER_BITS ; real size of probs array ; pop bc
.c: EQU (.real_c + 1) & -2 ; padding to even size (required by init code) ; -------------------------------------------
.e: EQU probs + .c ; probs_update_table: EQU probs-512
; -------------------------------------------
DISPLAY "upkr.unpack probs array placed at: ",/A,probs,",\tsize: ",/A,probs.c ; table generator is not obvious and probably not short either, 20+ bytes almost for sure, maybe even 30-40
ENDMODULE ENDMODULE
OPT pop OPT pop