Article 69467 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: ...and a Z80 question
Date: 15 Jun 1997 19:58:46 GMT
Organization: Northwestern University, Evanston, IL
Lines: 19
Message-ID: <5o1hhm$553@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69467 comp.sys.sinclair:39916 comp.emulators.cbm:21662

In article <5o00p9$gi9@news.acns.nwu.edu>, Stephen Judd <sjudd@nwu.edu> wrote:
>
>I would like to pose two additional problems to those posed in the

After poring over my Z80 instruction listings, I have a question:
Does the Z80 support direct addressing of memory?  That is, is there
a Z80 equivalent to LDA $C000, or are all memory accesses indirect
(LD A,(HL))?  Can a Z80 rotate, add, sub, or, etc. directly from a
memory location -- or to put it another way, which instructions
support direct addressing?

As long as I'm asking questions, does the Spectrum support double
buffering in some form?

TIA,
	evetS-

P.S. If someone wants to work on another coding challenge, what does
     a spectrum screen-clear routine look like?


Article 69468 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 15 Jun 1997 21:37:14 GMT
Organization: Northwestern University, Evanston, IL
Lines: 63
Message-ID: <5o1naa$70h@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69468 comp.sys.sinclair:39917 comp.emulators.cbm:21663

In article <5o1hhm$553@news.acns.nwu.edu>, Stephen Judd <sjudd@nwu.edu> wrote:
>In article <5o00p9$gi9@news.acns.nwu.edu>, Stephen Judd <sjudd@nwu.edu> wrote:
>>
>>I would like to pose two additional problems to those posed in the
>
>After poring over my Z80 instruction listings, I have a question:
>Does the Z80 support direct addressing of memory?  That is, is there
>a Z80 equivalent to LDA $C000, or are all memory accesses indirect

Ah, found it: LD A,($C000) right?  13 cycles, and only LD supports
it (feel free to enlighten me if otherwise).

Say, I rather like answering my own questions.  It makes me feel
Important and Special.

>(LD A,(HL))?  Can a Z80 rotate, add, sub, or, etc. directly from a
>memory location -- or to put it another way, which instructions

Nope, and it's PDA (pretty damn annoying)!

>support direct addressing?

Where do you get off, asking for people's addresses on the newsgroup?
Or do you just get off on soporific dissemenation of pedantry?  Or
maybe you just don't get off at all -- maybe you just get ON.  Did
you ever stop to think about that?  Do you even pay to get on?
A subway?  A bus?  Do you just not care about public transportation,
or is it that you don't care about the public at all?  Doesn't
the public welfare concern you?  Or maybe it doesn't -- maybe you
don't care about welfare at all.  Maybe you don't even pay taxes
to pay for welfare any more than you pay for a subway fare.  Maybe
you just don't even care about the government.  Shades of revolutionary
thoughts?  What makes you think you can just get off without paying
for anything in this world, or talk about overthrowing the government?
Why don't you just STOP and THINK, just once!  Please!

Yeah, that's the Commodore 64 for you.  Bastards.

>
>As long as I'm asking questions, does the Spectrum support double
>buffering in some form?

Probably not, but who knows.

>TIA,

What exactly do you mean by THAT?  Why you insensitive, rodent-haired,
YUTZ!!!

>	evetS-

Yeah, "ttub ym etib", buddy.

>
>P.S. If someone wants to work on another coding challenge, what does
>     a spectrum screen-clear routine look like?

It doesn't look like anything!!!  It clears the screen!  Clear!
You ju,  .

JEEZ.

	-S


Article 69608 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!newsfeed.internetmci.com!newsfeed.direct.ca!news.he.net!news.pagesat.net!decwrl!tribune.usask.ca!rover.ucs.ualberta.ca!news.ucalgary.ca!srv1.freenet.calgary.ab.ca!albrecht
From: "Alvin R. Albrecht" <albrecht@freenet.calgary.ab.ca>
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: Sun, 15 Jun 1997 23:44:08 -0600
Organization: Calgary Free-Net
Lines: 68
Message-ID: <5o2jtf$rng@ds2.acs.ucalgary.ca>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu>
NNTP-Posting-Host: albrecht@srv1.freenet.calgary.ab.ca
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <5o1hhm$553@news.acns.nwu.edu>
Xref: news.acns.nwu.edu comp.sys.cbm:69608 comp.sys.sinclair:40022 comp.emulators.cbm:21752



On 15 Jun 1997, Stephen Judd wrote:

> In article <5o00p9$gi9@news.acns.nwu.edu>, Stephen Judd <sjudd@nwu.edu> wrote:

> >I would like to pose two additional problems to those posed in the

> After poring over my Z80 instruction listings, I have a question:
> Does the Z80 support direct addressing of memory?  That is, is there
> a Z80 equivalent to LDA $C000, or are all memory accesses indirect

Yes.  LD A,(nnnn) - 8 bit load in 13 cycles.
LD rp,(nnnn) where rp=BC,DE,HL,SP is a 16 bit load in 20 cycles
LD IX/IY,(nnnn) 16 bit load in 24 cycles

> (LD A,(HL))?  Can a Z80 rotate, add, sub, or, etc. directly from a
> memory location -- or to put it another way, which instructions
> support direct addressing?

All these instructions can be done using the HL register (fast) or
the index registers (slow) as pointers:

ADD A,(HL); SUB (HL); INC (HL); OR (HL); RL (HL)

add ~12 cycles if index register used in most cases: +4 for
extra opcode, +8 for 8 bit 2's complement index.

There are a few shifts related to BCD arithmetic: RRD, for example,
which shifts nibbles among (HL) and A in 18 cycles.

The undocumented instructions do a lot of goofy things like
rotate in memory and store result in a register which can save
a lot of cycles.

> As long as I'm asking questions, does the Spectrum support double
> buffering in some form?

Not the original UK 48K Spectrum (double buffering must be simulated
in software by a fast copy), but in all subsequent Spectrums and the
US 48k Spectrum.

> P.S. If someone wants to work on another coding challenge, what does
>      a spectrum screen-clear routine look like?

Not unrolled and not the fastest (doesn't clear colour either):

10      LD HL,#4000
10      LD DE,#4001
10      LD (HL),0
10      LD BC,6143
21/16   LDIR

A faster version would probably relocate the stack pointer to the
end of the display and push zeroes onto the stack 16 bits at a
time.

10      LD SP,#4000+6143
10      LD HL,0
11      PUSH HL x however many times and loop

this is unrolled somewhat - the loop is missing.  It approaches
5.5 cycles per byte cleared or ~ 5.5*6144=33792 cycles.


Alvin




Article 69564 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!207.22.81.9!europa.clark.net!dispatch.news.demon.net!demon!delos.dra.hmg.gb!server1.netnews.ja.net!server5.netnews.ja.net!peer.news.u-net.net!yama.mcc.ac.uk!simonc
From: simonc@jumper.mcc.ac.uk (Cookie)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Followup-To: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Date: 16 Jun 1997 13:56:34 GMT
Organization: Sirius Cybernetics Corporation
Message-ID: <5o3gmi$9er@yama.mcc.ac.uk>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu>
NNTP-Posting-Host: jumper.mcc.ac.uk
X-Newsreader: TIN [version 1.2 PL2]
Lines: 51
Xref: news.acns.nwu.edu comp.sys.cbm:69564 comp.sys.sinclair:39983 comp.emulators.cbm:21721

Stephen Judd (judd@merle.acns.nwu.edu) wrote:
: After poring over my Z80 instruction listings, I have a question:
: Does the Z80 support direct addressing of memory?  That is, is there
: a Z80 equivalent to LDA $C000, or are all memory accesses indirect
: (LD A,(HL))?  Can a Z80 rotate, add, sub, or, etc. directly from a
: memory location -- or to put it another way, which instructions
: support direct addressing?

Z80 instructions:

LD A,(address) = LDA address
LD HL,(address)
LD DE,(address)
LD BC,(address)      and vice versa

Rotation:

RR (HL)
RL (HL)     --- rotate

RRC (HL)
RLC (HL)  --- rotate with bits that wrap also put into the carry flag

SRL (HL)
SLA (HL)  --- shift left and right

You can't add or sub directly from a memory location - you have to
indirect it using HL, IX or IY...

: As long as I'm asking questions, does the Spectrum support double
: buffering in some form?

Not the original - the TS2068 and the Spectrum 128 and upwards did though.

: TIA,
: 	evetS-

: P.S. If someone wants to work on another coding challenge, what does
:      a spectrum screen-clear routine look like?

DI (if interrupts were enabled in the first place)
LD SP,$5800
LD HL,0
then either 3072 PUSH HL's (for the fastest), or:

LD B,48
loop: PUSH HL (* 64)
...
DJNZ loop

Si


Article 69544 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!math.ohio-state.edu!pacific.mps.ohio-state.edu!freenet.columbus.oh.us!magnus.acs.ohio-state.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!News1.Vancouver.iSTAR.net!news.istar.net!hammer.uoregon.edu!agate!nntpfeed.doc.ic.ac.uk!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!news
From: imc@ecs.ox.ac.uk (Ian Collier)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 16 Jun 1997 16:43:43 GMT
Organization: Oxford University Computing Laboratory, UK
Lines: 27
Message-ID: <11284.imc@comlab.ox.ac.uk>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu> <5o3gmi$9er@yama.mcc.ac.uk>
NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
X-Local-Date: Monday, 16th June 1997 at 5:43pm BST
Xref: news.acns.nwu.edu comp.sys.cbm:69544 comp.sys.sinclair:39960 comp.emulators.cbm:21695

In article <5o3gmi$9er@yama.mcc.ac.uk>, simonc@jumper.mcc.ac.uk (Cookie) wrote:
>: P.S. If someone wants to work on another coding challenge, what does
>:      a spectrum screen-clear routine look like?

>DI (if interrupts were enabled in the first place)
>LD SP,$5800
>LD HL,0
>then either 3072 PUSH HL's (for the fastest), or:

>LD B,48
>loop: PUSH HL (* 64)
>...
>DJNZ loop

Or, for the lazy people among us...

LD HL,$4000
LD DE,$4001
LD BC,$1AFF
LD (HL),0
LDIR

Not as fast, but quicker to type. :-)  And you don't have to save the stack
pointer or disable the interrupts.
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


Article 69544 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!math.ohio-state.edu!pacific.mps.ohio-state.edu!freenet.columbus.oh.us!magnus.acs.ohio-state.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!News1.Vancouver.iSTAR.net!news.istar.net!hammer.uoregon.edu!agate!nntpfeed.doc.ic.ac.uk!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!news
From: imc@ecs.ox.ac.uk (Ian Collier)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 16 Jun 1997 16:43:43 GMT
Organization: Oxford University Computing Laboratory, UK
Lines: 27
Message-ID: <11284.imc@comlab.ox.ac.uk>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu> <5o3gmi$9er@yama.mcc.ac.uk>
NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
X-Local-Date: Monday, 16th June 1997 at 5:43pm BST
Xref: news.acns.nwu.edu comp.sys.cbm:69544 comp.sys.sinclair:39960 comp.emulators.cbm:21695

In article <5o3gmi$9er@yama.mcc.ac.uk>, simonc@jumper.mcc.ac.uk (Cookie) wrote:
>: P.S. If someone wants to work on another coding challenge, what does
>:      a spectrum screen-clear routine look like?

>DI (if interrupts were enabled in the first place)
>LD SP,$5800
>LD HL,0
>then either 3072 PUSH HL's (for the fastest), or:

>LD B,48
>loop: PUSH HL (* 64)
>...
>DJNZ loop

Or, for the lazy people among us...

LD HL,$4000
LD DE,$4001
LD BC,$1AFF
LD (HL),0
LDIR

Not as fast, but quicker to type. :-)  And you don't have to save the stack
pointer or disable the interrupts.
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


Article 69577 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!ais.net!newsfeed.direct.ca!News1.Vancouver.iSTAR.net!news.istar.net!hammer.uoregon.edu!agate!nntpfeed.doc.ic.ac.uk!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!news
From: imc@ecs.ox.ac.uk (Ian Collier)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: Two more coding challenges -- Shootout part deux
Date: 16 Jun 1997 16:47:16 GMT
Organization: Oxford University Computing Laboratory, UK
Lines: 22
Message-ID: <11285.imc@comlab.ox.ac.uk>
References: <5o00p9$gi9@news.acns.nwu.edu>
NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
X-Local-Date: Monday, 16th June 1997 at 5:47pm BST
Xref: news.acns.nwu.edu comp.sys.cbm:69577 comp.sys.sinclair:39992 comp.emulators.cbm:21731

In article <5o00p9$gi9@news.acns.nwu.edu>, sjudd@nwu.edu (Stephen Judd) wrote:
>Coding Challenge #6:

>Printing text to the screen seems like a useful thing to do, and both
>upper and lower case are of course handy.

>This problem is simply the first program many people write: Hello World.
>The challenge is to print the string "Hello World" to the screen,
>in assembly.

>What does a Speccy version look like?

    LD DE,msg
    XOR A
    JP $0C0A

msg:DEFB $80,"Hello Worl","d"+$80

Slow as hell but quite short.
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


Article 69766 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 18 Jun 1997 15:50:41 GMT
Organization: Northwestern University, Evanston, IL
Lines: 50
Message-ID: <5o904h$1k7@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu> <5o3gmi$9er@yama.mcc.ac.uk> <11284.imc@comlab.ox.ac.uk>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69766 comp.sys.sinclair:40100 comp.emulators.cbm:21841

In article <11284.imc@comlab.ox.ac.uk>, Ian Collier <imc@ecs.ox.ac.uk> wrote:
>In article <5o3gmi$9er@yama.mcc.ac.uk>, simonc@jumper.mcc.ac.uk (Cookie) wrote:
>>: P.S. If someone wants to work on another coding challenge, what does
>>:      a spectrum screen-clear routine look like?
>
>>DI (if interrupts were enabled in the first place)
>>LD SP,$5800
>>LD HL,0
>>then either 3072 PUSH HL's (for the fastest), or:
>
>>LD B,48
>>loop: PUSH HL (* 64)
>>...
>>DJNZ loop
>
>Or, for the lazy people among us...
>
>LD HL,$4000
>LD DE,$4001
>LD BC,$1AFF
>LD (HL),0
>LDIR
>
>Not as fast, but quicker to type. :-)  And you don't have to save the stack
>pointer or disable the interrupts.

Ahhh, I see now.  Somehow I didn't realize that the Z80 graphics memory
was part of the normal RAM (I thought it might be ported or something).
Using the stack would indeed be handy.

Well, for what it's worth, a C64 version generally looks like:
 
	LDY #00
	TYA
:LOOP	STA BASE,Y	;BASE=$8000 say for bitmap at $8000
	STA BASE+256,Y
	STA BASE+512,Y
	... [32 times]
	INY
	BNE :LOOP

...a little bit over 4 cycles/byte (which I still find oppressive since it
takes a total of like 2 frames).

-Steve

>---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
>------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html




Article 69767 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: Two more coding challenges -- Shootout part deux
Date: 18 Jun 1997 15:55:41 GMT
Organization: Northwestern University, Evanston, IL
Lines: 34
Message-ID: <5o90dt$1l3@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu> <11285.imc@comlab.ox.ac.uk>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69767 comp.sys.sinclair:40101 comp.emulators.cbm:21842

In article <11285.imc@comlab.ox.ac.uk>, Ian Collier <imc@ecs.ox.ac.uk> wrote:
>In article <5o00p9$gi9@news.acns.nwu.edu>, sjudd@nwu.edu (Stephen Judd) wrote:
>>Coding Challenge #6:
>
>>This problem is simply the first program many people write: Hello World.
>>The challenge is to print the string "Hello World" to the screen,
>>in assembly.
>
>>What does a Speccy version look like?
>
>    LD DE,msg
>    XOR A
>    JP $0C0A
>
>msg:DEFB $80,"Hello Worl","d"+$80
>
>Slow as hell but quite short.

Heh :)  Well, if it comes to that, 

	JSR STROUT
	TXT 'Hello World!',00
	...program continues here

Well, OK, so STROUT is my own routine, but on a 128 you can use PRIMM=$FF7D.

(Yup, I pronounce it ess-trout :)

-S trout

>---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
>------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html




Article 69743 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!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!198.70.175.6!alpha.sky.net!news.vbc.net!vbcnet-west!news.mira.net.au!news.netspace.net.au!news.mel.connect.com.au!munnari.OZ.AU!metro!metro!seagoon.newcastle.edu.au!cc.newcastle.edu.au!ecbm
From: "Bruce R. McFarling" <ecbm@cc.newcastle.edu.au>
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: Two more coding challenges -- Shootout part deux
Date: Wed, 18 Jun 1997 18:01:32 +1000
Organization: The University of Newcastle
Lines: 45
Message-ID: <Pine.PMDF.3.95.970618175754.675772758A-100000@cc.newcastle.edu.au>
References: <5o00p9$gi9@news.acns.nwu.edu> <01bc7a8c$93d12a60$cba1c6c3@FOO.telia.com> <5o6d5b$139@news.acns.nwu.edu>
NNTP-Posting-Host: cc.newcastle.edu.au
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=DEC-MCS
Content-Transfer-Encoding: QUOTED-PRINTABLE
In-Reply-To: <5o6d5b$139@news.acns.nwu.edu>
Xref: news.acns.nwu.edu comp.sys.cbm:69743 comp.sys.sinclair:40079 comp.emulators.cbm:21825

Stephen Judd <judd@merle.acns.nwu.edu> skrev i inl=E4gg
<5o00p9$gi9@news.acns.nwu.edu>...
=2E..
> >> =09LDY #00=09=09=09=09=092
> >> =09LDA TEXT=09;get char=09=094
> >> :LOOP=09STA 1024,Y=09;put char on screen=094
> >> =09INY=09=09=09=09=092
> >> =09LDA TEXT,Y=09=09=09=094
> >> =09BNE :LOOP=09=09=09=093/2
> >> =09RTS

In article <01bc7a8c$93d12a60$cba1c6c3@FOO.telia.com>,
Krister Sundstr=F6m <k.s@goteborg.mail.telia.com> wrote:
> >This is shorter!!!
> >=09LDY #0=09=09=09=09=092
> >:LOOP=09LDA TEXT,Y=09=09=09=094
> >=09STA $0400,Y=09=09=09=094
> >=09INY=09=09=09=09=092
> >=09BNE :LOOP=09=09=09=093/2
> >=09RTS=09=09=09=09
> >Total =3D 2+13*n cycles.
> >Size =3D 11 bytes!
> >
> >Krister!

On 17 Jun 1997, Stephen Judd wrote:
> When were you planning on exiting the loop? :)

<?>
<!>

8-)#

=09LDY #255=09=09=09=092
:LOOP=09INY=09=09=09=09=092
=09LDA TEXT,Y=09=09=09=094
=09STA $0400,Y=09=09=09=094
=09BNE :LOOP=09=09=09=093/2
=09RTS=09=09=09=09

Virtually,

Bruce R. McFarling, Newcastle, NSW
ecbm@cc.newcastle.edu.au



