Article View: comp.lang.modula2
Article #3291Re: XOR function
From: Rupert Toncic
Date: Fri, 16 Feb 1996 01:24
Date: Fri, 16 Feb 1996 01:24
53 lines
2919 bytes
2919 bytes
In article: <4fn5qu$ejm@nyheter.chalmers.se> Bengt-Inge Dalenback <bid@ta.chalmers.se> writes: > Path: demon.co.uk!news.demon.co.uk!demon!tank.news.pipex.net!pipex!news.mathworks.com!news.kei.com!nntp.coast.net!news00.sunet.se! sunic!news99.sunet.se!news.chalmers.se!g0-mac7.ta.chalmers.se!bid > From: Bengt-Inge Dalenback <bid@ta.chalmers.se> > Newsgroups: comp.lang.modula2 > Subject: Re: XOR function > Date: 12 Feb 1996 10:46:54 GMT > Organization: CATT & Dep. of Applied Acoustics, Chalmers > Lines: 28 > Distribution: world > Message-ID: <4fn5qu$ejm@nyheter.chalmers.se> > References: <1996Feb8.114044.15072@ucl.ac.uk> > NNTP-Posting-Host: g0-mac7.ta.chalmers.se > Mime-Version: 1.0 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: 8bit > X-Newsreader: Nuntius 2.0.1_68K > X-XXMessage-ID: <AD44D99ED401B84A@g0-mac7.ta.chalmers.se> > X-XXDate: Mon, 12 Feb 1996 10:48:46 GMT > > In article <1996Feb8.114044.15072@ucl.ac.uk> Chris Austin, > zcaccau@cs.ucl.ac.uk writes: > >Is there an XOR function in Topspeed Modula-2 V3.something. I want to be > >able to XOR either 2 cardinals or 2 BITSETs, so if there isn't a function, > >what is the best way to implement it. I need speed, not simplicity, as this > >is for graphics routines. > > > > I just yesterday needed that to create a XOR checksum required for the > Windows "placeable" Meta-file header! > > Low-level tricks like that can be done using SET operations. XOR is "/" > which means for A, B and C CARDINALs: > > "C = A XOR B" <=> C := CARDINAL( BITSET(A) / BITSET(B) ); > > Check out the "TopSpeed Language Tutorial" on SETs in case I remembered > it wrong. TopSpeed also has a "bitwise boolean operator" pragma that > sometimes > can be handy but which of course is nonportable. > It may also me much quicker to use the assembly language routine. You could use the Visual Debuger to view the asam code and see which is the quickest. XOR as a machine instrction between to 16 bit registers is about 2 clock cycles. -- -----------------------------*------------------------------------ Rupert Toncic | BCM RTC, London, WC1N 3XX, UK. Rupert@bcmrtc.demon.co.uk | Voice +44 956 275 144 -----------------------------*------------------------------------
Technical Details
Message-ID:
<533335858wnr@bcmrtc.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!bcmrtc.demon.co.ukReferences:
<1996Feb8.114044.15072@ucl.ac.uk> <4fn5qu$ejm@nyheter.chalmers.se>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!bcmrtc.demon.co.uk From: Rupert Toncic <Rupert@bcmrtc.demon.co.uk> Newsgroups: comp.lang.modula2 Subject: Re: XOR function Date: Fri, 16 Feb 1996 01:24:45 GMT Organization: R T Consultants Message-ID: <533335858wnr@bcmrtc.demon.co.uk> References: <1996Feb8.114044.15072@ucl.ac.uk> <4fn5qu$ejm@nyheter.chalmers.se> Reply-To: Rupert@bcmrtc.demon.co.uk X-NNTP-Posting-Host: bcmrtc.demon.co.uk X-Broken-Date: Friday, Feb 16, 1996 01.24.45 X-Newsreader: Newswin Alpha 0.7 X-Mail2News-Path: disperse.demon.co.uk!post.demon.co.uk!bcmrtc.demon.co.uk