> > For now it is confirmed that
> "the compiler does not use INDF1 or INDF2 yet." So, until
> this changes, it's no problem. But if this changes,
> trouble's ahead.
>
> I see what you mean... So, this means USB could get broken
> by a
> compiler upgrade? I guess this is what you have been
> talking about
> which I didn't quite understand.
That's exactly what I meant :-)
> Another thing to do is create a optional user constant for
> this (with
> a warning comment), for USB and other libs. From previous
> tests, small
> changes in a 512 byte array read loop made a big
> difference.
> Personally, I would want to transfer files as quick as
> possible.
Of course I don't approve to slow things down just to keep a compatibility that
is not needed. But again, it is perfectly safe to use these registers in an asm
block, as the compiler will never interfere there.
Here some (untested) examples. The memcopy_dword procedure takes little more
than three instruction cycles per copied byte. All procedures do only run on
PIC18 cores.
Greets,
Kiste
procedure memcopy_bytes ( word in source_ptr, word in dest_ptr, byte in amount
) is
-- copies [amount] bytes from source memory location to dest.
-- amount=0 copies 256 bytes
var byte counter
counter=amount
ASSEMBLER
movfw source_ptr
movwf FSR1L
movfw source_ptr+1
movwf FSR1H
movfw dest_ptr
movwf FSR2L
movfw dest_ptr+1
movwf FSR2H
LOCAL copy_loop
copy_loop:
movfw POSTINC1
movwf POSTINC2
decfsz counter,f
goto copy_loop
END ASSEMBLER
end procedure
procedure memcopy_words ( word in source_ptr, word in dest_ptr, byte in amount
) is
-- copies [amount] words from source memory location to dest.
-- amount=0 copies 256 words=512 bytes
var byte counter
counter=amount
ASSEMBLER
movfw source_ptr
movwf FSR1L
movfw source_ptr+1
movwf FSR1H
movfw dest_ptr
movwf FSR2L
movfw dest_ptr+1
movwf FSR2H
LOCAL copy_loop
copy_loop:
movfw POSTINC1
movwf POSTINC2
movfw POSTINC1
movwf POSTINC2
decfsz counter,f
goto copy_loop
END ASSEMBLER
end procedure
procedure memcopy_dwords ( word in source_ptr, word in dest_ptr, byte in amount
) is
-- copies [amount] dwords from source memory location to dest.
-- amount=0 copies 256 dwords=1024 bytes
var byte counter
counter=amount
ASSEMBLER
movfw source_ptr
movwf FSR1L
movfw source_ptr+1
movwf FSR1H
movfw dest_ptr
movwf FSR2L
movfw dest_ptr+1
movwf FSR2H
LOCAL copy_loop
copy_loop:
movfw POSTINC1
movwf POSTINC2
movfw POSTINC1
movwf POSTINC2
movfw POSTINC1
movwf POSTINC2
movfw POSTINC1
movwf POSTINC2
decfsz counter,f
goto copy_loop
END ASSEMBLER
end procedure
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.