On Thu, 18 May 2000, Marcelo Puhl wrote:
> Hi,
>
> Is there a way to reduce the size of this routine ?
Absolutely!
{Quote hidden}>
> Polynomial = x0 + x12 + x17
>
> x0 is in "data" bit_0
> x12 is in "mid" bit_3
> x17 is in "old" bit_0
>
> rlf mid,w ; x12 in w bit_4
> movwf temp ; x12 in temp bit_4
> swapf temp,w ; x12 in w bit_0
> xorwf old,w ; x12 + x17 in w bit_0
> xorwf data,w ; x0 + x12 + x17 in w bit_0
> movwf temp
> rrf temp,f ; x0 in Carry
>
> rlf new,f ; x0 to bit_0
> rlf mid,f ; Updates x12
> rlf old,f ; Updates x17
>
> Thanks for your help.
how 'bout
rrf data,w
rlf new,f ;copy data.0
rlf mid,f ;2nd part of 24bit shl
swapf mid,w ;get mid.4 (originally mid.3)
xorwf old,w ;xor'd with old.0
rlf old,f ;complete the 24bit shift
andlw 1 ;add old.0^mid.3
xorlw new,f ;to new.0
Saves a couple of cycles
Scott