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

Re: A85: 16-bit integer Square Root (few changes)




On Mon, 16 Mar 1998, Fuse Box wrote:
> just a small modification on the shift hl part... it wouldn't get shifted
> properly the way it was... my changes start with ;&&& 

Actually, because hl is being treated as a negative number you have to
shift a 1 into the left side when you want a divide by 2 effect.
About switching the order, it seemed to work fine when I tested it.
Did you find a problem when you tested the routine?
> 
> On Sun, 15 Mar 1998, Humberto Yeverino wrote:
> <snip>
> > >  Anyways here it is:
> > >  Sqrt16:	
> > 
> > **   push hl ;if you want to save hl 
> > 
> > >    push de
> > >    push bc
> > >    ld de,0
> > >    ld bc,0
> > >    call CP_HL_DE
> > >    jr z,Sqrt16Done  ;0 is a special case.
> > >    ld de,65280
> > >    ld bc,256
> > >    sbc hl,de
> > >    jr nc,Sqrt16done
> > >    dec bc           ;bc=255
> 
> ;&&& few changes I'd make:
> 
> 
> ;&&& remove this : > >    scf
> ;&&& change the order:
> ; shift hl
> rr l
> rr h
> jr nc, noSet
> set 7, l
> noSet:
> <snip>
> rest of code ...
> 
> Erik Huizing
> ehuizing@acs.ucalgary.ca
> http://www.ucalgary.ca/~ehuizing
> 
> 
> 

-Humberto Yeverino Jr.

"Small potatos make the steak look bigger."

http://www.engr.csufresno.edu/~humberto/Home.html
humberto@engr.csufresno.edu

<font size=3>For browsers:<br>
<a href="http://www.engr.csufresno.edu/~humberto/Home.html">
Have a look.</a></font><br>


References: