title: "memcpy" description: TRSE built-in method (from IDE help)
memcpy
Systems: Amiga, ATARI520ST
Parameters: a, l,a,l, l,i
MemCpy( [address1 source], [byte1 offset], [address2 destination], [byte2 total] );
- [address1 source] - Source address to copy from
- [byte1 offset] - offset to start copying from
- [address2 destination] - destination address to copy to
- [byte2 total] - number of bytes to copy
Description
Copies 0-255 (parameter 4) bytes of memory from source address (parameter 1 + parameter 2) to destination address (parameter 3).
Example
// copies 40 bytes of data from my_data to the first row of the screen (bank 0)
MemCpy(my_data, 0, ^$0400,40);
MemCpy also supports copying with zero pages:
// copies 160 bytes = 4 rows from color memory to some user-defined pointer
MemCpy(^$D800, 0, my_ptr, 160);
Notes:
MemCpy is the slowest. It copies 0-256 bytes from A to B by basically (in assembler) saying
This is slow because for every copied byte, it needs to decrement i and test if it is zero and go to the top again
for i:=0 to 256 do B[i] := A[i];