Path: umaxc.weeg.uiowa.edu!ns-mx!uunet!elroy.jpl.nasa.gov!nntp-server.caltech.edu!toddpw
From: toddpw@cco.caltech.edu (Todd P. Whitesel)
Newsgroups: comp.sys.apple2
Subject: Re: FAST DIVISION ALGORITHM
Message-ID: <1992Jun5.204424.308@cco.caltech.edu>
Date: 5 Jun 92 20:44:24 GMT
References: <2a2f74ff.8c9bcf.8@BEIZ.mediatex.ch>
Sender: news@cco.caltech.edu
Organization: California Institute of Technology, Pasadena
Lines: 34
Nntp-Posting-Host: bartman

Shadow@BEIZ.mediatex.ch writes:

>What about a fast multiplying routine?

; want to compute m*n
	lda	#0
	bra	m0
lp	asl	n
m0	lsr	m
	bcc	m1
	clc
	adc	n
m1	bne	lp
; result is in A

if you can store m inverted, you can avoid the clc in the loop:

	lda	m
	eor	#$ffff
	sta	m
	lda	#0
	bra	m0
lp	asl	n
m0	lsr	m
	bcs	m1
	adc	n
m1	bne	lp

It's not clear which is going to be faster, as the cutoff is about 6 bis set
in m. If you can arrange to have the input code do the EOR then the cutoff is
two bits set and that's a pretty clear win.

Todd Whitesel
toddpw @ tybalt.caltech.edu
