--- pgp/src/zmatch.S 2018/04/24 16:40:53 1.1 +++ pgp/src/zmatch.S 2018/04/24 16:45:20 1.1.1.2 @@ -19,9 +19,9 @@ .file "zmatch.S" -#ifdef SYSV +#if defined(SYSV) || defined(__ELF__) # define _prev prev -# define _window window +# define _slide slide # define _match_start match_start # define _prev_length prev_length # define _good_match good_match @@ -79,7 +79,7 @@ _longest_match: /* int longest_match(cur jae limit_ok sub %edx,%edx /* limit = NIL */ limit_ok: - add $_window+2,%edi /* edi = offset(window + strstart + 2) */ + add $_slide+2,%edi /* edi = offset(slide + strstart + 2) */ mov _prev_length,%ebx /* best_len = prev_length */ movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ movw -2(%edi),%cx /* cx = scan[0..1] */ @@ -92,7 +92,7 @@ limit_ok: long_loop: /* at this point, edi == scan+2, esi == cur_match */ movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ - movw -2(%edi),%cx /* cx = scan[0..1] */ + movw -2(%edi),%cx /* cx = scan[0..1] */ short_loop: dec %ebp /* --chain_length */ jz the_end @@ -100,20 +100,20 @@ short_loop: * ax = scan[best_len-1..best_len] and cx = scan[0..1] */ and $ WSIZE-1, %esi - movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */ + movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */ /* top word of esi is still 0 */ cmp %edx,%esi /* cur_match <= limit ? */ jbe the_end do_scan: - cmpw _window-1(%ebx,%esi),%ax/*check match at best_len-1 */ + cmpw _slide-1(%ebx,%esi),%ax/*check match at best_len-1 */ jne short_loop - cmpw _window(%esi),%cx /* check min_match_length match */ + cmpw _slide(%esi),%cx /* check min_match_length match */ jne short_loop - lea _window+2(%esi),%esi /* si = match */ + lea _slide+2(%esi),%esi /* si = match */ mov %edi,%eax /* ax = scan+2 */ mov $ MAX_MATCH2,%ecx /* scan for at most MAX_MATCH bytes */ -#ifdef SYSV +#if defined(SYSV) || defined(__ELF__) repz; cmpsw /* loop until mismatch */ #else repe; cmpsw @@ -124,8 +124,8 @@ mismatch: subb -2(%esi),%cl /* cl = 0 if first bytes equal */ xchg %edi,%eax /* edi = scan+2, eax = end of scan */ sub %edi,%eax /* eax = len */ - sub %eax,%esi /* esi = cur_match + 2 + offset(window) */ - sub $_window+2,%esi /* esi = cur_match */ + sub %eax,%esi /* esi = cur_match + 2 + offset(slide) */ + sub $_slide+2,%esi /* esi = cur_match */ subb $1,%cl /* set carry if cl == 0 (cannot use DEC) */ adc $0,%eax /* eax = carry ? len+1 : len */ cmp %ebx,%eax /* len > best_len ? */