Searching \ for 'Optimal realization: Array data to another locatio' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/mems.htm?key=data
Search entire site for: 'Optimal realization: Array data to another locatio'.

Truncated match.
PICList Thread
'Optimal realization: Array data to another locatio'
1999\01\27@054654 by Dmitry Kiryashov

flavicon
face
I'm glad to say: Greetings All. ;-)

I have a little question about how to make couple of FSR
from existing one ;-)

In words of C it looks like the following:
for ( i = num_of_elements; i; ) { b[i] = a[i]; i--; }

In words of MPASM it looks slightly different...

       movlw   num_of_elements
       movwf   i
loop:
       decf    i,W
       addlw   a
       movwf   FSR     ; (a+i)
       movfw   INDF    ;**1
       movwf   temp    ;**2

       movlw   (b-a)
       addwf   FSR,F   ; (b+i)
       movfw   temp    ;**3
       movwf   INDF    ;**4

       decfsz  i,F
       goto    loop

Did someone see the way how to squeeze it down ?

WBR Dmitry.

PS.  It seems that designers of PIC core didn't like the C ;-)

1999\01\27@225009 by Mike Keitz

picon face
On Wed, 27 Jan 1999 13:42:31 +0300 Dmitry Kiryashov <spam_OUTzewsTakeThisOuTspamAHA.RU> writes:

>In words of C it looks like the following:
>for ( i = num_of_elements; i; ) { b[i] = a[i]; i--; }

>Did someone see the way how to squeeze it down ?

14-bit PICs have a hard time with arbitrary moves like that.  If you
locate the array variables carefully at "block" addresses in RAM, then
it's possible to change the pointer between them simply by setting and
clearing bits in FSR.

For example, place a[0] at $40 and b[0] at $60:

       movlw   array_a         ;First byte of A
       movwf   FSR
       movlw   num_of_elements
       movwf   i
loop
       movfw   INDF    ;get a byte of A
       bsf     FSR,5   ;Point to B
       movwf   INDF    ;move into B
       bcf     FSR,5   ;Point back to A
       incf    FSR,f
       decfsz  i,f
       goto    loop


For the general case I've looked at using the xoring swap trick to swap
FSR with a RAM "fsr2" or W and FSR, but it is faster to use a temporary
RAM like you did.


___________________________________________________________________
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]

1999\01\27@232537 by Regulus Berdin

picon face
Hi,

The best way is to organize your array a and b that will be exactly
multiples of 2 away from each other.

ex: b - a = 16

       movlw   num_of_elements
       movwf   i
       movlw   a
       movwf   FSR
loop:
       movf    INDF,w
       bsf     FSR,4
       movwf   INDF
       bcf     FSR,4
       incf    FSR
       decfsz  i
        goto   loop

regards,
Reggie


Dmitry Kiryashov wrote:
{Quote hidden}

1999\01\28@122107 by Scott Dattalo

face
flavicon
face
On Wed, 27 Jan 1999, Dmitry Kiryashov wrote:

{Quote hidden}

you can decrease the loop execution time by one instruction

       movlw   num_of_elements
       movwf   i
       movlw   b-1     ;initialize FSR
       movwf   FSR
loop:
       movlw   (a-b)+1
       addwf   FSR,f

       movfw   INDF    ;**1
       movwf   temp    ;**2

       movlw   (b-a)
       addwf   FSR,F   ; (b+i)
       movfw   temp    ;**3
       movwf   INDF    ;**4

       decfsz  i,F
       goto    loop



Scott

ps. 34

1999\01\29@093935 by Walter Banks
picon face
----------
> From: Scott Dattalo <.....sdattaloKILLspamspam@spam@UNIX.SRI.COM>
> To: PICLISTspamKILLspamMITVMA.MIT.EDU
> Subject: Re: Optimal realization: Array data to another location
copyingin              words of PIC
{Quote hidden}

If you are free to play with the addresses of your variables
you can shorten the main loop anytime the base address
is not different by three bits.

The address management and temp are 6 instructions worth
of overheads.

Walter Banks

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...