Rom constant address question - answered

Beta Testing discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Rom constant address question - answered

#1 Post by Dany » 14 Jun 2011 18:29

Hi, I see a difference in constant address between the content of a pointer to it and what the statistics "rom memory constants" show.

This is the code (that fully works by the way):

Code: Select all

program Const_Pointer_Test;

const WrdArr: array[10] of word = (1000,2000,3000,4000,5000,6000,7,8,9,0);
var Ptr: ^const word;
var   Wrd: word;

begin
  { Main program }
  Ptr := @WrdArr;      // <---------------- Ptr has a value of 0x822C (seen in the debugger)
  Wrd := Ptr^;                
  inc(Ptr);
  Wrd := Ptr^;
  inc(Ptr);
  Wrd := Ptr^;
end.
After the first instruction has been executed (see arrow), Ptr contains the address of constant "WrdArr".
The content of Ptr is then (seen in the debugger) 0x822C.
But: in the statistics screen the address of "WrdArr" seems to be 0x022C.
The list file shows also an address of 0x022C.

Do I miss something? (I am new to PIC24...)

Thanks in advance!
Last edited by Dany on 12 Aug 2011 20:45, edited 2 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: Rom constant address question

#2 Post by slavisa.zlatanovic » 15 Jun 2011 10:33

Hi Danny!

Please, see the MCU datasheet: READING DATA FROM PROGRAM MEMORY USING PROGRAM SPACE VISIBILITY.
PSV.PNG
PSV.PNG (49.06 KiB) Viewed 3137 times
Note how the address is formed: PSVPAG + 1(MSB) + EA[14:0].
In the Statistic Window you see the real address of the const WrdArr and in the Watch Window you see the value of the
pointer 1(MSB) + EA[14:0].
Best regards
Slavisa

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Rom constant address question

#3 Post by Dany » 15 Jun 2011 10:58

Aha! Thanks! :D :D :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing”