AnsweredAssumed Answered

S12ZVM12 Memory model and pointer size

Question asked by AMEY KHATAVKAR on Feb 16, 2016
Latest reply on Feb 23, 2016 by Pascal Irrle

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

Outcomes