<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 02 Jun 2005 13:50:41 +0100
From   : Richard_Talbot-Watkins@...
Subject: Re: Assembly Language Square Root

Michael Borcherds wrote:

> Peter Craven <cjl_craves@...> wrote:
>
> > I came across a Z80 Assembly Language program at the end of the
> > web page at: http://map.tni.nl/articles/mult_div_shifts.php
>
> > Sqr16_Loop:
> >  sbc hl,de
>
> The Z80 carry is used the other way round to the 6502 for the SBC
> instruction so you might need to think about swapping the carry
> before and after it.

Yes...

Other gotchas:

The LD DE,#0040 is a hex constant - the '#' denoting 'hex', not 'immediate
mode'.  (Z80 doesn't use # to indicate immediate - all constants are
immediate, and contents of memory locations are accessed by putting the
operand in brackets).  Hence your 6502 version should be doing
LDA#&40:STAd.

I'll have a go at 6502ing that code myself in a sec - I suspect that,
whereas it is tuned very nicely to a Z80, with its 16-bit add opcodes and
so on, it may be suboptimal on a 6502.  This is also true of Z80 multiply
routines which are able to use the obvious left-shift method to achieve
their goal, versus the 6502 versions which make very clever use of right
shifts instead.

Meanwhile, there's a square-root routine here (though I don't know how good
it is):

http://www.6502.org/source/integers/root.htm

Cheers,
Rich


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster@...

This footnote also confirms that this email message has been checked
for all known viruses.

**********************************************************************
Sony Computer Entertainment Europe




<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>