Re: A85: Square roots


[Prev][Next][Index][Thread]

Re: A85: Square roots



> Does anybody know a fast way of calcing out squreroots in z80 asm?
> 
> (need it for primes)

On my web pages I have C source for an algorithm for calculating the
square root of a 32 bit number. 
http://www.cs.waikato.ac.nz/~rbg/fsr.html It only uses shifts, adds,
subtracts and comparisons so is ideal for the Z80.  It is not too
complex so you should be able to convert to Z80 assembly by hand.  Or
you could compile it with a Z80 C compiler and use it's result.

If you only need to do 16 bit numbers change 32768 to 128, change 14
to 6, and change the number types accordingly.

--
Richard Gallagher
rbg@cvm.co.nz
http://www.cs.waikato.ac.nz/~rbg/


References: