On Wed, Feb 22, 2006 at 11:58:26AM -0500, Rolf wrote:
{Quote hidden}> J?hn Bal?zs wrote:
> > Hi,
> >
> > I want a 8 bit number divide by 10 (ten).
> > I need the quotient and the remain.
> >
> > Which is the fastest ASM code for pic 16f877?
> >
> > Many thanks!!!
> >
> > Balazs
> >
> > ___________________________________________________________________________
> > [origo] klikkbank lakoss?gi sz?mlacsomag havi 199 Ft-?rt, bankk?rtya ?ves d?j n?lk?l!
> >
http://www.klikkbank.hu
> >
> >
> >
> >
> Given that the dividend is only an 8 bit value to start with (stored in
> W), and assuming it is in range 0-255....
> snippet puts quotient in "quotient", and remainder in W
>
> movwf dividend ; w contains the dividend
> clrf quotient
> movlw 10
> subwf dividend,f
> btfss STATUS,0 ; check for positive (Carry bit).
> goto $+3 ; result is negative
> incf quotient,f
> goto $-4
> addwf dividend,w
>
>
> best case makes this 8 cycles, worst case is 25*6 + 8 = 158 cycles.
> "average" is about 75 cycles.
I would suggest that this would not qualify as "fast". A lookup table
encoded either as RETLWs or as instructions would have an average and best
time of better than 8 cycles.
BAJ