We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using Uvision 3 , Generating code for lpc2214
Here below is my simple code
int x=10 ; int y=100 ;
void ram_fun(void); void delay(void);
void main() { ram_fun(); while(1) { ; } }
void ram_fun(void) __ram { x = y/x; }
Here below I am pasting a section of the disassembly shown by .COD file generated by compiler
*** Disassembly of Segment '?C_INITSEG' when instruction is x = y/x: 00000130 40000498 DD 0x40000498
00000134 400004C4 DD 0x400004C4
Now if i replace x = y/x with x = x+y and no other changes in code or compiler settings than the disassembly shown by .COD file for ?C_INITSEG segment is as below.
*** Disassembly of Segment '?C_INITSEG' when instructio is x = x+y: 00000130 40000000 DD x
00000134 40000008 DD x + 0x8
00000138 0000000A DD 0xA
0000013C 00000064 DD 0x64
00000140 40000498 DD 0x40000498
00000144 400004B0 DD 0x400004B0
which shows the difference between ?C_INITSEG segment.
I have read somewhere that ?C_INITSEG is responsible for initilization of the global variables.
This disassembly clearly shows that there is no initlization code for Global variables when we have division operation in our code. Which agrees with my observation of the values of variables.
Please note that the replcement of division instruction with addition is only difference in both the case. All other code and settings are same.
If I remove __ram attribute than all works fine.
Can anybody explain this?
Is it problem with keil?
Thanks and regards.