It is currently 22 Nov 2017 16:28

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 13 Sep 2017 08:32 
Offline

Joined: 01 May 2014 10:46
Posts: 33
I've a problem with a record initialisation

I defined a font table:


type T_Font = record
                 FontName : ^byte;
                 FontColor: word;
              end;

const Fonts : array [0..7] of T_Font = ( (1,2), (3,4), (5,6), (7,8), (0,0), (0,0), (0,0), (0,0) );


In this silplified example I'm using numbers instead of pointer for easy debugging

Font [0] and Font [1] are correct, Font[2] shows illegal values and the program hangs


This is the code in list file
x9D0241B8 0x00000001 ;_Fonts+0
0x9D0241BC 0x00000002 ;_Fonts+4
0x9D0241C0 0x00000003 ;_Fonts+8
0x9D0241C4 0x00050004 ;_Fonts+12
0x9D0241C8 0x00060000 ;_Fonts+16
0x9D0241CC 0x00000007 ;_Fonts+20
0x9D0241D0 0x00000008 ;_Fonts+24
0x9D0241D4 0x00000000 ;_Fonts+28
0x9D0241D8 0x00000000 ;_Fonts+32
0x9D0241DC 0x00000000 ;_Fonts+36
0x9D0241E0 0x00000000 ;_Fonts+40
0x9D0241E4 0x00000000 ;_Fonts+44
0x9D0241E8 0x00000000 ;_Fonts+48
0x9D0241EC 0x00008000 ;_Fonts+52
0x9D0241F0 0x00004000 ;_Fonts+56
0x9D0241F4 0x00001000 ;_Fonts+60




It shows that a 32 bit alignment ist used. The adresses are the same as displayed in the watch window.
Adress of Font[2] is 0x9D0241C8 and value should be 5

Using FontColor:DWord the stucture is kept and the values are ok

For me it looks like a bug of the compiler

Mike


Top
 Profile  
 
PostPosted: 13 Sep 2017 16:04 
Offline
mikroElektronika team
User avatar

Joined: 25 Jan 2008 09:56
Posts: 9397
Hi,

I have tried the following piece of code in the hardware and software debugger (used PIC32MX460F512L) :
program test;

type T_Font = record
                 FontName : ^byte;
                 FontColor: word;
              end;

const Fonts : array [0..7] of T_Font = ( (1,2), (3,4), (5,6), (7,8), (0,0), (0,0), (0,0), (0,0) );

var test : T_Font;
var i : byte;

begin
  for i := 0 to 7 do
  begin
    test := Fonts[i];
  end
end.

In each iteration, the test variable was populated according to the array values.

Can you please tell me which compiler version and MCU are you using ?

Regards,
Filip.


Top
 Profile  
 
PostPosted: 14 Sep 2017 11:43 
Offline

Joined: 01 May 2014 10:46
Posts: 33
Oh yes, I forgot that

Micropascal 4.0.0
Pic 32MX795F512L


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: