Path: csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: CMOVE/CMOVE> Date: Wed, 19 Aug 2015 02:48:32 -0400 Organization: Aioe.org NNTP Server Lines: 59 Message-ID: References: <62627f57-1e63-4156-844a-db5708923aaf@googlegroups.com> <2015Aug18.180551@mips.complang.tuwien.ac.at> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:41391 On Tue, 18 Aug 2015 12:59:01 -0400, Mark Wills wrote: > On Tuesday, 18 August 2015 17:16:28 UTC+1, Anton Ertl wrote: >> Mark Wills writes: >> >I'm aware of the word MOVE which will choose to perform either a CMOVE >> >or CMOVE> depending on overlap and direction. My system doesn't have >> >MOVE though I'd like to implement it. >> > >> >Does anyone have any nice concise logic for checking the parameters and >> >calling either CMOVE or CMOVE> accordingly? >> >> : move ( from to count -- ) >> >r 2dup u< if >> r> cmove> >> else >> r> cmove >> then ; >> >> Better branch prediction accuracy: >> >> [...] > > That's nice code, thank you. Mine also included WITHIN but your first > example is neater IMO. I just tested it quickly and it seems to work fine. There is lots of useful information to be found in Google Groups archive of comp.lang.forth. BruceMcF Dec 2010 https://groups.google.com/d/msg/comp.lang.forth/zFEW7-NWJXM/rI8nbNsw9z0J His '>' should probably be 'U>'. His IF sections are reversed too. Michael L Gassanenko's CMOVE CMOVE> MOVE Mar 2002 https://groups.google.com/d/msg/comp.lang.forth/hYokH0zY9RY/xSFFFb2CSJ0J He has a slight variation for MOVE. He moves the duplicate R> outside the conditional. I have the same as Anton's, except the IF sections are reversed from Anton's, like BruceMcF did too, i.e., U> instead of U< . Both CMOVE and CMOVE> should perform the copy of the region if 'from' = 'to'. So, this shouldn't matter, unless there is an implementation issue with CMOVE or CMOVE> . I.e., it's possibly worth checking to make sure it actually works when 'from' = 'to'. If 'from' and 'to' are actually equal - unlikely, but possible - you might want to kick out of the definition, i.e., to not waste time doing a useless copy. Rod Pemberton -- Scientists now say we'll experience a mini-ice in 2030. So, I guess we need more global warming today ...