Subject: no subject (file transmission)

From: [email-masked] (Stephen Judd)
Date: Sun, 29 Jun 1997 11:15:30 -0500 (CDT)

Article 69563 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!europa.clark.net!dispatch.news.demon.net!demon!delos.dra.hmg.gb!server1.netnews.ja.net!warwick!yama.mcc.ac.uk!simonc
From: [email-masked] (Cookie)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Followup-To: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Date: 16 Jun 1997 13:06:17 GMT
Organization: Sirius Cybernetics Corporation
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc6f79$486f2220$04b8de8b@w9622136> <[email-masked]> <01bc7126$447a6860$04b8de8b@w9622136> <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]>
NNTP-Posting-Host: jumper.mcc.ac.uk
X-Newsreader: TIN [version 1.2 PL2]
Lines: 28
Xref: news.acns.nwu.edu comp.sys.sinclair:39982 comp.sys.cbm:69563 comp.emulators.cbm:21720 comp.sys.amstrad.8bit:6973

Cliff Lawson ([email-masked]) wrote:
:  Spike wrote in article <[email-masked]>...
: Well a routine that serves no real practical purpose (OK, it might in
: processing graphics) is to work out the shortest / quickest routine to
: reverse the bits in a byte so that, for example 10100111 becomes 11100101.
: It's the kind of question I'd ask prospective employees to see if they know
: their onions. (It may not be relevant but I'm always impressed by people
: who manage to work in the use of an EX SP,(HL) in there somewhere!).

Shortest (A = result on exit, on entry C contains number to reverse)

      LD B,8
loop: RR C
      RLA
      DJNZ loop

Quickest: (L = number to revcerser on entry, = result on exit) (lag!
excuse typos)

LD H,table_of_bytes/256
LD A,(HL)

:)

SImon

Article 69581 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.ece.nwu.edu!news.cse.psu.edu!uwm.edu!chi-news.cic.net!howland.erols.net!agate!nntpfeed.doc.ic.ac.uk!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!news
From: [email-masked] (Ian Collier)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: 16 Jun 1997 16:38:50 GMT
Organization: Oxford University Computing Laboratory, UK
Lines: 21
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]>
NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
X-Local-Date: Monday, 16th June 1997 at 5:38pm BST
Xref: news.acns.nwu.edu comp.sys.sinclair:39995 comp.sys.cbm:69581 comp.emulators.cbm:21734 comp.sys.amstrad.8bit:6974

In article <[email-masked]>, "Cliff Lawson" <[email-masked]> wrote:
>Well a routine that serves no real practical purpose (OK, it might in
>processing graphics) is to work out the shortest / quickest routine to
>reverse the bits in a byte so that, for example 10100111 becomes 11100101.

{RRA:RL C} x 8 : LD A,C

(saving BC and coding a loop is at the reader's discretion. :-) )

>It's the kind of question I'd ask prospective employees to see if they know
>their onions. (It may not be relevant but I'm always impressed by people
>who manage to work in the use of an EX SP,(HL) in there somewhere!).

I'd be surprised if one turned up during that exercise!  There are cases
where I've used it, however, for example during a long division or a
ROM call (where you say, for instance, "CALL myroutine: DEFW 123" to
page in a particular ROM and call the routine at 123 with all the registers
intact).
-- 
---- Ian Collier : [email-masked] : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html

Article 69610 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!math.ohio-state.edu!uwm.edu!vixen.cso.uiuc.edu!howland.erols.net!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!158.152.1.94!dispatch.news.demon.net!demon!easynet-uk!easynet-uko!news.ukonline.co.uk!not-for-mail
From: "Cliff Lawson" <[email-masked]>
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: Tue, 17 Jun 1997 10:44:04 +0100
Organization: Amstrad plc
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]> <[email-masked]>
NNTP-Posting-Host: lon5-7.ukonline.co.uk
X-Newsreader: Microsoft Outlook Express 4.71.0544.0
X-MimeOLE: Produced By Microsoft MimeOLE Engine V4.71.0544.0
Lines: 30
Xref: news.acns.nwu.edu comp.sys.sinclair:40023 comp.sys.cbm:69610 comp.emulators.cbm:21753 comp.sys.amstrad.8bit:6991

 Ian Collier wrote in article <[email-masked]>...
