home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / diffs / infozip / zip19p1 / match.s < prev   
Encoding:
Text File  |  1993-12-14  |  10.4 KB  |  236 lines

  1. *** orig/infozip/zip19p1/match.s    Sat Sep  4 15:55:44 1993
  2. --- src/infozip/zip19p1/match.s    Sat Sep  4 16:00:22 1993
  3. ***************
  4. *** 1,20 ****
  5. ! /
  6. ! / Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  7. ! / Kai Uwe Rommel and Igor Mandrichenko.
  8. ! / Permission is granted to any individual or institution to use, copy, or
  9. ! / redistribute this software so long as all of the original files are included
  10. ! / unmodified, that it is not sold for profit, and that this copyright notice
  11. ! / is retained.
  12. ! /
  13. ! / match.s by Jean-loup Gailly. Translated to 32 bit code by Kai Uwe Rommel.
  14. ! / match.s, optimized version of longest_match() in deflate.c
  15. ! / This version is for 386 Unix or OS/2 in 32 bit mode.
  16. ! / Warning: it uses the AT&T syntax: mov source,dest
  17. ! / This file is only optional. If you want to force the C version,
  18. ! / add -DNO_ASM to CFLAGS in makefile and remove match.o from OBJI).
  19. ! / If you have reduced WSIZE in zip.h, then change its value below.
  20. ! / This version assumes static allocation of the arrays (-DDYN_ALLOC not used).
  21.   
  22.       .file   "match.s"
  23.   
  24. --- 1,21 ----
  25. ! /* */
  26. ! /* Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly, */
  27. ! /* Kai Uwe Rommel and Igor Mandrichenko. */
  28. ! /* Permission is granted to any individual or institution to use, copy, or */
  29. ! /* redistribute this software so long as all of the original files are included */
  30. ! /* unmodified, that it is not sold for profit, and that this copyright notice */
  31. ! /* is retained. */
  32. ! /* */
  33. ! /* match.s by Jean-loup Gailly. Translated to 32 bit code by Kai Uwe Rommel. */
  34. ! /* syntax changed for gas 2.1.1 by DJ Delorie dj@ctron.com */
  35. ! /* match.s, optimized version of longest_match() in deflate.c */
  36. ! /* This version is for 386 Unix or OS/2 in 32 bit mode. */
  37. ! /* Warning: it uses the AT&T syntax: mov source,dest */
  38. ! /* This file is only optional. If you want to force the C version, */
  39. ! /* add -DNO_ASM to CFLAGS in makefile and remove match.o from OBJI). */
  40. ! /* If you have reduced WSIZE in zip.h, then change its value below. */
  41. ! /* This version assumes static allocation of the arrays (-DDYN_ALLOC not used). */
  42.   
  43.       .file   "match.s"
  44.   
  45. ***************
  46. *** 49,141 ****
  47.   _match_init:
  48.       ret
  49.   
  50. ! / -----------------------------------------------------------------------
  51. ! / Set match_start to the longest match starting at the given string and
  52. ! / return its length. Matches shorter or equal to prev_length are discarded,
  53. ! / in which case the result is equal to prev_length and match_start is
  54. ! / garbage.
  55. ! / IN assertions: cur_match is the head of the hash chain for the current
  56. ! /   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  57.   
  58.   _longest_match:    /* int longest_match(cur_match) */
  59.   
  60.   #define cur_match   20(%esp)
  61. !         / return address                / esp+16
  62. !         push    %ebp                    / esp+12
  63. !         push    %edi                    / esp+8
  64. !     push    %esi                    / esp+4
  65. !     push    %ebx            / esp
  66. ! /       match        equ esi
  67. ! /       scan         equ edi
  68. ! /       chain_length equ ebp
  69. ! /       best_len     equ ebx
  70. ! /       limit        equ edx
  71.   
  72.       mov     cur_match,%esi
  73. !         mov     _max_chain_length,%ebp  / chain_length = max_chain_length
  74.       mov     _strstart,%edi
  75.       mov     %edi,%edx
  76. !     sub    $ MAX_DIST,%edx         / limit = strstart-MAX_DIST
  77.       jae    limit_ok
  78. !     sub    %edx,%edx               / limit = NIL
  79.   limit_ok:
  80. !         add    $_window+2,%edi         / edi = offset(window + strstart + 2)
  81. !         mov    _prev_length,%ebx       / best_len = prev_length
  82. !         movw     -3(%ebx,%edi),%ax       / ax = scan[best_len-1..best_len]
  83. !         movw     -2(%edi),%cx            / cx = scan[0..1]
  84. !     cmp    _good_match,%ebx        / do we have a good match already?
  85.           jb      do_scan
  86. !     shr     $2,%ebp                 / chain_length >>= 2
  87.           jmp     do_scan
  88.   
  89.           .align  4
  90.   long_loop:
  91. ! / at this point, edi == scan+2, esi == cur_match
  92. !         movw    -3(%ebx,%edi),%ax       / ax = scan[best_len-1..best_len]
  93. !         movw     -2(%edi),%cx            / cx = scan[0..1]
  94.   short_loop:
  95. !         dec     %ebp                    / --chain_length
  96.           jz      the_end
  97. ! / at this point, di == scan+2, si == cur_match,
  98. ! / ax = scan[best_len-1..best_len] and cx = scan[0..1]
  99. !         and     $ WSIZE-1, %esi
  100. !         movw     _prev(%esi,%esi),%si    / cur_match = prev[cur_match]
  101. !                                         / top word of esi is still 0
  102. !         cmp     %edx,%esi        / cur_match <= limit ?
  103.           jbe     the_end
  104.   do_scan:
  105. !         cmpw    _window-1(%ebx,%esi),%ax /check match at best_len-1
  106.           jne     short_loop
  107. !         cmpw    _window(%esi),%cx       / check min_match_length match
  108.           jne     short_loop
  109.   
  110. !         lea     _window+2(%esi),%esi    / si = match
  111. !         mov     %edi,%eax               / ax = scan+2
  112. !         mov     $ MAX_MATCH2,%ecx       / scan for at most MAX_MATCH bytes
  113.   #ifdef unix
  114. !         repz;   cmpsw                   / loop until mismatch
  115.   #else
  116.           repe;   cmpsw
  117.   #endif
  118. !         je      maxmatch                / match of length MAX_MATCH?
  119.   mismatch:
  120. !         movb    -2(%edi),%cl            / mismatch on first or second byte?
  121. !         subb    -2(%esi),%cl            / cl = 0 if first bytes equal
  122. !         xchg    %edi,%eax               / edi = scan+2, eax = end of scan
  123. !         sub     %edi,%eax               / eax = len
  124. !     sub    %eax,%esi               / esi = cur_match + 2 + offset(window)
  125. !     sub    $_window+2,%esi         / esi = cur_match
  126. !         subb    $1,%cl                  / set carry if cl == 0 (cannot use DEC)
  127. !         adc     $0,%eax                 / eax = carry ? len+1 : len
  128. !         cmp     %ebx,%eax               / len > best_len ?
  129.           jle     long_loop
  130. !         mov     %esi,_match_start       / match_start = cur_match
  131. !         mov     %eax,%ebx               / ebx = best_len = len
  132. !         cmp     $ MAX_MATCH,%eax        / len >= MAX_MATCH ?
  133.           jl      long_loop
  134.   the_end:
  135. !         mov     %ebx,%eax               / result = eax = best_len
  136.       pop     %ebx
  137.           pop     %esi
  138.           pop     %edi
  139. --- 50,142 ----
  140.   _match_init:
  141.       ret
  142.   
  143. ! /* ----------------------------------------------------------------------- */
  144. ! /* Set match_start to the longest match starting at the given string and */
  145. ! /* return its length. Matches shorter or equal to prev_length are discarded, */
  146. ! /* in which case the result is equal to prev_length and match_start is */
  147. ! /* garbage. */
  148. ! /* IN assertions: cur_match is the head of the hash chain for the current */
  149. ! /*   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 */
  150.   
  151.   _longest_match:    /* int longest_match(cur_match) */
  152.   
  153.   #define cur_match   20(%esp)
  154. !         /* return address                / esp+16 */
  155. !         push    %ebp                    /* esp+12 */
  156. !         push    %edi                    /* esp+8 */
  157. !     push    %esi                    /* esp+4 */
  158. !     push    %ebx            /* esp */
  159. ! /*       match        equ esi */
  160. ! /*       scan         equ edi */
  161. ! /*       chain_length equ ebp */
  162. ! /*       best_len     equ ebx */
  163. ! /*       limit        equ edx */
  164.   
  165.       mov     cur_match,%esi
  166. !         mov     _max_chain_length,%ebp  /* chain_length = max_chain_length */
  167.       mov     _strstart,%edi
  168.       mov     %edi,%edx
  169. !     sub    $(MAX_DIST),%edx         /* limit = strstart-MAX_DIST */
  170.       jae    limit_ok
  171. !     sub    %edx,%edx               /* limit = NIL */
  172.   limit_ok:
  173. !         add    $_window+2,%edi         /* edi = offset(window + strstart + 2) */
  174. !         mov    _prev_length,%ebx       /* best_len = prev_length */
  175. !         movw     -3(%ebx,%edi),%ax       /* ax = scan[best_len-1..best_len] */
  176. !         movw     -2(%edi),%cx            /* cx = scan[0..1] */
  177. !     cmp    _good_match,%ebx        /* do we have a good match already? */
  178.           jb      do_scan
  179. !     shr     $2,%ebp                 /* chain_length >>= 2 */
  180.           jmp     do_scan
  181.   
  182.           .align  4
  183.   long_loop:
  184. ! /* at this point, edi == scan+2, esi == cur_match */
  185. !         movw    -3(%ebx,%edi),%ax       /* ax = scan[best_len-1..best_len] */
  186. !         movw     -2(%edi),%cx            /* cx = scan[0..1] */
  187.   short_loop:
  188. !         dec     %ebp                    /* --chain_length */
  189.           jz      the_end
  190. ! /* at this point, di == scan+2, si == cur_match, */
  191. ! /* ax = scan[best_len-1..best_len] and cx = scan[0..1] */
  192. !         and     $(WSIZE-1), %esi
  193. !         movw     _prev(%esi,%esi),%si    /* cur_match = prev[cur_match] */
  194. !                                         /* top word of esi is still 0 */
  195. !         cmp     %edx,%esi        /* cur_match <= limit ? */
  196.           jbe     the_end
  197.   do_scan:
  198. !         cmpw    _window-1(%ebx,%esi),%ax /* check match at best_len-1 */
  199.           jne     short_loop
  200. !         cmpw    _window(%esi),%cx       /* check min_match_length match */
  201.           jne     short_loop
  202.   
  203. !         lea     _window+2(%esi),%esi    /* si = match */
  204. !         mov     %edi,%eax               /* ax = scan+2 */
  205. !         mov     $(MAX_MATCH2),%ecx       /* scan for at most MAX_MATCH bytes */
  206.   #ifdef unix
  207. !         repz;   cmpsw                   /* loop until mismatch */
  208.   #else
  209.           repe;   cmpsw
  210.   #endif
  211. !         je      maxmatch                /* match of length MAX_MATCH? */
  212.   mismatch:
  213. !         movb    -2(%edi),%cl            /* mismatch on first or second byte? */
  214. !         subb    -2(%esi),%cl            /* cl = 0 if first bytes equal */
  215. !         xchg    %edi,%eax               /* edi = scan+2, eax = end of scan */
  216. !         sub     %edi,%eax               /* eax = len */
  217. !     sub    %eax,%esi               /* esi = cur_match + 2 + offset(window) */
  218. !     sub    $_window+2,%esi         /* esi = cur_match */
  219. !         subb    $1,%cl                  /* set carry if cl == 0 (cannot use DEC) */
  220. !         adc     $0,%eax                 /* eax = carry ? len+1 : len */
  221. !         cmp     %ebx,%eax               /* len > best_len ? */
  222.           jle     long_loop
  223. !         mov     %esi,_match_start       /* match_start = cur_match */
  224. !         mov     %eax,%ebx               /* ebx = best_len = len */
  225. !         cmp     $(MAX_MATCH),%eax       /* len >= MAX_MATCH ? */
  226.           jl      long_loop
  227.   the_end:
  228. !         mov     %ebx,%eax               /* result = eax = best_len */
  229.       pop     %ebx
  230.           pop     %esi
  231.           pop     %edi
  232.