compare constant array and variable array

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
vladaepro
Posts: 7
Joined: 29 May 2008 21:19

compare constant array and variable array

#1 Post by vladaepro » 15 Jul 2008 22:08

Hi

Anybody know how to compare constant array with variable array? memcmp don't work if const array given as input param.

For example, i have a const buffer:array[5] of byte = (1,2,3,4,5);

i can access sigle values ofcourse (b := buffer[5]), but can't pass it as param to function like:

function compare(a1,a2:pointer;len:byte):byte;
or
function compare(var a1,a2:array[20] of byte;len:byte):byte;
...

So my question is how to pass const array to procedure and how to access it in procedure?

vladaepro
Posts: 7
Joined: 29 May 2008 21:19

#2 Post by vladaepro » 16 Jul 2008 21:51

In a meanwhile i found a solution which i can use, but still not sure is it a right way, and will it work with other mc's (i'm using atmega32 currently).

If you pass address of const array to procedure (@buffer) you can read data with Flash_read function, but address must be divided by 2:

Flash_read(@buffer shr 1 + count)

Suppose that's something about byte/word alignment of data in flash memory...

Somebody have some explanation of this issue?

Post Reply

Return to “mikroPascal for AVR General”