[Basic] Copy data block to another one
François Vanzeveren (2221) 241 posts |
Hello all I have defined two data blocks as After having filled the source% block, I would like to make a copy into the target% block. Currently, i have defined a PROC
Is there a better/faster/more efficient way to achieve this? Thank you for your help. François |
GavinWraith (26) 1563 posts |
For a start, word by word would be quicker than byte by byte. We know that the blocksize is a multiple of 4.
But faster still would be to use assembler. |
François Vanzeveren (2221) 241 posts |
Thanks GavinWraith Of course, asm would be best… but I am too old for this :) |
GavinWraith (26) 1563 posts |
Not as bad as you think. Fastest is to use LDM and STM. You load 8 words at a time into 8 registers, say R2-R10 (having set R0 to source% and R1 to target%) and repeat this pair of instructions 32 times.
|
Steve Drain (222) 1620 posts |
@Gavin There are couple of other ways to copy a block of memory without resorting to assembler. You could use SYS"Wimp_TransferBlock" if you are running your program as a wimp task. It works inside a task as well as between tasks, but I would expect it to be inefficient for small blocks. Of course, I also have to mention that Basalt can do it for you:
With ON the block is copied even if it overwrites the source, but with TO there would be an error. |