>>(It may not be relevant but I'm always impressed by people
>>who manage to work in the use of an EX SP,(HL) in there somewhere!).
>
>I'd be surprised if one turned up during that exercise!  

That's what I meant by "It may not be relevant" but it does come into play
for the solutions for some other 5 line "teasers" that test people's
ability to demonstrate a good understanding of code.

Another good question is, without looking it up, what are the opcodes for 
LD A,37  
LD HL,1234 (OK easy peasy!)
IN A,(C) (maybe not quite so easy?)
LDIR
DEC (HL)

That last one definitely shows signs of a mis-spent youth (not necessarily
a bad thing!) as it is the code you'd probably be searching for when
hacking a game and trying to find the bit that decrements the "lives"
counter. (Guess who had a mis-spent youth!). 
Games that used DEC (HL) included JSW, Manic Miner, Knightlore, amongst
others.

Cliff (who used to be able to crack DJL loaders in his sleep! - bloody LD
A,R's!)

Article 69554 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: [email-masked] (Stephen Judd)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: 16 Jun 1997 21:19:43 GMT
Organization: Northwestern University, Evanston, IL
Lines: 37
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]>
Reply-To: [email-masked] (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.sinclair:39972 comp.sys.cbm:69554 comp.emulators.cbm:21710 comp.sys.amstrad.8bit:6967

In article <[email-masked]>,
Cliff Lawson <[email-masked]> wrote:
>
>Well a routine that serves no real practical purpose (OK, it might in
>processing graphics) is to work out the shortest / quickest routine to
>reverse the bits in a byte so that, for example 10100111 becomes 11100101.
>It's the kind of question I'd ask prospective employees to see if they know
>their onions. (It may not be relevant but I'm always impressed by people
>who manage to work in the use of an EX SP,(HL) in there somewhere!).

It is practical: it is part of any FFT routine.  In fact, I once used my
128 to double-check a routine I wrote, because it's so incredibly simple
to do with an ML monitor.

	LDY #00
BIGLOOP	STY $FF
	LDX #8		;Or however many bits to reverse
:LOOP	LSR $FF
	ROL
	DEX
	BNE :LOOP
	STA TABLE,Y	;Table of reversed bit-positions
	INY
	BNE BIGLOOP

The C version, on the other hand, is not such a pretty sight. :)

Want to give me a job now? :)

	-Steve

>=======================================
>mailto:[email-masked]
>http://web.ukonline.co.uk/cliff.lawson/index.htm
>=======================================

Didn't I just read that Amstrad is breaking up?

Article 69603 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!europa.clark.net!dispatch.news.demon.net!demon!mail2news.demon.co.uk!not-for-mail
From: Jason <[email-masked]>
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Followup-To: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Date: Mon, 16 Jun 97 21:15:14 GMT
Organization: Cosine Systems
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc6f79$486f2220$04b8de8b@w9622136> <[email-masked]> <01bc7126$447a6860$04b8de8b@w9622136> <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <
X-Mail2News-User: [email-masked]
X-Mail2News-Path: relay-1.mail.demon.net!gate.demon.co.uk!cosine.demon.co.uk
X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
Lines: 31
Xref: news.acns.nwu.edu comp.sys.sinclair:40016 comp.sys.cbm:69603 comp.emulators.cbm:21747 comp.sys.amstrad.8bit:6981

Cliff Lawson:
> Well a routine that serves no real practical purpose (OK, it might in
> processing graphics) is to work out the shortest / quickest routine to
> reverse the bits in a byte so that, for example 10100111 becomes 11100101.
> It's the kind of question I'd ask prospective employees to see if they know
> their onions. (It may not be relevant but I'm always impressed by people
> who manage to work in the use of an EX SP,(HL) in there somewhere!).

Okay, this'll do it in 6502 (and I don't claim it to be most efficient,
okay? =-) with the start value in zeropage location $02 and the end value
in the accumulator at the end.

     LDX #$07
LOOP ASL $02
     ROR
     DEX
     BPL LOOP

The *very* fastest way to do it is to precalculate all 256 combinations to
a table and when you want to do a conversion just put the original number
in the X register and go LDA table,X to get the answer in the accumulator.
--
Jason  =-)
     _______________________________________________________________________
TMR /     /     /     /  /     /     /                                     /\
   /  /__/  /  /  /__/  /  /  /  /__/    Email: [email-masked]    / /
  /  /\_/  /  /__   /  /  /  /  __//          Cosine Homepage:           / /
 /  /__/  /  /  /  /  /  /  /  /  /    http://www.cosine.demon.co.uk    / /
/_____/_____/_____/__/__/__/_____/_____________________________________/ /
\_____\_____\_____\__\__\__\_____\_____________________________________\/

Article 69964 of comp.sys.cbm:
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!news.maxwell.syr.edu!nildram!Aladdin!aladdin.net!ns2.aladdin.net!RMplc!rmplc.co.uk!yama.mcc.ac.uk!nntpfeed.doc.ic.ac.uk!sunsite.doc.ic.ac.uk!qmw!news
From: Simon Matthews <[email-masked]>
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: Fri, 20 Jun 1997 16:22:37 -0700
Organization: Better Than Life.  Remove "nospam" if you want.....
Lines: 40
Message-ID: <[email-masked]>
References: <[email-masked]> <01bc6f79$486f2220$04b8de8b@w9622136> <[email-masked]> <01bc7126$447a6860$04b8de8b@w9622136> <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]>
NNTP-Posting-Host: chs-public-10.mds.qmw.ac.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (Win16; I)
Xref: news.acns.nwu.edu comp.sys.sinclair:40242 comp.sys.cbm:69964 comp.emulators.cbm:21945 comp.sys.amstrad.8bit:7085

Bruce R. McFarling wrote:
> 
>         LDX pattern     ; pattern to flip
>         LDA table,x     ; bingo
> 
> Where is pattern?  The above will work for zero page, absolute, and
> Y-indexed (immediate would be silly, now wouldn't it?)  Or is the the
> pattern in the accumulator?  In which case
> 
>         TAX             ; pattern to flip
>         LDA table,x     ; bingo
> 
> Virtually,
> 
> Bruce R. McFarling, Newcastle, NSW
> [email-masked]

G'day Bruce,  (cor! always wanted to say that!)

Not quite sure what you mean....

Basically the table is made up of 256 bytes, each of which is the
"flipped" equivalent.  So, byte 0 (at memory location &9000) contains 0.
Byte 1 which is 00000001 (i think!) holds the value 10000000, and so on.

So, you load L with the byte you want to flip (say 25 -> 00011001) and
it looks in the 25th byte in the table, and retrieves the value of 
25 flipped ( 10011000 --> 152).  Voila.

All the page aligned malarky is so that it runs like greased lightning. 
The downside is that the table can only be 256 bytes maximum and must
start on a page boundary, so that the hi byte is the same for the whole
table ie. &9000 --> &90ff or &9100 --> &91ff.  

If I've got the wrong end of the stick and you knew this already, a
thousand apologies.  

Anyway, no worries mate.  (cor! always wanted to say that too!)

Ratz

Article 70212 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.luc.edu!chi-news.cic.net!feeder.chicago.cic.net!news.mathworks.com!news-xfer.cybernet.dk!rill.news.pipex.net!pipex!server1.netnews.ja.net!warwick!bham!bhamcs!news.ox.ac.uk!news
From: [email-masked] (Ian Collier)
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: 23 Jun 1997 17:53:49 GMT
Organization: Oxford University Computing Laboratory, UK
Lines: 11
Message-ID: <[email-masked]>
References: <[email-masked]> <[email-masked]> <Pine.PMDF.3.95.9706 <[email-masked]>
NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
X-Local-Date: Monday, 23rd June 1997 at 6:53pm BST
Xref: news.acns.nwu.edu comp.sys.sinclair:40411 comp.sys.cbm:70212 comp.emulators.cbm:22116 comp.sys.amstrad.8bit:7141

In article <[email-masked]>, [email-masked] (Richard Fairhurst) wrote:
>The byte is in the L register. A simple LD L,A transfers it from the
>accumulator. On the Z80, you can directly load any value into any
>register you like. And there are loads of 'em. :-)

If the byte is stored in memory then you usually have a small problem,
but not in this case as you can simply LD HL,(nn) from the location before
setting the H register to the appropriate constant.
-- 
---- Ian Collier : [email-masked] : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html

Article 70282 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.ece.nwu.edu!news.cse.psu.edu!uwm.edu!chi-news.cic.net!howland.erols.net!newspump.sol.net!sol.net!spool.mu.edu!newsspool.sol.net!munnari.OZ.AU!metro!metro!seagoon.newcastle.edu.au!CC.newcastle.edu.au!ecbm
From: "Bruce R. McFarling" <[email-masked]>
Newsgroups: comp.sys.sinclair,comp.sys.cbm,comp.emulators.cbm,comp.sys.amstrad.8bit
Subject: Re: Spectrum Emulator for C64
Date: Wed, 25 Jun 1997 19:59:00 +1000
Organization: The University of Newcastle
Lines: 41
Message-ID: <[email-masked]>
References: <01bc7126$447a6860$04b8de8b@w9622136> <[email-masked]> <01bc7171$fa267a00$04b8de8b@w9622136> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]> <[email-masked]>
NNTP-Posting-Host: cc.newcastle.edu.au
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <[email-masked]>
Xref: news.acns.nwu.edu comp.sys.sinclair:40462 comp.sys.cbm:70282 comp.emulators.cbm:22155 comp.sys.amstrad.8bit:7169

On Mon, 23 Jun 1997, Richard Fairhurst wrote:

> Bruce R. McFarling <[email-masked]> wrote:
> 
> >       No, I meant where is the byte that wants to be flipped.  If it is
> > in memory, it can be loaded directly into the index register X (or Y for
> > that matter), while if it is in the accumulator, it can transferred
> > internally with a TAX instruction, which is quickest.
> 
> Hate to state the bleeding obvious, but I believe you're talking about
> two different processors... Simon's code was Z80-based, while yours
> sounds rather 6502-like.

	I hate to state the obvious as well (such as England is hoping it
is a rainy summer in Britain, while the Windies are rather hoping for some
dry weather in the Caribbean), but but I was talking about process, not
processors. RTF cross-postings -- this is a cross processor discussion.
 
> The byte is in the L register. A simple LD L,A transfers it from the
> accumulator. On the Z80, you can directly load any value into any
> register you like. And there are loads of 'em. :-)

	And loads of instructions to load them all. On the 65C02, you can
transfer between any of the three main registers (TAY, TYA, TAX, TXA, TYX,
TXY). There's only three, which is why the 65C02 can do the job with so
many fewer gates.[*] You can also access the stack register via the X
register, but this is less critical, since which an 8-bit hardware stack
pointer, there is much more reliance in 6502 on software stacks
implemented with the rich set of address modes in the 6502 instruction
set.

Virtually,

Bruce R. McFarling, Newcastle, NSW
[email-masked]

[*] C64 programmers may not recognize all of these.  The direct XY
transfers where added when the CMOS design was created, and are not
available in the C64's NMOS 6510 version of the processor. The more's the
pity.