Article 69771 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: Two more coding challenges -- Shootout part deux
Date: 18 Jun 1997 16:55:38 GMT
Organization: Northwestern University, Evanston, IL
Lines: 78
Message-ID: <5o93ua$2v9@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu> <01bc7a8c$93d12a60$cba1c6c3@FOO.telia.com> <5o6d5b$139@news.acns.nwu.edu> <Pine.PMDF.3.95.970618175754.675772758A-100000@cc.newcastle.edu.au>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69771 comp.sys.sinclair:40104 comp.emulators.cbm:21845

In article <Pine.PMDF.3.95.970618175754.675772758A-100000@cc.newcastle.edu.au>,
Bruce R. McFarling <ecbm@cc.newcastle.edu.au> wrote:
>On 17 Jun 1997, Stephen Judd wrote:
>> When were you planning on exiting the loop? :)
>
><?>
><!>
>
>8-)#

A smiley with a goatee?

>=09LDY #255=09=09=09=092
>:LOOP=09INY=09=09=09=09=092
>=09LDA TEXT,Y=09=09=09=094
>=09STA $0400,Y=09=09=09=094
>=09BNE :LOOP=09=09=09=093/2
>=09RTS=09=09=09=09

A challenge!  Well then!

First method:

BLAH	INY
	STA $0400,Y
HELLO	LDA TEXT,Y
	BNE BLAH
	RTS

Usage: LDY #00  JSR HELLO  :)

And it correctly doesn't print empty strings!

--

Second method:

	LDY TEXT
LOOP	LDA TEXT,Y
	PHA
	DEY
	BNE LOOP

TEXT	DFB 12
	ASC 'Hello World!'

(Naturally, the screen must be located at $0000 :)

--

Third method:

	LDX TEXT
	TXS
LOOP	TSX
	LDA TEXT+1,X
	STA $0400,X
	JSR LOOP

TEXT	DFB 24
	ASC 'H e l l o   W o r l d !'

--

Fourth method:




Usage: Hello World! [return]


Sigh, out of ideas already.

	evetS-

>Bruce R. McFarling, Newcastle, NSW
>ecbm@cc.newcastle.edu.au


Article 69766 of comp.sys.cbm:
Path: news.acns.nwu.edu!merle!judd
From: judd@merle.acns.nwu.edu (Stephen Judd)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 18 Jun 1997 15:50:41 GMT
Organization: Northwestern University, Evanston, IL
Lines: 50
Message-ID: <5o904h$1k7@news.acns.nwu.edu>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o1hhm$553@news.acns.nwu.edu> <5o3gmi$9er@yama.mcc.ac.uk> <11284.imc@comlab.ox.ac.uk>
Reply-To: sjudd@nwu.edu (Stephen Judd)
NNTP-Posting-Host: merle.acns.nwu.edu
Xref: news.acns.nwu.edu comp.sys.cbm:69766 comp.sys.sinclair:40100 comp.emulators.cbm:21841

In article <11284.imc@comlab.ox.ac.uk>, Ian Collier <imc@ecs.ox.ac.uk> wrote:
>In article <5o3gmi$9er@yama.mcc.ac.uk>, simonc@jumper.mcc.ac.uk (Cookie) wrote:
>>: P.S. If someone wants to work on another coding challenge, what does
>>:      a spectrum screen-clear routine look like?
>
>>DI (if interrupts were enabled in the first place)
>>LD SP,$5800
>>LD HL,0
>>then either 3072 PUSH HL's (for the fastest), or:
>
>>LD B,48
>>loop: PUSH HL (* 64)
>>...
>>DJNZ loop
>
>Or, for the lazy people among us...
>
>LD HL,$4000
>LD DE,$4001
>LD BC,$1AFF
>LD (HL),0
>LDIR
>
>Not as fast, but quicker to type. :-)  And you don't have to save the stack
>pointer or disable the interrupts.

Ahhh, I see now.  Somehow I didn't realize that the Z80 graphics memory
was part of the normal RAM (I thought it might be ported or something).
Using the stack would indeed be handy.

