Re: A86: Sorry Dux. =-|


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

Re: A86: Sorry Dux. =-|




First of all thanks for pointing out my terrible mistake.
I did manage to resurrect it though.  Keep reading.

Russian Peasant's Algorithm:
made by Dux Gregis
modified and renamed by Tim Farrell
        (head recently buried in sand, not picking sand from ears and nose)
nitpicked by Kirk Meyer
scrutinized by RabidCow
slaughtered by Dux Gregis
Resurrected by Tim Farrell

> I don't know if you tested this or not, but this doesn't work.

I did test it.  However, I only tested it by loading 2 into b.  It
worked then (and only then).

> The algorithm works like this:

Had you not explained this I couldn't have corrected it.

> Also, I thought about it and decided that more time can be saved over
> all if you check which of the input numbers is smallest before the
> routine.  Otherwise, 179*0 will loop 7 times when it really doesn't need
> to loop at all.

Done.

> Here's the Russian Peasants' Algorithm again (I doubt there's anything
> that will speed it up):

Doubt your doubts and believe your beliefs.
This routine is 8 bytes bigger.  But when doing
your 9*5 problem mine comes out 32 ticks faster.
Check for yourself.  If I'm wrong please tell me,
I hate to be wrong.

;African Swallow Algorithm_________________________
;Input: hl * b                                    |
;Output: hl                                       |
;Destroys: a, b, de                               |
;Size: 27 bytes                                   |
;--------------------------------------------------
ASMult:
	xor a			
	ld d, a		
	ld e, a
	cp b
	jp z, Bzero
	cp l
	jp nz, ASTop
	cp h
	ret z
ASTop:
        srl b
        jp nc, ASkipadd
        ex de, hl
        add hl, de
ASkipadd:
        ret z
        add hl, hl
        jp ASTop
Bzero:
	ld h, a
	ld l, a
	ret
-- 
Tercero	 --  Email: mailto:tercero@busprod.com

"The stone the builders rejected has become the capstone;"
			--Psalms 118:22
"Everyone who falls on that stone will be broken to pieces,
but he on whom it falls will be crushed."
			--Luke 20:18


Follow-Ups: References: