Re: A86: Fw: Simple Division
[Prev][Next][Index][Thread]
Re: A86: Fw: Simple Division
be patient
there's the divide-by-3 problem that just went by, in which there was
another that divided by anything but if you want to use 3 a lot then this
might be better.
use fixed point to multiply by .3333...
256*.333=$00.56=%00000000.01010110 (rounded up)
;de=number use d=0,e=8-bit number if you want
;h=de/3
div3:
ld h,d
ld l,e
add hl,hl ;*%00000010
add hl,hl ;*%00000100
add hl,de ;*%00000101
add hl,hl ;*%00001010
add hl,hl ;*%00010100
add hl,de ;*%00010101
add hl,hl ;*%00101010
add hl,de ;*%00101011
add hl,hl ;*%01010110
ret
9*11+2*4=107 t-states, not including call/return
this will work up to $02fa, which gives 762/3=255.something instead of
254.whatever
ok, now divide by 6 is the same, without the last "add hl,hl"
107-11=96 t-states, not including call/ret
that should work twice as far as div3, up to $05f4
use them inline if you want to squeeze out every ounce of speed (leave
out the ret then)
-josh
On Fri, 11 Dec 1998 21:05:29 -0600 "Dave M. Weprin"
<bioserr@megsinet.net> writes:
>
>Well since no one answered (very rude), here it is again...
>
>-----Original Message-----
>From: Dave M. Weprin <bioserr@megsinet.net>
>To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
>Date: Friday, December 11, 1998 5:00 PM
>Subject: A86: Simple Division
>
>
>>
>>All I need to know is the fastest way to divide an 8-bit integer by 3
>and
>by
>>6.
>>
>>I know several ways of doing this, but I don't know of the fastest
>way.
>Any
>>suggestions would be grately appreciated. Remember, size doesn't
>matter to
>>me very much, it's the speed that I'm most concerned about.
>>
>>Thanks
>>-Dave
>>
>
>
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]