Thread View: comp.lang.modula2
5 messages
5 total messages
Started by Chris Austin
Thu, 08 Feb 1996 11:40
XOR function
Author: Chris Austin
Date: Thu, 08 Feb 1996 11:40
Date: Thu, 08 Feb 1996 11:40
12 lines
752 bytes
752 bytes
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. Thanks for any help. p.s. All those that sent help on determining if there was a floppy in a disk drive, it was a big help, I now know how to do it. I just need the time. Chris Austin.
Re: XOR function
Author: "Mark Morgan Lloyd "
Date: Thu, 08 Feb 1996 18:16
Date: Thu, 08 Feb 1996 18:16
16 lines
676 bytes
676 bytes
MODULE Demo;
VAR a, b, c: CARDINAL;
BEGIN
IF SIZE(CARDINAL) <> SIZE(BITSET) THEN (* Paranoid? Me? *)
UserBreak
END;
c:= CARDINAL(BITSET(a) / BITSET(b))
END Demo.
Mark Morgan Lloyd
mark_tbu@cix.compulink.co.uk
[Opinions above are the author's, not those of his employers or
colleagues]
Re: XOR function
Author: Bengt-Inge Dalenback
Date: Mon, 12 Feb 1996 10:46
Date: Mon, 12 Feb 1996 10:46
28 lines
1873 bytes
1873 bytes
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. ....................................................................... Bengt-Inge Dalenback at: and: Department of Applied Acoustics CATT Chalmers University of Technology (Software for room acoustic Gothenburg, SWEDEN prediction and auralization) e-mail: bid@ta.chalmers.se e-mail: catt@netg.se
Re: XOR function
Author: 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 -----------------------------*------------------------------------
Re: XOR function
Author: Martin Tom Brown
Date: Fri, 16 Feb 1996 11:23
Date: Fri, 16 Feb 1996 11:23
32 lines
1877 bytes
1877 bytes
In article <533335858wnr@bcmrtc.demon.co.uk>
Rupert@bcmrtc.demon.co.uk "Rupert Toncic" writes:
> In article: <4fn5qu$ejm@nyheter.chalmers.se> Bengt-Inge Dalenback
> <bid@ta.chalmers.se> writes:
> > 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.
At least on the JPI compiler all bitset operations compile to the
appropriate 80x86 instructions so no need to use ASM for this.
I have always been very impressed with their code generator.
IIR Logitech compiler was a bit weak in this area.
(It may have improved recently I no longer use it)
Regards,
--
Martin Brown <martin@nezumi.demon.co.uk> __ CIS: 71651,470
Scientific Software Consultancy /^,,)__/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads