This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem about location of local variable in data memory

I have problem about location of local variable in data memory. In my code

void WRITE_RTC(uchar Dat,uchar Addr)
{
xxx=(RTC_ADDR|WRITE);
Start();
Out_Byte(xxx);
Out_Byte(Addr);
Out_Byte(Dat);
Stop();
}

but in M51 file it show

TYPE BASE LENGTH RELOCATION SEGMENT NAME
DATA 0074H 0002H UNIT ?DT?_WRITE_RTC?I2C_DEVICE_FUNCTION3

in function I have only local variable uchar Dat,uchar Addr why keil fix address for them

Parents
  • Note that the beginning of the 2nd paragraph in that link directly answers your original question:

    "Normally, functions in Cx51 cannot be called recursively or in a fashion which causes reentrancy. The reason for this limitation is that function arguments and local variables are stored in fixed memory locations."

    Unless you absolutely need your functions to be reentrant, do not specify the 'reentrant' attribute. As it says in the link, that will make your code grossly inefficient!

Reply
  • Note that the beginning of the 2nd paragraph in that link directly answers your original question:

    "Normally, functions in Cx51 cannot be called recursively or in a fashion which causes reentrancy. The reason for this limitation is that function arguments and local variables are stored in fixed memory locations."

    Unless you absolutely need your functions to be reentrant, do not specify the 'reentrant' attribute. As it says in the link, that will make your code grossly inefficient!

Children
No data