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 ; Adapted for the Amiga by Carsten Steger <stegerc@informatik.tu-muenchen.de>
7 ; using the code in match.S.
8 ; The major change in this code consists of removing all unaligned
9 ; word accesses, because they cause 68000-based Amigas to crash.
10 ; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc.
11 ; The program will then only run on 68020-based Amigas, though.
13 ; This code will run with registerized parameters too, unless SAS
14 ; changes parameter passing conventions between new releases of SAS/C.
17 Cur_Match reg d0 ; Must be in d0!
34 MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1
37 xref _max_chain_length
61 move.l 4(sp),Cur_Match
64 movem.l d2-d6/a2-a4,-(sp)
66 movem.l d2-d7/a2-a4,-(sp)
68 move.l _max_chain_length,Chain_Length
69 move.l _prev_length,Best_Len
70 lea _prev,Prev_Address
71 lea _window+MIN_MATCH,Match_Ini
72 move.l _strstart,Limit
73 move.l Match_Ini,Scan_Ini
75 subi.w #MAX_DIST,Limit
79 cmp.l _good_match,Best_Len
83 subq.l #1,Chain_Length
87 move.w -MIN_MATCH(Scan_Ini),Scan_Start
88 move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
92 move.b -MIN_MATCH(Scan_Ini),Scan_Start
94 move.b -MIN_MATCH+1(Scan_Ini),Scan_Start
95 move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
97 move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
107 move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
111 move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
113 move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
119 move.w 0(Prev_Address,Cur_Match),Cur_Match
120 cmp.w Limit,Cur_Match
121 dbls Chain_Length,do_scan
125 move.l Match_Ini,Match
126 add.l Cur_Match,Match
130 cmp.w -MIN_MATCH-1(Match,Best_Len),Scan_End
132 cmp.w -MIN_MATCH(Match),Scan_Start
137 move.b -MIN_MATCH-1(Match,Best_Len),Scan_Test
139 move.b -MIN_MATCH(Match,Best_Len),Scan_Test
140 cmp.w Scan_Test,Scan_End
142 move.b -MIN_MATCH(Match),Scan_Test
144 move.b -MIN_MATCH+1(Match),Scan_Test
145 cmp.w Scan_Test,Scan_Start
150 move.w #(MAX_MATCH-MIN_MATCH),Loop_Counter
153 cmpm.b (Match)+,(Scan)+
154 dbne Loop_Counter,scan_loop
157 addq.l #(MIN_MATCH-1),Scan
161 move.l Cur_Match,_match_start
162 cmp.l _nice_match,Best_Len
167 movem.l (sp)+,d2-d6/a2-a4
169 movem.l (sp)+,d2-d7/a2-a4