1 ; match.a -- optional optimized asm version of longest match in deflate.c
2 ; Copyright (C) 1992-1993 Jean-loup Gailly
3 ; This is free software; you can redistribute it and/or modify it under the
4 ; terms of the GNU General Public License, see the file COPYING.
6 ; $Id: match.a,v 1.1 1993/03/11 16:05:57 jloup Exp $
8 ; Adapted for the Amiga by Carsten Steger <stegerc@informatik.tu-muenchen.de>
9 ; using the code in match.S.
10 ; The major change in this code consists of removing all unaligned
11 ; word accesses, because they cause 68000-based Amigas to crash.
12 ; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc.
13 ; The program will then only run on 68020-based Amigas, though.
15 ; This code will run with registerized parameters too, unless SAS
16 ; changes parameter passing conventions between new releases of SAS/C.
19 Cur_Match reg d0 ; Must be in d0!
36 MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1
39 xref _max_chain_length
63 move.l 4(sp),Cur_Match
66 movem.l d2-d6/a2-a4,-(sp)
68 movem.l d2-d7/a2-a4,-(sp)
70 move.l _max_chain_length,Chain_Length
71 move.l _prev_length,Best_Len
72 lea _prev,Prev_Address
73 lea _window+MIN_MATCH,Match_Ini
74 move.l _strstart,Limit
75 move.l Match_Ini,Scan_Ini
77 subi.w #MAX_DIST,Limit
81 cmp.l _good_match,Best_Len
85 subq.l #1,Chain_Length
89 move.w -MIN_MATCH(Scan_Ini),Scan_Start
90 move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
94 move.b -MIN_MATCH(Scan_Ini),Scan_Start
96 move.b -MIN_MATCH+1(Scan_Ini),Scan_Start
97 move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
99 move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
109 move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
113 move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
115 move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
121 move.w 0(Prev_Address,Cur_Match),Cur_Match
122 cmp.w Limit,Cur_Match
123 dbls Chain_Length,do_scan
127 move.l Match_Ini,Match
128 add.l Cur_Match,Match
132 cmp.w -MIN_MATCH-1(Match,Best_Len),Scan_End
134 cmp.w -MIN_MATCH(Match),Scan_Start
139 move.b -MIN_MATCH-1(Match,Best_Len),Scan_Test
141 move.b -MIN_MATCH(Match,Best_Len),Scan_Test
142 cmp.w Scan_Test,Scan_End
144 move.b -MIN_MATCH(Match),Scan_Test
146 move.b -MIN_MATCH+1(Match),Scan_Test
147 cmp.w Scan_Test,Scan_Start
152 move.w #(MAX_MATCH-MIN_MATCH),Loop_Counter
155 cmpm.b (Match)+,(Scan)+
156 dbne Loop_Counter,scan_loop
159 addq.l #(MIN_MATCH-1),Scan
163 move.l Cur_Match,_match_start
164 cmp.l _nice_match,Best_Len
169 movem.l (sp)+,d2-d6/a2-a4
171 movem.l (sp)+,d2-d7/a2-a4