User manual
mikroPascal PRO for PIC32
MikroElektronika
587
memcpy
memmove
memset
Prototype
procedure memcpy(p1, p2 : ^byte; nn : word);
Description The function copies nn words from the memory area starting at the address p2 to the memory area
starting at p1. If these memory buffers overlap, the memcpy function cannot guarantee that words are
copied before being overwritten. If these buffers do overlap, use the memmove function.
For parameters p1 and p2 you can use either a numerical value (literal/variable/constant) indicating
memory address or a dereferenced value of an object, for example @mystring or @PORTB.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
memcpy(@txt+4, @txt_sub, 4); // string ‘txt’ will be populated with the rst
4 characters of the ‘txt_sub’ string, beginning from the 4th character
Prototype
procedure memmove(p1, p2 : ^byte; nn : word);
Description The function copies nn words from the memory area starting at the address p2 to the memory area
starting at p1. If these memory buffers overlap, the Memmove function ensures that the words in p2 are
copied to p1 before being overwritten.
For parameters p1 and p2 you can use either a numerical value (literal/variable/constant) indicating
memory address or a dereferenced value of an object, for example @mystring or @PORTB.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
memmove(@txt+7, @txt_sub, 4); // string ‘txt’ will be populated with rst
4 characters of the ‘txt_sub’ string, beginning from the 7th character
Prototype
procedure memset(p : ^byte; character : byte; n : word);
Description The function lls the rst n words in the memory area starting at the address p with the value of word
character.
For parameter p you can use either a numerical value (literal/variable/constant) indicating memory
address or a dereferenced value of an object, for example @mystring or @PORTB.
Example
txt := ‘mikroElektronika’;
memset(@txt, ‘a’, 2); // routine will copy the character ‘a’ into each of
the rst ‘n’ characters of the string ‘txt’,