Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6819 → Rev 6818

/programs/fs/kfar/trunk/zlib/deflate.asm
400,7 → 400,8
cmp dword[edi+deflate_state.head],Z_NULL
je .end3
cmp dword[edi+deflate_state.pending_buf],Z_NULL
jne @f
je .end3
jmp @f
.end3: ;if (..==0 || ..==0 || ..==0 || ..==0)
mov dword[edi+deflate_state.status],FINISH_STATE
ERR_MSG Z_MEM_ERROR
437,8 → 438,9
; const Bytef *dictionary
; uInt dictLength
align 4
proc deflateSetDictionary uses ebx ecx edx edi esi, strm:dword, dictionary:dword, dictLength:dword
proc deflateSetDictionary uses ebx edi, strm:dword, dictionary:dword, dictLength:dword
locals
; uInt str, n;
wrap dd ? ;int
avail dd ? ;unsigned
next dd ? ;unsigned char*
450,7 → 452,8
cmp edi,Z_NULL
je @f
cmp dword[dictionary],Z_NULL
jne .end0 ;if (..==0 || ..==0 || ..==0)
je @f ;if (..==0 || ..==0 || ..==0)
jmp .end0
@@:
mov eax,Z_STREAM_ERROR
jmp .end_f
483,71 → 486,40
mov eax,[edi+deflate_state.w_size]
cmp [dictLength],eax
jl .end2 ;if (..>=..)
cmp dword[wrap],0
jne @f ;if (..==0) ;already empty otherwise
CLEAR_HASH edi
mov dword[edi+deflate_state.strstart],0
mov dword[edi+deflate_state.block_start],0
mov dword[edi+deflate_state.insert],0
@@:
mov eax,[dictLength]
sub eax,[edi+deflate_state.w_size]
add [dictionary],eax ;use the tail
; if (wrap == 0) { /* already empty otherwise */
; CLEAR_HASH(s);
; s->strstart = 0;
; s->block_start = 0L;
; s->insert = 0;
; }
; dictionary += dictLength - s->w_size; /* use the tail */
mov eax,[edi+deflate_state.w_size]
mov [dictLength],eax
.end2:
 
; insert dictionary into window and hash
mov eax,[ebx+z_stream.avail_in]
mov [avail],eax
mov eax,[ebx+z_stream.next_in]
mov [next],eax
mov eax,[dictLength]
mov [ebx+z_stream.avail_in],eax
mov eax,[dictionary]
mov [ebx+z_stream.next_in],eax
stdcall fill_window, edi
.cycle0: ;while (..>=..)
mov ecx,[edi+deflate_state.lookahead]
cmp ecx,MIN_MATCH
jl .cycle0end
mov esi,[edi+deflate_state.strstart]
;esi = str
sub ecx,MIN_MATCH-1
.cycle1: ;do
mov eax,[edi+deflate_state.window]
add eax,esi
add eax,MIN_MATCH-1
movzx eax,byte[eax]
UPDATE_HASH edi, [edi+deflate_state.ins_h], eax
; avail = strm->avail_in;
; next = strm->next_in;
; strm->avail_in = dictLength;
; strm->next_in = (z_const Bytef *)dictionary;
; fill_window(s);
; while (s->lookahead >= MIN_MATCH) {
; str = s->strstart;
; n = s->lookahead - (MIN_MATCH-1);
; do {
; UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
if FASTEST eq 0
mov edx,[edi+deflate_state.ins_h]
shl edx,2
add edx,[edi+deflate_state.head]
mov edx,[edx] ;edx = s.head[s.ins_h]
mov eax,esi
and eax,[edi+deflate_state.w_mask]
shl eax,2
add eax,[edi+deflate_state.prev]
mov [eax],edx
; s->prev[str & s->w_mask] = s->head[s->ins_h];
end if
mov edx,[edi+deflate_state.ins_h]
shl edx,2
add edx,[edi+deflate_state.head]
mov [edx],esi ;s.head[s.ins_h] = str
inc esi
dec ecx
jnz .cycle1 ;while (--..)
mov [edi+deflate_state.strstart],esi
mov [edi+deflate_state.lookahead],MIN_MATCH-1
stdcall fill_window, edi
jmp .cycle0
align 4
.cycle0end:
mov eax,[edi+deflate_state.strstart]
add eax,[edi+deflate_state.lookahead]
mov [edi+deflate_state.strstart],eax
mov [edi+deflate_state.block_start],eax
; s->head[s->ins_h] = (Pos)str;
; str++;
; } while (--n);
; s->strstart = str;
; s->lookahead = MIN_MATCH-1;
; fill_window(s);
; }
; s->strstart += s->lookahead;
; s->block_start = (long)s->strstart;
mov eax,[edi+deflate_state.lookahead]
mov [edi+deflate_state.insert],eax
mov dword[edi+deflate_state.lookahead],0
580,7 → 552,8
cmp dword[ebx+z_stream.zalloc],0
je @f
cmp dword[ebx+z_stream.zfree],0
jne .end0 ;if (..==0 || ..==0 || ..==0 || ..==0)
je @f ;if (..==0 || ..==0 || ..==0 || ..==0)
jmp .end0
@@:
mov eax,Z_STREAM_ERROR
jmp .end_f
597,7 → 570,8
 
cmp dword[edi+deflate_state.wrap],0
jge @f ;if (..<0)
neg dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH)
neg dword[edi+deflate_state.wrap]
inc dword[edi+deflate_state.wrap] ;was made negative by deflate(..., Z_FINISH)
@@:
mov eax,BUSY_STATE
cmp dword[edi+deflate_state.wrap],0
1536,15 → 1510,17
; If avail_out is zero, the application will call deflate again
; to flush the rest.
 
cmp dword[edi+deflate_state.wrap],0
cmp dword[edi+deflate_state.pending],0
jle @f ;if (..>0) ;write the trailer only once!
neg dword[edi+deflate_state.wrap]
neg dword[edi+deflate_state.pending]
inc dword[edi+deflate_state.pending]
@@:
mov eax,Z_OK
cmp dword[edi+deflate_state.pending],0
jne .end_f
je .end_f
mov eax,Z_STREAM_END
.end_f:
zlib_debug ' deflate.ret = %d',eax
ret
endp
 
1755,6 → 1731,7
add [ebx+z_stream.total_in],eax
 
.end_f:
;zlib_debug ' read_buf.ret = %d',eax
ret
endp
 
1991,7 → 1968,8
cmp eax,[limit]
jle .cycle0end
dec dword[chain_length]
jnz .cycle0
cmp dword[chain_length],0
jne .cycle0
align 4
.cycle0end: ;while (..>.. && ..!=0)
 
2818,7 → 2796,6
je .cycle0 ;if (..)
FLUSH_BLOCK edi, 0
jmp .cycle0
align 4
.end2: ;else if (..)
cmp dword[edi+deflate_state.match_available],0
je .end3
2843,7 → 2820,7
jne .cycle0 ;if (..==0) return ..
mov eax,need_more
jmp .end_f
align 4
jmp .cycle0 ;.end4
.end3: ;else
; There is no previous match to compare with, wait for
; the next step to decide.
2851,6 → 2828,7
mov dword[edi+deflate_state.match_available],1
inc dword[edi+deflate_state.strstart]
dec dword[edi+deflate_state.lookahead]
;.end4:
jmp .cycle0
align 4
.cycle0end:
2953,7 → 2931,7
mov [edx+deflate_state.match_length],edi
mov eax,[edx+deflate_state.lookahead]
cmp [edx+deflate_state.match_length],eax
jle .end2 ;if (..>..)
jle .end2
mov [edx+deflate_state.match_length],eax
.end2:
mov eax,[edx+deflate_state.window_size]
3053,8 → 3031,9
dec dword[edi+deflate_state.lookahead]
inc dword[edi+deflate_state.strstart]
cmp dword[bflush],0
je .cycle0 ;if (..)
je @f ;if (..)
FLUSH_BLOCK edi, 0
@@:
jmp .cycle0
align 4
.cycle0end: