--- pgp/src/zmatch.asm 2018/04/24 16:40:50 1.1.1.3 +++ pgp/src/zmatch.asm 2018/04/24 16:45:17 1.1.1.5 @@ -38,9 +38,9 @@ LCODE equ 1 ifndef DYN_ALLOC extrn _prev : word - extrn _window : byte + extrn _slide : byte prev equ _prev ; offset part - window equ _window + slide equ _slide endif _DATA segment word public 'DATA' @@ -51,15 +51,15 @@ _DATA segment word public 'DATA' extrn _max_chain_length : word ifdef DYN_ALLOC extrn _prev : word - extrn _window : word + extrn _slide : word prev equ 0 ; offset forced to zero - window equ 0 - window_seg equ _window[2] - window_off equ 0 -else - wseg dw seg _window - window_seg equ wseg - window_off equ offset _window + slide equ 0 + slide_seg equ _slide[2] + slide_off equ 0 +else + wseg dw seg _slide + slide_seg equ wseg + slide_off equ offset _slide endif _DATA ends @@ -107,12 +107,12 @@ else jne error endif ifdef DYN_ALLOC - mov ax,_window[0] ; force zero offset + mov ax,_slide[0] ; force zero offset add ax,15 mov cx,4 shr ax,cl - add _window[2],ax - mov _window[0],0 + add _slide[2],ax + mov _slide[0],0 mov ax,_prev[0] ; force zero offset add ax,15 @@ -161,7 +161,7 @@ if LCODE else cur_match equ word ptr [bp+4] endif -; window equ es:window (es:0 for DYN_ALLOC) +; slide equ es:slide (es:0 for DYN_ALLOC) ; prev equ ds:prev ; match equ es:si ; scan equ es:di @@ -177,9 +177,9 @@ endif jae limit_ok sub dx,dx ; limit = NIL limit_ok: - add di,2+window_off ; di = offset(window + strstart + 2) + add di,2+slide_off ; di = offset(slide + strstart + 2) mov bx,_prev_length ; best_len = prev_length - mov es,window_seg + mov es,slide_seg mov ax,es:[bx+di-3] ; ax = scan[best_len-1..best_len] mov cx,es:[di-2] ; cx = scan[0..1] cmp bx,_good_match ; do we have a good match already? @@ -209,15 +209,15 @@ endif cmp si,dx ; cur_match <= limit ? jbe the_end do_scan: - cmp ax,word ptr es:window[bx+si-1] ; check match at best_len-1 + cmp ax,word ptr es:slide[bx+si-1] ; check match at best_len-1 jne short_loop - cmp cx,word ptr es:window[si] ; check min_match_length match + cmp cx,word ptr es:slide[si] ; check min_match_length match jne short_loop - lea si,window[si+2] ; si = match + lea si,slide[si+2] ; si = match mov ax,di ; ax = scan+2 mov cx,es - mov ds,cx ; ds = es = window + mov ds,cx ; ds = es = slide mov cx,(MAX_MATCH-2)/2 ; scan for at most MAX_MATCH bytes repe cmpsw ; loop until mismatch je maxmatch ; match of length MAX_MATCH? @@ -226,8 +226,8 @@ mismatch: sub cl,[si-2] ; cl = 0 if first bytes equal xchg ax,di ; di = scan+2, ax = end of scan sub ax,di ; ax = len - sub si,ax ; si = cur_match + 2 + offset(window) - sub si,2+window_off ; si = cur_match + sub si,ax ; si = cur_match + 2 + offset(slide) + sub si,2+slide_off ; si = cur_match sub cl,1 ; set carry if cl == 0 (can't use DEC) adc ax,0 ; ax = carry ? len+1 : len cmp ax,bx ; len > best_len ?