Re: A85: What i really need is...


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

Re: A85: What i really need is...



I would love to just loop and add, but this is impossible since there
is the possibility of 63*127.  I don't think that would be too pretty
with your routine.  thanks anyways.

-mike pearce

On Tue, 19 Aug 1997 17:11:21 -0700, you wrote:

>Michael Pearce wrote:
>> 
>> I didn't really need a multiplication earlier, what i needed was a
>> *signed* multiplication routine.  Still 8 bit * 8 bit.  Again, if
>> anyone has one, i'd like to see it.
>> 
>> -mike pearce
>
>I'm thinking of this as I type, so correct any mistakes I make:
>
>;multiplies signed b and signed e, result stored in hl
>;destroys af,bc,de
>;if b=0,hl=256*e
>;if e=0,hl=0
>
>;instruction		estimated execution time,microseconds,4 Mhz
>	xor	a		;1.00
>	ld	a,b		;1.00
>	and	%10000000	;1.75
>	ld	c,a		;1.00
>	ld	a,e		;1.00
>	and	%10000000	;1.75
>	xor	c		;1.00
>	ld	c,a		;1.00
>	set	7,b		;2.00
>	set	7,e		;2.00
>	ld	d,0		;1.75
>	ld	hl,0		;2.50
>loop:
>	add	hl,de		;2.75
>	djnz	loop		;3.25/2.00 if b=0
>	ld	a,c		;1.00
>	or	h		;1.00
>	ld	h,a		;1.00
>
>Fairly quick; you can always optimize.
>
>-- 
>Terry Peng
>email-	tpeng@geocities.com
>web-	http://www.geocities.com/SiliconValley/Bay/5104/index.html
>


References: