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.
/*******************************************/ /*Name:Main Function */ /* Memory model: LARGE */ unsigned char Temp; unsigned char *pTemp; void func(void); void main(void) { unsigned char i = 6; pTemp = &Temp; *pTemp = 98; func(); i = *pTemp; } /*************************************************/ /*-------------------------------------- compile following program to assembly , then link with the main function.No Error! But the " i " cannot get the number "0xdd". Why and how to chang the assembly . please help me,thank you.! ------------------------------------------*/ #pragma src(MYPTR.A51) large extern unsigned char *pTemp; void func(void) { *pTemp = 0xdd; }
Is it possible that the compiler has optimized the variable i out? Since the value assigned to it is never used the compiler has the right to do so. You can try and disable optimizations or use the variable i somehow. Anyway, why not have a look at the generated code? Regards, - Mike
When I had compiled in SMALL memory model,it was OK. But when in LARGE memory model,the compiler generated wrong code for "i = *pTemp;". Is this a bug in Keil? -Bird
Are both files compiled for the same memory model? Jon
"the compiler generated wrong code for 'i = *pTemp;'." In what way was it "wrong?"
If you have optimizations on, doing absolutely nothing IS correct for "i = *pTemp;". Does your code fail if you compile it with no optimizations?
Thanks very much!Thanks Mike,Thanks Jon! Thanks all of you! My program is OK.