S12ZVM12 Memory model and pointer size

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S12ZVM12 Memory model and pointer size

987件の閲覧回数
ameykhatavkar
Contributor III

Hi Team,

As I understand, the memory model are defined to set the accesses to global non-constant data,

i.e. small model has 14 bit access, medium model has 18 bit and large model has 24bit access.

 

According these memory model, the size of pointer to non-constant data (int *) must be like,

Small = 2 byte(14bit), Medium= 3byte(18bit) , Large = 3byte (24bit).

 

But I observed that this is the not right scenario considering the small memory model. In the case of small memory model it is also of size 3byte.

This I confirmed as follows -

Created the project with Small memory model in Code warrior 10.6.4

 

int data = 0xff;

int *ptr1;

int sizePtr;

 

void main(void)

{

     ptr1 = &data;

     sizePtr = sizeof(ptr1);

 

     for(;;)     {

     }

}

Here the size of pointer 'ptr1' getting in sizePtr as 3.

Also I have confirmed the size of memory allocated for the pointer ptr1by looking into map file and here also it taking as 3 byte.

Please clarify/correct me. Is it a wrong scenario? or compiler is not taking care properly.

 

Regards,

Amey

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

786件の閲覧回数
trytohelp
NXP Employee
NXP Employee

Hi Amey,

It seems you refer to the pointer description at MCU_S12Z_Compiler.pdf compiler page 163:

++++++++++++++++++++++++++++++++++++++

pastedImage_0.png

++++++++++++++++++++++++++++++++++++++

Following the rule for the code:

++++++++++++++++++++++++++++++++++++++

int data = 0xff;

int *ptr1;

int sizePtr;

void main(void) {

  EnableInterrupts;

  /* include your code here */

        ptr1 = &data;

      sizePtr = sizeof(ptr1);

++++++++++++++++++++++++++++++++++++++

Sizeptr returns the value 3.

I've reproduced the problem on my side.

I need to investigate it and keep you informed


Have a great day,
Pascal
NXP Technical Support

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

786件の閲覧回数
ameykhatavkar
Contributor III

Hi,

Anybody have seen this?

please reply. I am waiting

Regards,

Amey

0 件の賞賛
返信

786件の閲覧回数
trytohelp
NXP Employee
NXP Employee

Hi Amey,

I've contacted the compiler team and got more information.

The size of the pointer within the program (i.e. sizeof(<pointer type>) is always 24-bit (i.e. 3-byte).

The table below (from the compiler manual) refers to the size of the addresses that are stored in the pointer types:

  • for small and medium memory models the addresses used for non-constant global data (RAM) are smaller (due to the encoding of the instructions using RAM addresses, resulting in smaller encoding size, if the application data fits in 14 / 18 – bits RAM addresses)
  • the other types of data (constant data or code) are placed in ROM, which require 24-bit addresses


Have a great day,
Pascal
NXP Technical Support

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信