Article 72093 of comp.sys.cbm:
From: simonc@jumper.mcc.ac.uk (Cookie)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm
Subject: Re: Miss Manners's Guide To Programming
Followup-To: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm
Date: 25 Jul 1997 16:50:48 GMT
Organization: Sirius Cybernetics Corporation
Lines: 27
Message-ID: <5ralh8$9c7@yama.mcc.ac.uk>
References: <339d8a2a.3224107@news.demon.co.uk> <868571056.jce@ox.compsoc.org.uk> <11452.imc@comlab.ox.ac.uk> <Pine.PMDF.3.95.970714163250.676054565B-100000@cc.newcastle.edu.au> <5qmp3b$2g2@news.acns.nwu.edu>
NNTP-Posting-Host: jumper.mcc.ac.uk
X-Newsreader: TIN [version 1.2 PL2]
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.ece.nwu.edu!news.cse.psu.edu!news.math.psu.edu!chi-news.cic.net!howland.erols.net!cpk-news-hub1.bbnplanet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!theplanet.net!news.mite.net!uknet!yama.mcc.ac.uk!simonc
Xref: news.acns.nwu.edu comp.sys.sinclair:42117 comp.sys.cbm:72093 comp.emulators.cbm:23258

Stephen Judd (judd@merle.acns.nwu.edu) wrote:
: >	This is one thing that Z80 does better than the 6502, which crops
: >up in trying to build a set of Forth primitives for the 6502:

Hmmm... can anyone give me the timings for something like this (in 6502,
rather than my Z80 version)?

; B = value 1 XOR value 2
; C = value 1
; D = mask

  LD A,B
  AND D
  XOR C

BTW -- this routine takes values 1 and 2, and merges them. Wherever a bit
is set in the mask, value 1's corresponding bit will be placed. Wherever a
bit is reset, value 2's corresponding bit will appear.

Nice, quick bit merge -- lovely :)
(And yes, there is a reason for doing something like that)

--
+- Email:Simon.Cooke@umist.ac.uk ---- Fidonet: 2:250/124.2 (Simon Cooke) -+
|  Snail: 26 Woodhouse Lane, Sale, Cheshire, M33 4JX   Tel: 0161 976 3426 |
|  Message Pager: 01426 208084 (55p per min peak, 35ppm offpeak)          |
+- WWW: http://jumper.mcc.ac.uk/~simonc ----------------------------------+


Article 72132 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.ece.nwu.edu!news.cse.psu.edu!rutgers!news.cis.ohio-state.edu!news.maxwell.syr.edu!dispatch.news.demon.net!demon!powerfield.demon.co.uk!uzzy
From: Uzzy/Entropy <uzzy@powerfield.demon.nospam.co.uk>
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm
Subject: Re: Miss Manners's Guide To Programming
Date: Sat, 26 Jul 1997 18:30:16 +0100
Sender: Uzzy/Entropy <uzzy@powerfield.demon.co.uk>
Distribution: world
Message-ID: <ewokzGAoQj2zMwlt@powerfield.demon.co.uk>
References: <339d8a2a.3224107@news.demon.co.uk>
 <868571056.jce@ox.compsoc.org.uk> <11452.imc@comlab.ox.ac.uk>
 <Pine.PMDF.3.95.970714163250.676054565B-100000@cc.newcastle.edu.au>
 <5qmp3b$2g2@news.acns.nwu.edu> <5ralh8$9c7@yama.mcc.ac.uk>
NNTP-Posting-Host: powerfield.demon.co.uk
X-NNTP-Posting-Host: powerfield.demon.co.uk [194.222.143.72]
MIME-Version: 1.0
X-Newsreader: Turnpike Version 3.03a <OsIhttKrVQ$4$2oJXzqm1Pj39Z>
Lines: 54
Xref: news.acns.nwu.edu comp.sys.sinclair:42169 comp.sys.cbm:72132 comp.emulators.cbm:23289

In article <5ralh8$9c7@yama.mcc.ac.uk>, Cookie <simonc@jumper.mcc.ac.uk>
writes
>Stephen Judd (judd@merle.acns.nwu.edu) wrote:
>: >    This is one thing that Z80 does better than the 6502, which crops
>: >up in trying to build a set of Forth primitives for the 6502:
>
>Hmmm... can anyone give me the timings for something like this (in 6502,
>rather than my Z80 version)?
>
>; B = value 1 XOR value 2
>; C = value 1
>; D = mask
>
>  LD A,B
LD A,B probably isn't possible directly on the 6502.  Possibly, the
nearest 6502 equivalent is TXA or TYA.  Remember that the 6502 has only
three registers.

However, if "B", "C" and "D" are memory addresses, these are the
timings:

        LDA B           ; 4 cycles
        AND D           ; 4 cycles = 8 so far
        EOR C           ; 4 cycles = 12 in total

>  AND D
>  XOR C
>
>BTW -- this routine takes values 1 and 2, and merges them. Wherever a bit
>is set in the mask, value 1's corresponding bit will be placed. Wherever a
>bit is reset, value 2's corresponding bit will appear.
>
>Nice, quick bit merge -- lovely :)
>(And yes, there is a reason for doing something like that)
12 cycles.  Is that what you wanted to know?

Incidentally, under the 6502, this falls into the realms of "yes, but
when will I ever use it?"  To which the answer is "probably never".  The
only use for this I can see is dealing with I/O - which is memory mapped
on 6502, but not on Z80.

