Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
675
memcmp
Prototype
sub function memcmp(dim p1, p2 as ^byte, dim n as word) as integer
Description The function returns a positive, negative, or zero value indicating the relationship 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/variable/constant) indicating
memory address or a dereferenced value of an object, for example
@mystring
or
@PORTB
.
Example
txt = “mikroElektronika”
txt_sub = “mikro”
res = memcmp(@txt, @txt_sub, 16) ‘ returns 69, which is ASCII code of the
first differing character - letter ‘E’
memcmp
Prototype
sub function memcmp(dim p1, p2 as ^byte, dim n as word) as integer
Description The function returns a positive, negative, or zero value indicating the relationship 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/variable/constant) indicating
memory address or a dereferenced value of an object, for example
@mystring
or
@PORTB
.
Example
txt = “mikroElektronika”
txt_sub = “mikro”
res = memcmp(@txt, @txt_sub, 16) ‘ returns 69, which is ASCII code of the
first differing character - letter ‘E’
memcpy
Prototype
sub procedure memcpy(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
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 first
4 characters of the ‘txt_sub’ string, beginning from the 4th character