Well, for what it's worth, a C64 version generally looks like:
 
	LDY #00
	TYA
:LOOP	STA BASE,Y	;BASE=$8000 say for bitmap at $8000
	STA BASE+256,Y
	STA BASE+512,Y
	... [32 times]
	INY
	BNE :LOOP

...a little bit over 4 cycles/byte (which I still find oppressive since it
takes a total of like 2 frames).

-Steve

>---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
>------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html




Article 70002 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.luc.edu!chi-news.cic.net!news.mathworks.com!europa.clark.net!mr.net!news.netins.net!not-for-mail
From: phdss@netins.nett
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 21:05:12 -0400
Organization: Professional Hybrid Development Software Systems
Lines: 58
Message-ID: <IjyqzIIelAFA092yn@netins.net>
References: <337C5E94.388@actcom.co.il> <01bc7171$fa267a00$04b8de8b@w9622136>
 <5n73gt$h4p$2@gerry.cc.keele.ac.uk> <5o361v$f5r$11@morse.news.easynet.net>
 <5o4alf$717@news.acns.nwu.edu>
Reply-To: phdss@worf.netins.net
NNTP-Posting-Host: desm-15-34.dialup.netins.net
Xref: news.acns.nwu.edu comp.sys.sinclair:40258 comp.sys.cbm:70002 comp.emulators.cbm:21965 comp.sys.amstrad.8bit:7091

judd@merle.acns.nwu.edu (Stephen Judd) wrote:
>
>I would like to pose two additional problems to those posed in the
>"Shootout at the 0K corral" thread.  (The purpose of these problems
>is of course to compare the 6510 to the Z80 and the C64 to the Spectrum,
>and to gain insight into different methods for tackling problems).
>
>--
>Coding Challenge #6:
>
>Printing text to the screen seems like a useful thing to do, and both
>upper and lower case are of course handy.
>
>This problem is simply the first program many people write: Hello World.
>The challenge is to print the string "Hello World" to the screen,
>in assembly.
>
>Here is a typical C64 solution:
>                                     clock      bytes
>       LDY #00                         2         2
>       LDA TEXT    ;get char           4         3
>:LOOP  STA 1024,Y  ;put char on screen 4         3
>       INY                             2         1
>       LDA TEXT,Y                      4         3
>       BNE :LOOP                       2         2
>       RTS                                       1
>                                                15
>TEXT	TXT 'Hello World',00
>
>Total = 6+13*n cycles, n=number of characters to print.
>Size = 14 bytes (excluding RTS and string)
>What does a Speccy version look like?

--------

                       bytes   clock cycles
    ldy #txt'length   ; 2        2
-   lda txt,y         ; 3        4
    sta $1024,y       ; 3        4
    dey               ; 1        2
    bpl -             ; 2        2 (12cycle loop)*11chars=132cycles
    rts               ; 1        6
                        12

txt .scr "Hello World" : txt'length=*-txt-1

Assuming the code starts on a page boundary:

Total loop
(12) * 11 chars = 132 cycles in loop + 8 setup and exit = 140 cycles.

Thus, the loop times are the same, but we save 4 cycles and 4 bytes
to set it up.


-- Brett Tabke
-- phdss @ netins.net



Article 70061 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.luc.edu!chi-news.cic.net!news.maxwell.syr.edu!howland.erols.net!newsfeed.internetmci.com!malgudi.oar.net!triglav.iwaynet.net!not-for-mail
From: dklugh@iwaynet.net
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: Two more coding challenges -- Shootout part deux
Date: 22 Jun 1997 09:26:44 GMT
Lines: 35
Message-ID: <5oir4k$gd2$6@triglav.iwaynet.net>
References: <5o4ike$ekr$1@news.eecs.umich.edu>
NNTP-Posting-Host: port212.iwaynet.net
X-Everything: Net-Tamer V 1.08
Xref: news.acns.nwu.edu comp.sys.cbm:70061 comp.sys.sinclair:40305 comp.emulators.cbm:22023



On 1997-06-16 holz4061@gmi.edu(WhiteFlame) said:
   >Krister Sundström (k.s@goteborg.mail.telia.com) wrote:
   >: Stephen Judd <judd@merle.acns.nwu.edu> skrev i inlägg
   >: >
   >: > This problem is simply the first program many people write:
   >: >Hello World.  The challenge is to print the string "Hello World"
   >: >to the screen,  in assembly.
   >: >
   >: > Here is a typical C64 solution:
   >: >
   >: >  LDY #00     2
   >: >  LDA TEXT ;get char  4
   >: > :LOOP STA 1024,Y ;put char on screen 4
   >: >  INY     2
   >: >  LDA TEXT,Y    4
   >: >  BNE :LOOP    3/2
   >: >  RTS
   >: >
   >: > TEXT TXT 'Hello World',00
   >: >
   >: > Total = 6+13*n cycles, n=number of characters to print.
   >: > Size = 14 bytes (excluding RTS and string)

You do know that the Kernal has a routine to place a character onto the screen?
This would have the advantage that it would work with 80-columns and 
re-directed output.

Of course this would be faster on the Atari since it supports sending more than
one byte at-a-time to a device,and it supports device handlers.
So you could write the programme to send the whole string of text to the
screen,and then load a fast screen editor (E:) handler.

Net-Tamer V 1.08 - Test Drive


Article 70051 of comp.sys.cbm:
Path: news.acns.nwu.edu!newsfeed.acns.nwu.edu!news.luc.edu!chi-news.cic.net!news.maxwell.syr.edu!news-peer.gsl.net!news-paris.gsl.net!news.gsl.net!newsfeed.cableol.net!server4.netnews.ja.net!server2.netnews.ja.net!server3.netnews.ja.net!server1.netnews.ja.net!warwick!bham!bhamcs!news.ox.ac.uk!news
From: imc@ecs.ox.ac.uk (Ian Collier)
Newsgroups: comp.sys.cbm,comp.sys.sinclair,comp.emulators.cbm
Subject: Re: ...and a Z80 question
Date: 20 Jun 1997 17:21:45 GMT
Organization: Oxford University Computing Laboratory
Lines: 27
Message-ID: <11324.imc@comlab.ox.ac.uk>
References: <5o00p9$gi9@news.acns.nwu.edu> <5o3gmi$9er@yama.mcc.ac.uk> <11284.imc@comlab.ox.ac.uk> <5o904h$1k7@news.acns.nwu.edu>
NNTP-Posting-Host: gruffle.comlab.ox.ac.uk
X-Modified-on: Friday, 20th June 1997 at 6:21pm BST
X-Local-Date: Friday, 20th June 1997 at 6:21pm BST
Xref: news.acns.nwu.edu comp.sys.cbm:70051 comp.sys.sinclair:40295 comp.emulators.cbm:22013

In article <5o904h$1k7@news.acns.nwu.edu>, sjudd@nwu.edu (Stephen Judd) wrote:
>Ahhh, I see now.  Somehow I didn't realize that the Z80 graphics memory
>was part of the normal RAM (I thought it might be ported or something).

To be fair, you should say "Spectrum graphics".  Who knows what someone
somewhere might have attached to a Z80? :-)

>Well, for what it's worth, a C64 version generally looks like:

>	LDY #00
>	TYA
>:LOOP	STA BASE,Y	;BASE=$8000 say for bitmap at $8000
>	STA BASE+256,Y
>	STA BASE+512,Y
>	... [32 times]
>	INY
>	BNE :LOOP

>...a little bit over 4 cycles/byte (which I still find oppressive since it
>takes a total of like 2 frames).

The Z80 stack-based version took a little over 5.5 cycles per byte, which is
a clear winner at last. :-)  At that rate it would take just over half a
frame on a Spectrum.
-- 
---- Ian Collier : imc@comlab.ox.ac.uk : WWW page (including Spectrum section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html


