funny things in arrays

General discussion on mikroPascal for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Skydec
Posts: 39
Joined: 30 Jan 2009 12:38

funny things in arrays

#1 Post by Skydec » 12 Feb 2009 12:48

I have a very strange thing happening in arrays.

I have declaired an array 0..10 of byte (a: array [0..10] of byte;)

When I do this:

Code: Select all

procedure somewhat();
var b,c: byte;
c:=0;
b:=U2RXREG;
  while something do
    a[c]:=b;
    // Checkpoint
   inc(c);
  end;
end;

When I check the variables on // Checkpoint, b does have a value but a[c] = 0 that's strange.

But another funny thing is, when I change the declaration from a in to an array of word (a: array[0..10] of word;) then I get a compile error:

0:86 E-420 Invalid ASM instruction (233): [W1] (0x0002B4) [W1]

Is there a known issue with arrays?

Thanks in advance

goran.marinkovic
mikroElektronika team
Posts: 265
Joined: 25 Nov 2008 09:09

#2 Post by goran.marinkovic » 13 Feb 2009 18:37

Hi,

Please post this question on our Support Desk:
http://www.mikroe.com/en/support/
And provide us with piece of code in a project like form that can be compiled
(packed in zip or rar format), which demonstrates the issue you are talking about.
Explain your code as much as possible, how it is supposed to work, when error occur,
what I need to do to reproduce your problem, so I can review it for any possible errors and suggestions.
It is important to send all the files in the project folder, so I can recreate your exact settings and flags of MCU.

Regards

Skydec
Posts: 39
Joined: 30 Jan 2009 12:38

#3 Post by Skydec » 16 Feb 2009 11:36

Thanks for your reply.

I've manage to fix it by leaving out the extra step.

b:=U2RXREG;
a[c]:=b;

I changed it to
a[c]:=U2RXREG;

And then it works fine (should work in the first place)

When I have some spare time, I'll change the code back and send you the Unit I've made.

Post Reply

Return to “mikroPascal for dsPIC30/33 and PIC24 General”