cannam@89: ;uInt longest_match_x64( cannam@89: ; deflate_state *s, cannam@89: ; IPos cur_match); /* current match */ cannam@89: cannam@89: ; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86_64 cannam@89: ; (AMD64 on Athlon 64, Opteron, Phenom cannam@89: ; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) cannam@89: ; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. cannam@89: ; cannam@89: ; File written by Gilles Vollant, by converting to assembly the longest_match cannam@89: ; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. cannam@89: ; cannam@89: ; and by taking inspiration on asm686 with masm, optimised assembly code cannam@89: ; from Brian Raiter, written 1998 cannam@89: ; cannam@89: ; This software is provided 'as-is', without any express or implied cannam@89: ; warranty. In no event will the authors be held liable for any damages cannam@89: ; arising from the use of this software. cannam@89: ; cannam@89: ; Permission is granted to anyone to use this software for any purpose, cannam@89: ; including commercial applications, and to alter it and redistribute it cannam@89: ; freely, subject to the following restrictions: cannam@89: ; cannam@89: ; 1. The origin of this software must not be misrepresented; you must not cannam@89: ; claim that you wrote the original software. If you use this software cannam@89: ; in a product, an acknowledgment in the product documentation would be cannam@89: ; appreciated but is not required. cannam@89: ; 2. Altered source versions must be plainly marked as such, and must not be cannam@89: ; misrepresented as being the original software cannam@89: ; 3. This notice may not be removed or altered from any source distribution. cannam@89: ; cannam@89: ; cannam@89: ; cannam@89: ; http://www.zlib.net cannam@89: ; http://www.winimage.com/zLibDll cannam@89: ; http://www.muppetlabs.com/~breadbox/software/assembly.html cannam@89: ; cannam@89: ; to compile this file for infozip Zip, I use option: cannam@89: ; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm cannam@89: ; cannam@89: ; to compile this file for zLib, I use option: cannam@89: ; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm cannam@89: ; Be carrefull to adapt zlib1222add below to your version of zLib cannam@89: ; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change cannam@89: ; value of zlib1222add later) cannam@89: ; cannam@89: ; This file compile with Microsoft Macro Assembler (x64) for AMD64 cannam@89: ; cannam@89: ; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK cannam@89: ; cannam@89: ; (you can get Windows WDK with ml64 for AMD64 from cannam@89: ; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price) cannam@89: ; cannam@89: cannam@89: cannam@89: ;uInt longest_match(s, cur_match) cannam@89: ; deflate_state *s; cannam@89: ; IPos cur_match; /* current match */ cannam@89: .code cannam@89: longest_match PROC cannam@89: cannam@89: cannam@89: ;LocalVarsSize equ 88 cannam@89: LocalVarsSize equ 72 cannam@89: cannam@89: ; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 cannam@89: ; free register : r14,r15 cannam@89: ; register can be saved : rsp cannam@89: cannam@89: chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len cannam@89: ; low word: s->wmask cannam@89: ;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10 cannam@89: ;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11 cannam@89: ;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w cannam@89: ;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx cannam@89: ;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13 cannam@89: ;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d cannam@89: ;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9 cannam@89: IFDEF INFOZIP cannam@89: ELSE cannam@89: nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size cannam@89: ENDIF cannam@89: cannam@89: save_rdi equ rsp + 24 - LocalVarsSize cannam@89: save_rsi equ rsp + 32 - LocalVarsSize cannam@89: save_rbx equ rsp + 40 - LocalVarsSize cannam@89: save_rbp equ rsp + 48 - LocalVarsSize cannam@89: save_r12 equ rsp + 56 - LocalVarsSize cannam@89: save_r13 equ rsp + 64 - LocalVarsSize cannam@89: ;save_r14 equ rsp + 72 - LocalVarsSize cannam@89: ;save_r15 equ rsp + 80 - LocalVarsSize cannam@89: cannam@89: cannam@89: ; summary of register usage cannam@89: ; scanend ebx cannam@89: ; scanendw bx cannam@89: ; chainlenwmask edx cannam@89: ; curmatch rsi cannam@89: ; curmatchd esi cannam@89: ; windowbestlen r8 cannam@89: ; scanalign r9 cannam@89: ; scanalignd r9d cannam@89: ; window r10 cannam@89: ; bestlen r11 cannam@89: ; bestlend r11d cannam@89: ; scanstart r12d cannam@89: ; scanstartw r12w cannam@89: ; scan r13 cannam@89: ; nicematch r14d cannam@89: ; limit r15 cannam@89: ; limitd r15d cannam@89: ; prev rcx cannam@89: cannam@89: ; all the +4 offsets are due to the addition of pending_buf_size (in zlib cannam@89: ; in the deflate_state structure since the asm code was first written cannam@89: ; (if you compile with zlib 1.0.4 or older, remove the +4). cannam@89: ; Note : these value are good with a 8 bytes boundary pack structure cannam@89: cannam@89: cannam@89: MAX_MATCH equ 258 cannam@89: MIN_MATCH equ 3 cannam@89: MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) cannam@89: cannam@89: cannam@89: ;;; Offsets for fields in the deflate_state structure. These numbers cannam@89: ;;; are calculated from the definition of deflate_state, with the cannam@89: ;;; assumption that the compiler will dword-align the fields. (Thus, cannam@89: ;;; changing the definition of deflate_state could easily cause this cannam@89: ;;; program to crash horribly, without so much as a warning at cannam@89: ;;; compile time. Sigh.) cannam@89: cannam@89: ; all the +zlib1222add offsets are due to the addition of fields cannam@89: ; in zlib in the deflate_state structure since the asm code was first written cannam@89: ; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). cannam@89: ; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). cannam@89: ; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). cannam@89: cannam@89: cannam@89: IFDEF INFOZIP cannam@89: cannam@89: _DATA SEGMENT cannam@89: COMM window_size:DWORD cannam@89: ; WMask ; 7fff cannam@89: COMM window:BYTE:010040H cannam@89: COMM prev:WORD:08000H cannam@89: ; MatchLen : unused cannam@89: ; PrevMatch : unused cannam@89: COMM strstart:DWORD cannam@89: COMM match_start:DWORD cannam@89: ; Lookahead : ignore cannam@89: COMM prev_length:DWORD ; PrevLen cannam@89: COMM max_chain_length:DWORD cannam@89: COMM good_match:DWORD cannam@89: COMM nice_match:DWORD cannam@89: prev_ad equ OFFSET prev cannam@89: window_ad equ OFFSET window cannam@89: nicematch equ nice_match cannam@89: _DATA ENDS cannam@89: WMask equ 07fffh cannam@89: cannam@89: ELSE cannam@89: cannam@89: IFNDEF zlib1222add cannam@89: zlib1222add equ 8 cannam@89: ENDIF cannam@89: dsWSize equ 56+zlib1222add+(zlib1222add/2) cannam@89: dsWMask equ 64+zlib1222add+(zlib1222add/2) cannam@89: dsWindow equ 72+zlib1222add cannam@89: dsPrev equ 88+zlib1222add cannam@89: dsMatchLen equ 128+zlib1222add cannam@89: dsPrevMatch equ 132+zlib1222add cannam@89: dsStrStart equ 140+zlib1222add cannam@89: dsMatchStart equ 144+zlib1222add cannam@89: dsLookahead equ 148+zlib1222add cannam@89: dsPrevLen equ 152+zlib1222add cannam@89: dsMaxChainLen equ 156+zlib1222add cannam@89: dsGoodMatch equ 172+zlib1222add cannam@89: dsNiceMatch equ 176+zlib1222add cannam@89: cannam@89: window_size equ [ rcx + dsWSize] cannam@89: WMask equ [ rcx + dsWMask] cannam@89: window_ad equ [ rcx + dsWindow] cannam@89: prev_ad equ [ rcx + dsPrev] cannam@89: strstart equ [ rcx + dsStrStart] cannam@89: match_start equ [ rcx + dsMatchStart] cannam@89: Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip cannam@89: prev_length equ [ rcx + dsPrevLen] cannam@89: max_chain_length equ [ rcx + dsMaxChainLen] cannam@89: good_match equ [ rcx + dsGoodMatch] cannam@89: nice_match equ [ rcx + dsNiceMatch] cannam@89: ENDIF cannam@89: cannam@89: ; parameter 1 in r8(deflate state s), param 2 in rdx (cur match) cannam@89: cannam@89: ; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and cannam@89: ; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp cannam@89: ; cannam@89: ; All registers must be preserved across the call, except for cannam@89: ; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. cannam@89: cannam@89: cannam@89: cannam@89: ;;; Save registers that the compiler may be using, and adjust esp to cannam@89: ;;; make room for our stack frame. cannam@89: cannam@89: cannam@89: ;;; Retrieve the function arguments. r8d will hold cur_match cannam@89: ;;; throughout the entire function. edx will hold the pointer to the cannam@89: ;;; deflate_state structure during the function's setup (before cannam@89: ;;; entering the main loop. cannam@89: cannam@89: ; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) cannam@89: cannam@89: ; this clear high 32 bits of r8, which can be garbage in both r8 and rdx cannam@89: cannam@89: mov [save_rdi],rdi cannam@89: mov [save_rsi],rsi cannam@89: mov [save_rbx],rbx cannam@89: mov [save_rbp],rbp cannam@89: IFDEF INFOZIP cannam@89: mov r8d,ecx cannam@89: ELSE cannam@89: mov r8d,edx cannam@89: ENDIF cannam@89: mov [save_r12],r12 cannam@89: mov [save_r13],r13 cannam@89: ; mov [save_r14],r14 cannam@89: ; mov [save_r15],r15 cannam@89: cannam@89: cannam@89: ;;; uInt wmask = s->w_mask; cannam@89: ;;; unsigned chain_length = s->max_chain_length; cannam@89: ;;; if (s->prev_length >= s->good_match) { cannam@89: ;;; chain_length >>= 2; cannam@89: ;;; } cannam@89: cannam@89: mov edi, prev_length cannam@89: mov esi, good_match cannam@89: mov eax, WMask cannam@89: mov ebx, max_chain_length cannam@89: cmp edi, esi cannam@89: jl LastMatchGood cannam@89: shr ebx, 2 cannam@89: LastMatchGood: cannam@89: cannam@89: ;;; chainlen is decremented once beforehand so that the function can cannam@89: ;;; use the sign flag instead of the zero flag for the exit test. cannam@89: ;;; It is then shifted into the high word, to make room for the wmask cannam@89: ;;; value, which it will always accompany. cannam@89: cannam@89: dec ebx cannam@89: shl ebx, 16 cannam@89: or ebx, eax cannam@89: cannam@89: ;;; on zlib only cannam@89: ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; cannam@89: cannam@89: IFDEF INFOZIP cannam@89: mov [chainlenwmask], ebx cannam@89: ; on infozip nice_match = [nice_match] cannam@89: ELSE cannam@89: mov eax, nice_match cannam@89: mov [chainlenwmask], ebx cannam@89: mov r10d, Lookahead cannam@89: cmp r10d, eax cannam@89: cmovnl r10d, eax cannam@89: mov [nicematch],r10d cannam@89: ENDIF cannam@89: cannam@89: ;;; register Bytef *scan = s->window + s->strstart; cannam@89: mov r10, window_ad cannam@89: mov ebp, strstart cannam@89: lea r13, [r10 + rbp] cannam@89: cannam@89: ;;; Determine how many bytes the scan ptr is off from being cannam@89: ;;; dword-aligned. cannam@89: cannam@89: mov r9,r13 cannam@89: neg r13 cannam@89: and r13,3 cannam@89: cannam@89: ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? cannam@89: ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; cannam@89: IFDEF INFOZIP cannam@89: mov eax,07efah ; MAX_DIST = (WSIZE-MIN_LOOKAHEAD) (0x8000-(3+8+1)) cannam@89: ELSE cannam@89: mov eax, window_size cannam@89: sub eax, MIN_LOOKAHEAD cannam@89: ENDIF cannam@89: xor edi,edi cannam@89: sub ebp, eax cannam@89: cannam@89: mov r11d, prev_length cannam@89: cannam@89: cmovng ebp,edi cannam@89: cannam@89: ;;; int best_len = s->prev_length; cannam@89: cannam@89: cannam@89: ;;; Store the sum of s->window + best_len in esi locally, and in esi. cannam@89: cannam@89: lea rsi,[r10+r11] cannam@89: cannam@89: ;;; register ush scan_start = *(ushf*)scan; cannam@89: ;;; register ush scan_end = *(ushf*)(scan+best_len-1); cannam@89: ;;; Posf *prev = s->prev; cannam@89: cannam@89: movzx r12d,word ptr [r9] cannam@89: movzx ebx, word ptr [r9 + r11 - 1] cannam@89: cannam@89: mov rdi, prev_ad cannam@89: cannam@89: ;;; Jump into the main loop. cannam@89: cannam@89: mov edx, [chainlenwmask] cannam@89: cannam@89: cmp bx,word ptr [rsi + r8 - 1] cannam@89: jz LookupLoopIsZero cannam@89: cannam@89: LookupLoop1: cannam@89: and r8d, edx cannam@89: cannam@89: movzx r8d, word ptr [rdi + r8*2] cannam@89: cmp r8d, ebp cannam@89: jbe LeaveNow cannam@89: sub edx, 00010000h cannam@89: js LeaveNow cannam@89: cannam@89: LoopEntry1: cannam@89: cmp bx,word ptr [rsi + r8 - 1] cannam@89: jz LookupLoopIsZero cannam@89: cannam@89: LookupLoop2: cannam@89: and r8d, edx cannam@89: cannam@89: movzx r8d, word ptr [rdi + r8*2] cannam@89: cmp r8d, ebp cannam@89: jbe LeaveNow cannam@89: sub edx, 00010000h cannam@89: js LeaveNow cannam@89: cannam@89: LoopEntry2: cannam@89: cmp bx,word ptr [rsi + r8 - 1] cannam@89: jz LookupLoopIsZero cannam@89: cannam@89: LookupLoop4: cannam@89: and r8d, edx cannam@89: cannam@89: movzx r8d, word ptr [rdi + r8*2] cannam@89: cmp r8d, ebp cannam@89: jbe LeaveNow cannam@89: sub edx, 00010000h cannam@89: js LeaveNow cannam@89: cannam@89: LoopEntry4: cannam@89: cannam@89: cmp bx,word ptr [rsi + r8 - 1] cannam@89: jnz LookupLoop1 cannam@89: jmp LookupLoopIsZero cannam@89: cannam@89: cannam@89: ;;; do { cannam@89: ;;; match = s->window + cur_match; cannam@89: ;;; if (*(ushf*)(match+best_len-1) != scan_end || cannam@89: ;;; *(ushf*)match != scan_start) continue; cannam@89: ;;; [...] cannam@89: ;;; } while ((cur_match = prev[cur_match & wmask]) > limit cannam@89: ;;; && --chain_length != 0); cannam@89: ;;; cannam@89: ;;; Here is the inner loop of the function. The function will spend the cannam@89: ;;; majority of its time in this loop, and majority of that time will cannam@89: ;;; be spent in the first ten instructions. cannam@89: ;;; cannam@89: ;;; Within this loop: cannam@89: ;;; ebx = scanend cannam@89: ;;; r8d = curmatch cannam@89: ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) cannam@89: ;;; esi = windowbestlen - i.e., (window + bestlen) cannam@89: ;;; edi = prev cannam@89: ;;; ebp = limit cannam@89: cannam@89: LookupLoop: cannam@89: and r8d, edx cannam@89: cannam@89: movzx r8d, word ptr [rdi + r8*2] cannam@89: cmp r8d, ebp cannam@89: jbe LeaveNow cannam@89: sub edx, 00010000h cannam@89: js LeaveNow cannam@89: cannam@89: LoopEntry: cannam@89: cannam@89: cmp bx,word ptr [rsi + r8 - 1] cannam@89: jnz LookupLoop1 cannam@89: LookupLoopIsZero: cannam@89: cmp r12w, word ptr [r10 + r8] cannam@89: jnz LookupLoop1 cannam@89: cannam@89: cannam@89: ;;; Store the current value of chainlen. cannam@89: mov [chainlenwmask], edx cannam@89: cannam@89: ;;; Point edi to the string under scrutiny, and esi to the string we cannam@89: ;;; are hoping to match it up with. In actuality, esi and edi are cannam@89: ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is cannam@89: ;;; initialized to -(MAX_MATCH_8 - scanalign). cannam@89: cannam@89: lea rsi,[r8+r10] cannam@89: mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8) cannam@89: lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8] cannam@89: lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8] cannam@89: cannam@89: prefetcht1 [rsi+rdx] cannam@89: prefetcht1 [rdi+rdx] cannam@89: cannam@89: cannam@89: ;;; Test the strings for equality, 8 bytes at a time. At the end, cannam@89: ;;; adjust rdx so that it is offset to the exact byte that mismatched. cannam@89: ;;; cannam@89: ;;; We already know at this point that the first three bytes of the cannam@89: ;;; strings match each other, and they can be safely passed over before cannam@89: ;;; starting the compare loop. So what this code does is skip over 0-3 cannam@89: ;;; bytes, as much as necessary in order to dword-align the edi cannam@89: ;;; pointer. (rsi will still be misaligned three times out of four.) cannam@89: ;;; cannam@89: ;;; It should be confessed that this loop usually does not represent cannam@89: ;;; much of the total running time. Replacing it with a more cannam@89: ;;; straightforward "rep cmpsb" would not drastically degrade cannam@89: ;;; performance. cannam@89: cannam@89: cannam@89: LoopCmps: cannam@89: mov rax, [rsi + rdx] cannam@89: xor rax, [rdi + rdx] cannam@89: jnz LeaveLoopCmps cannam@89: cannam@89: mov rax, [rsi + rdx + 8] cannam@89: xor rax, [rdi + rdx + 8] cannam@89: jnz LeaveLoopCmps8 cannam@89: cannam@89: cannam@89: mov rax, [rsi + rdx + 8+8] cannam@89: xor rax, [rdi + rdx + 8+8] cannam@89: jnz LeaveLoopCmps16 cannam@89: cannam@89: add rdx,8+8+8 cannam@89: cannam@89: jnz short LoopCmps cannam@89: jmp short LenMaximum cannam@89: LeaveLoopCmps16: add rdx,8 cannam@89: LeaveLoopCmps8: add rdx,8 cannam@89: LeaveLoopCmps: cannam@89: cannam@89: test eax, 0000FFFFh cannam@89: jnz LenLower cannam@89: cannam@89: test eax,0ffffffffh cannam@89: cannam@89: jnz LenLower32 cannam@89: cannam@89: add rdx,4 cannam@89: shr rax,32 cannam@89: or ax,ax cannam@89: jnz LenLower cannam@89: cannam@89: LenLower32: cannam@89: shr eax,16 cannam@89: add rdx,2 cannam@89: LenLower: sub al, 1 cannam@89: adc rdx, 0 cannam@89: ;;; Calculate the length of the match. If it is longer than MAX_MATCH, cannam@89: ;;; then automatically accept it as the best possible match and leave. cannam@89: cannam@89: lea rax, [rdi + rdx] cannam@89: sub rax, r9 cannam@89: cmp eax, MAX_MATCH cannam@89: jge LenMaximum cannam@89: cannam@89: ;;; If the length of the match is not longer than the best match we cannam@89: ;;; have so far, then forget it and return to the lookup loop. cannam@89: ;/////////////////////////////////// cannam@89: cannam@89: cmp eax, r11d cannam@89: jg LongerMatch cannam@89: cannam@89: lea rsi,[r10+r11] cannam@89: cannam@89: mov rdi, prev_ad cannam@89: mov edx, [chainlenwmask] cannam@89: jmp LookupLoop cannam@89: cannam@89: ;;; s->match_start = cur_match; cannam@89: ;;; best_len = len; cannam@89: ;;; if (len >= nice_match) break; cannam@89: ;;; scan_end = *(ushf*)(scan+best_len-1); cannam@89: cannam@89: LongerMatch: cannam@89: mov r11d, eax cannam@89: mov match_start, r8d cannam@89: cmp eax, [nicematch] cannam@89: jge LeaveNow cannam@89: cannam@89: lea rsi,[r10+rax] cannam@89: cannam@89: movzx ebx, word ptr [r9 + rax - 1] cannam@89: mov rdi, prev_ad cannam@89: mov edx, [chainlenwmask] cannam@89: jmp LookupLoop cannam@89: cannam@89: ;;; Accept the current string, with the maximum possible length. cannam@89: cannam@89: LenMaximum: cannam@89: mov r11d,MAX_MATCH cannam@89: mov match_start, r8d cannam@89: cannam@89: ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; cannam@89: ;;; return s->lookahead; cannam@89: cannam@89: LeaveNow: cannam@89: IFDEF INFOZIP cannam@89: mov eax,r11d cannam@89: ELSE cannam@89: mov eax, Lookahead cannam@89: cmp r11d, eax cannam@89: cmovng eax, r11d cannam@89: ENDIF cannam@89: cannam@89: ;;; Restore the stack and return from whence we came. cannam@89: cannam@89: cannam@89: mov rsi,[save_rsi] cannam@89: mov rdi,[save_rdi] cannam@89: mov rbx,[save_rbx] cannam@89: mov rbp,[save_rbp] cannam@89: mov r12,[save_r12] cannam@89: mov r13,[save_r13] cannam@89: ; mov r14,[save_r14] cannam@89: ; mov r15,[save_r15] cannam@89: cannam@89: cannam@89: ret 0 cannam@89: ; please don't remove this string ! cannam@89: ; Your can freely use gvmat64 in any free or commercial app cannam@89: ; but it is far better don't remove the string in the binary! cannam@89: db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 cannam@89: longest_match ENDP cannam@89: cannam@89: match_init PROC cannam@89: ret 0 cannam@89: match_init ENDP cannam@89: cannam@89: cannam@89: END