structure variable acess problem

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

structure variable acess problem

Post by Roshan » Sun Jun 21, 2009 11:05 am

Here is my sample program. Program compile ok.


Structure ttemp
id As Byte
ltemp As Byte
htemp As Byte
End Structure

Dim sample(13) As ttemp
Dim cnt As Byte

main:

For cnt = 0 To Bound(sample)
sample(cnt).id =10
sample(cnt).ltemp = 10
sample(cnt).htemp = 10
Next


my problem is only element 0 of sample hold value of 10. others are blank

where is my mistake .
ROSHAN

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sun Jun 21, 2009 11:24 am

Works fine here

Code: Select all

include "usart.bas"
include "convert.bas"

Structure ttemp
id As Byte
ltemp As Byte
htemp As Byte
End Structure

Dim sample(13) As ttemp
Dim cnt As Byte

setbaudrate(br19200)

For cnt = 0 To Bound(sample)
   sample(cnt).id = cnt
   sample(cnt).ltemp = cnt + 1
   sample(cnt).htemp = cnt + 2
Next 

For cnt = 0 To Bound(sample)
   write(dectostr(cnt), ":", 
         dectostr(sample(cnt).id),",",
         dectostr(sample(cnt).ltemp),",",
         dectostr(sample(cnt).htemp),13,10)
Next 
output

Code: Select all

0:0,1,2
1:1,2,3
2:2,3,4
3:3,4,5
4:4,5,6
5:5,6,7
6:6,7,8
7:7,8,9
8:8,9,10
9:9,10,11
10:10,11,12
11:11,12,13
12:12,13,14

Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

Post by Roshan » Sun Jun 21, 2009 11:47 am

Dear Sir,

I test it & it really works. Its ok.

I see result in isis> show variable. It still does not show other values. It may be problem of labcenter.

here is picture you can see.


http://hotfile.com/dl/7324431/d48ea94/error.JPG.html

BTW thanks for help.

Regards
ROSHAN

nigle
Registered User
Registered User
Posts: 36
Joined: Tue Aug 12, 2008 3:13 pm
Location: West London

Post by nigle » Mon Jun 22, 2009 12:24 pm

The code is probably working fine, but Isis is showing you the wrong memory for the array except for the first element.

The first element is at 0x005B, but Isis thinks the next one is at 0x0082, 39 bytes away. This happens to be the size of the whole array, so either Swordfish is outputing incorrect information or Isis isn't interpreting it correctly.

Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

Post by Roshan » Mon Jun 22, 2009 12:38 pm

Dear Nigle,

Yes, you are right. I see in isis.

Is there any soluation ? :roll:

Regards
ROSHAN

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Mon Jun 22, 2009 2:21 pm

..it's an ISIS issue, the COFF file generated works fine with MPLAB

Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

Post by Roshan » Tue Jun 23, 2009 12:54 pm

Ok, I will post this problem on labcenter forum.

Regards
ROSHAN

Post Reply