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
Hi Amey,
It seems you refer to the pointer description at MCU_S12Z_Compiler.pdf compiler page 163:
++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++
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!
-----------------------------------------------------------------------------------------------------------------------
Hi,
Anybody have seen this?
please reply. I am waiting
Regards,
Amey
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:
Have a great day,
Pascal
NXP Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------