Mikroelektronika MIKROE-350 データシート

ページ / 526
memcmp
memcpy
memmove
490
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function memcmp(dim p1, p2 as ^bytedim as wordas integer
Description
The function returns a positive, negative, or zero value indicating the relation-
ship of first n words of memory areas starting at addresses 
p1
and 
p2
.
This function compares two memory areas starting at addresses 
p1
and 
p2
for n
words and returns a value indicating their relationship as follows:
Value
Meaning
< 0       p1 "less than" p2
= 0       p1 "equal to" p2
> 0       p1 "greater than" p2
The value returned by the function is determined by the difference between the
values of the first pair of words that differ in the strings being compared.
For parameters 
p1
and 
p2
you can use either a numerical value (literal/vari-
able/constant) indicating memory address or a dereferenced value of an object,
for example 
@mystring
or 
@PORTB
.
Prototype
sub procedure memcpy(dim p1, p2 as ^bytedim nn as 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/vari-
able/constant) indicating memory address or a dereferenced value of an object,
for example 
@mystring
or 
@PORTB
.
Prototype
sub procedure memmove(dim p1, p2, as ^byte, dim nn as 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/vari-
able/constant) indicating memory address or a dereferenced value of an object,
for example 
@mystring
or 
@PORTB
.