>
>--
>+- Email:Simon.Cooke@umist.ac.uk ---- Fidonet: 2:250/124.2 (Simon Cooke) -+
>|  Snail: 26 Woodhouse Lane, Sale, Cheshire, M33 4JX   Tel: 0161 976 3426 |
>|  Message Pager: 01426 208084 (55p per min peak, 35ppm offpeak)          |
>+- WWW: http://jumper.mcc.ac.uk/~simonc ----------------------------------+

+--------------------------------------------------------------+
| Entropy      -  Back from the flames of Hell  -      Entropy |
| Official Entropy Website - http://www.powerfield.demon.co.uk |
| Entropy archive online soon <> all legal 64 Entropy products |
| E-Mail: uzzy@powerfield.demon.co.uk <-- use only this E-Mail |
+--------------------------------------------------------------+


Article 72104 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm
Subject: Re: Miss Manners's Guide To Programming
Date: 26 Jul 1997 19:54:48 GMT
Organization: Northwestern University, Evanston, IL
Lines: 48
Message-ID: <5rdkm8$e42@news.acns.nwu.edu>
References: <339d8a2a.3224107@news.demon.co.uk> <Pine.PMDF.3.95.970714163250.676054565B-100000@cc.newcastle.edu.au> <5qmp3b$2g2@news.acns.nwu.edu> <5ralh8$9c7@yama.mcc.ac.uk>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.sinclair:42137 comp.sys.cbm:72104 comp.emulators.cbm:23268

Hello Simon,

In article <5ralh8$9c7@yama.mcc.ac.uk>, Cookie <simonc@jumper.mcc.ac.uk> wrote:
>Stephen Judd (judd@merle.acns.nwu.edu) wrote:

Actually, Bruce wrote this:

>: >	This is one thing that Z80 does better than the 6502, which crops
>: >up in trying to build a set of Forth primitives for the 6502:
>
>Hmmm... can anyone give me the timings for something like this (in 6502,
>rather than my Z80 version)?
>
>; B = value 1 XOR value 2
>; C = value 1
>; D = mask
>
>  LD A,B
>  AND D
>  XOR C

	LDA A
	AND D
	EOR C

Each instruction works the same way: if the argument is in non-zp memory, it 
takes 4 cycles; if in zero page, 3 cycles; if absolute (AND #$55), 2 cycles.

>BTW -- this routine takes values 1 and 2, and merges them. Wherever a bit
>is set in the mask, value 1's corresponding bit will be placed. Wherever a
>bit is reset, value 2's corresponding bit will appear.
>
>Nice, quick bit merge -- lovely :)
>(And yes, there is a reason for doing something like that)

Although I don't know what it is, I can certainly believe there is a reason :).

Here's another EOR trick: swap two values without using a temporary variable.

	A <- A EOR B
	B <- B EOR A
	A <- A EOR B

(Not very useful on a 6502 though :).

-S

>+- Email:Simon.Cooke@umist.ac.uk ---- Fidonet: 2:250/124.2 (Simon Cooke) -+


Article 72211 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.ece.nwu.edu!news.cse.psu.edu!uwm.edu!vixen.cso.uiuc.edu!howland.erols.net!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!baron.netcom.net.uk!netcom.net.uk!server3.netnews.ja.net!news.ox.ac.uk!news
From: imc@ecs.ox.ac.uk (Ian Collier)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm
Subject: Re: Miss Manners's Guide To Programming
Date: 28 Jul 1997 14:08:25 GMT
Organization: Oxford University Computing Laboratory
Lines: 30
Message-ID: <11569-oak.imc@comlab.ox.ac.uk>
References: <339d8a2a.3224107@news.demon.co.uk> <Pine.PMDF.3.95.970714163250.676054565B-100000@cc.newcastle.edu.au> <5qmp3b$2g2@news.acns.nwu.edu> <5ralh8$9c7@yama.mcc.ac.uk>
NNTP-Posting-Host: gruffle.comlab.ox.ac.uk
X-Local-Date: Monday, 28th July 1997 at 3:08pm BST
Xref: news.acns.nwu.edu comp.sys.sinclair:42261 comp.sys.cbm:72211 comp.emulators.cbm:23333

In article <5ralh8$9c7@yama.mcc.ac.uk>, simonc@jumper.mcc.ac.uk (Cookie) wrote:
>Hmmm... can anyone give me the timings for something like this (in 6502,
>rather than my Z80 version)?

>; B = value 1 XOR value 2
>; C = value 1
>; D = mask

>  LD A,B
   XOR C     (Well I know you said B had value 1 XOR value 2, but you don't
              often have the luxury of being able to calculate this
              beforehand.)
>  AND D
>  XOR C

>BTW -- this routine takes values 1 and 2, and merges them. Wherever a bit
>is set in the mask, value 1's corresponding bit will be placed. Wherever a
>bit is reset, value 2's corresponding bit will appear.

>Nice, quick bit merge -- lovely :)
>(And yes, there is a reason for doing something like that)

For instance, doing a patterned draw (D holds the pixels to be plotted,
value 2 is the pattern and value 1 is whatever was on the screen).  In
fact, there is a bit of xz80 which does this very operation for half-
toning the display (and in that case the values are available to be XORed
beforehand).
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


